Compare commits

...

693 Commits

Author SHA1 Message Date
coryb 748b7d552f Merge pull request #512 from go-jira/v3-api-search
update for v3 search api
2025-11-11 11:18:26 -08:00
Cory Bennett bf988a00b4 update for v3 search api 2025-11-11 11:08:53 -08:00
Judson Lester f50f3d2b16 Merge pull request #398 from nenad/patch/load-config-browse
Load config on "jira browse"
2025-05-07 11:44:51 -07:00
Ron Green 4263bd24f9 Merge pull request #450 from georgettica/georgettica/add-summary
feat(create): allow setting summary
2022-10-27 10:03:49 +03:00
Judson Lester f922fc7fb7 Merge pull request #440 from makkes/default-col-width
feat: add `defaultColWidth` template function
2022-10-26 17:28:42 -07:00
Judson Lester a5358286b2 Merge pull request #416 from samsm/patch-1
Update (miscopied?) description of rank command
2022-10-26 17:28:16 -07:00
Judson Lester e3f29d4884 Merge pull request #395 from seanblong/bug/remove-login-loop
Remove (possible) infinite loop from CmdLogin.
2022-10-13 10:11:48 -07:00
Ron Green 10ad221ce4 attempt to make tests pass 2021-12-05 18:00:31 +02:00
Ron Green 6e90b2000a feat(create): allow setting summary
shamelessly taken from his fork

a part of me going through all of the forks and pulling all of the
useful info out

Co-authored-by: Ben Cordero <bencord0@condi.me>
2021-12-05 17:56:12 +02:00
Mike Pountney 07bd89afca Merge pull request #447 from catskul/fix-rvl-auth-bearer-token
Fix rvl auth bearer token branch
2021-11-27 17:09:03 -08:00
Andrew Somerville b3723c7b63 wrap token comparisons in a function, proliferate it virtually everywhere apk-token was, and fix some related tab/space issues 2021-11-21 01:21:26 -05:00
Max Jonas Werner 80adab38ee feat: add defaultColWidth template function
This function can be used in templates to change the default column
width to accommodate wider terminals.
2021-08-09 13:15:32 +02:00
Rodney Lorrimar ccb5fadfc3 Add documentation for bearer token authentication 2021-08-03 13:18:36 +08:00
Rodney Lorrimar fedc66614f Add authentication-method: bearer-token 2021-08-03 13:02:38 +08:00
Ron Green a59fdc81fc feat(OWNERS): make myself a code owner 2021-05-27 09:10:23 -04:00
Ron Green 892bedc8a2 fix(actions): fix release.yml
this is a WIP and should solve the promotion problem
2021-05-18 09:55:03 -04:00
ldelossa 29b5dda228 chore: v1.0.28 changelog bump 2021-05-05 10:18:27 -04:00
Ron Green f16109e038 Update prepare-release.yml 2021-05-05 10:15:09 -04:00
Ron Green f089cd51f2 go fmt all tree 2021-05-05 08:40:24 -04:00
mlerman 70e91a94b5 Update cli.go
adding option --file for create command
2021-05-05 08:40:24 -04:00
Ron Green 298a637f8c fix rebase issue 2021-05-05 08:40:24 -04:00
Sam Schenkman-Moore 7f1a21fd5c Update (miscopied?) description of command
This looked like an artifact of a copy/paste sorta situation: the current description for the `rank` command has the description for the `block` command.

I ad libbed a new description that is hopefully at least _more_ correct 😄
2021-04-10 11:05:48 -04:00
Nenad Stojanovikj c32908a6ff Load config on "jira browse"
This is done in order to ensure consistency with the other commands on how the configuration files are loaded. I found out about it when I had set up a global project, but the "jira browse 1234" command complained about missing project.
2020-11-30 15:02:48 +01:00
seanblong 1c55c069d3 Remove (possible) infinite loop from CmdLogin. 2020-11-16 19:59:13 -08:00
ldelossa 2c7a9b2830 chore: V1.0.27 changelog bump 2020-10-07 16:09:58 -04:00
Evan Gates f7587f43f1 block: reverse order of arguments
The BLOCKER and ISSUE arguments for the block command were incorrect.
With hypothetical ticket names BLOCKER and ISSUE, calling

	jira block BLOCKER ISSUE

resulted in

	ISSUE blocks BLOCKER
	BLOCKER is blocked by ISSUE

which is the reverse of the documentation which claims it should be

	BLOCKER blocks ISSUE
	ISSUE is blocked by BLOCKER

Reverse order of the arguments so the documentation matches the
actual usage.  This does not break existing usage, only updates the
documentation.

Fixes #383
2020-10-01 13:48:18 -04:00
Evan Gates 0e3082fab6 templates: add wrap helper function
Add "wrap" command to TemplateProcessor.  Use
github.com/mitchellh/go-wordwrap to wrap lines on word breaks at
a given length.  This can make long fields much more readable in
a terminal.  E.g.

	{{ .fields.description | wrap 76 | indent 2}}
2020-09-30 11:51:06 -04:00
Keien Ohta 6fbc522ee7 also use login for subtask 2020-09-15 13:31:17 -04:00
Keien Ohta c2abbd9864 update templates with emailAddress and login
go-jira/jira#369
2020-09-15 13:31:17 -04:00
ldelossa c3d22b765a chore: v1.0.26 changelog bump 2020-09-11 14:12:24 -04:00
ldelossa 96ec3339a4 cicd: automated releases fixes
Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-09-11 14:04:47 -04:00
ldelossa 31f7b03978 cicd: automated changelog and release
Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-09-11 10:50:22 -04:00
ldelossa 578c44c628 chore: v1.0.25 release
Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-09-11 09:31:35 -04:00
ldelossa aa8dae7c5b bugfix: only build jira tool with gox
previosly running the "make all" target build th schema binary with the
same name as the jira binaries. This caused the schema tool to be called
incorrectly. Gox performing parallel builds made this issue only happen
"somtimes".

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-09-11 09:15:07 -04:00
ldelossa a8c961fe19 tests: rework passive tests into native go tests
this commit re-works the basic.t tests and administers them using go's
native testing suite.

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-09-11 09:15:07 -04:00
Alan Voiski 42e5d23f63 Ensure body is NPE safe 2020-09-07 16:24:45 -04:00
Alan Voiski b572037cfe Support empty responses in request commands
Avoid JSON parser when the response is empty - common cases for HTTP 204 in issues deletion, or moving issues to sprint.
2020-09-07 16:24:45 -04:00
ldelossa ff5decc114 fix(changelog): fix changelog version 2020-09-04 15:58:38 -04:00
ldelossa 1d27af0a2c Updated Changelog 2020-09-04 14:30:24 -04:00
Dan Loewenherz 7179f36e5f ensure GO111MODULE is set to on prior to installing
This closes #291.
2020-09-04 14:21:49 -04:00
coryb a1450e879f Merge pull request #367 from bbkane/master
Make -h flag show --help
2020-08-31 16:30:07 -07:00
Cory Bennett 7da5f353ac add @ldelossa to list of default reviewers 2020-08-31 16:26:57 -07:00
Cory Bennett 18e2c1d5b7 version bump 2020-08-31 16:23:50 -07:00
Cory Bennett c6ef367e89 Updated Changelog 2020-08-31 16:23:50 -07:00
Benjamin Kane 4bf1d030e7 Make -h flag show --help 2020-08-31 16:12:42 -07:00
ldelossa d093bcf63a cicd: deflake tests
this commit removes the parallel test matrix as parallel testing runs
the potention of trampling one another

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-08-31 13:26:57 -04:00
ldelossa 3bc5e42bd0 tests: transition if under review
this commit attempts to transition any failed test issues if they ticket
is left in "Under Review" state

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-08-31 12:55:19 -04:00
ldelossa 3c1c4d95e1 transition: map field name to id
this commit allows a user to use the more friendly field.Name when
transitioning to states which require custom field inputs.

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-08-28 22:06:46 -04:00
ldelossa 6a27e28c61 username-deprecation: use email and display names
this commit deprecates the searching ability by username and
instructs user to provide email or display names in commands.

the username parameter has been deprecated completely from v2 and v3
api

Signed-off-by: ldelossa <ldelossa@redhat.com>
2020-08-28 17:59:14 -04:00
coryb 36e2a914cd Merge pull request #349 from aszenz/patch-1
Fix command for sprint issues w/o project
2020-06-18 09:40:59 -07:00
coryb 97591ef200 Merge pull request #355 from go-jira/vanniktech-patch-1
Remove myself as a code owner
2020-06-18 09:21:40 -07:00
Niklas Baudy 5c93c4e8d7 Remove myself as a code owner
Frankly, I've stopped using this since I went from being employed to freelance and only a few of my clients are using Jira.
2020-06-18 11:38:56 +02:00
asrar a9dd1ed310 Fix command for sprint issues w/o project
Instead of echo error message, show all sprint issues
2020-06-12 12:01:36 +05:30
coryb af7a8f45e4 Merge pull request #323 from tjamet/issue-comment
Add support to get all comments for an issue
2020-03-24 12:10:26 -07:00
Thibault Jamet a311d0d817 Add support to get all comments for an issue 2020-03-24 14:44:55 +01:00
coryb 01c0c38d8c Merge pull request #318 from jrschumacher/patch-1
Update README for simpler instructions for Atlassian Cloud users
2020-02-26 10:04:38 -08:00
coryb 417568ca2d Merge pull request #317 from go-jira/privacy-migration
update all usage of user.name to user.accountId for privacy migration
2020-02-26 10:02:23 -08:00
Ryan Schumacher fae004391a Update authentication for more clarity 2020-02-25 16:06:58 -08:00
Cory Bennett a26683e01d update all usage of user.name to user.accountId for privacy migration:
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/
2020-02-23 23:59:39 -08:00
Mike Pountney 57e1c7426e Merge pull request #302 from go-jira/simplify-template-tables
add template functions to handle table output, fixes #176, replaces #296
2019-12-02 18:19:10 -08:00
Cory Bennett 7e9746304a add template functions to handle table output, fixes #176, replaces #296 2019-12-02 14:43:07 -08:00
coryb 7cd34d3698 Merge pull request #292 from pdecat/cache_password
Cache password to avoid invoking password source on each API request with api-token
2019-12-01 20:58:02 -08:00
coryb f5871c5a58 Merge branch 'master' into cache_password 2019-12-01 20:41:49 -08:00
Cory Bennett 01bdea9778 Merge branch 'patrickpichler-make-password-source-binary-exchangeable' 2019-12-01 20:30:11 -08:00
Cory Bennett d6173ce77d use password-source-path to allow overriding binary and/or path to binary 2019-12-01 20:27:00 -08:00
Cory Bennett e26fbfcb14 Merge branch 'make-password-source-binary-exchangeable' of https://github.com/patrickpichler/jira into patrickpichler-make-password-source-binary-exchangeable 2019-12-01 20:16:40 -08:00
coryb b590005aac Merge pull request #301 from go-jira/allow-issue-ints
allow issues on command line to automatically prefix with project when defined
2019-12-01 17:27:59 -08:00
Cory Bennett d002d7fe74 allow issues on command line to automatically prefix with project when defined 2019-12-01 16:29:35 -08:00
colton riffel 789886c68e Forgot you use TAB instead of spaces 2019-12-01 16:21:52 -08:00
colton riffel 8a462152ea Fixed append project to view 2019-12-01 16:21:52 -08:00
colton riffel 9cbd9937be Added a line break removal function 2019-12-01 16:21:52 -08:00
colton riffel db53622548 Pushed Readfile to .jira.d directory instead of pwd 2019-12-01 16:21:52 -08:00
Patrick Decat 0f059a5ed1 Cache password to avoid invoking password source on each API request 2019-11-02 09:46:50 +01:00
Patrick Pichler 659a5c8e74 Add support to switch out password source binary
There is now a new configuration entry option `password-source-binary`,
which allows to use an alternate binary for the gopass/pass password
source.

If the option is not specified, we will fallback to `pass` (for `pass`)
and `gopass` (for `gopass`).
2019-10-21 10:49:38 +02:00
coryb 590244947b Merge pull request #286 from patrickpichler/add-gopass-instructions-to-readme
Add gopass section to README.md
2019-10-04 08:52:05 -07:00
Patrick Pichler 6e87b646ff Add gopass section to README.md 2019-10-04 10:06:02 +02:00
Mike Pountney b045cd74c2 Merge pull request #285 from patrickpichler/add-gopass-support
Add gopass as password source support
2019-10-03 17:04:31 -07:00
Patrick Pichler 3339303e89 Add error handling to pass password-source 2019-10-03 13:43:56 +02:00
Patrick Pichler 3c0a62e74f Add gopass support 2019-10-03 13:24:32 +02:00
coryb 967602392f fix travis build badge 2019-10-02 11:00:02 -07:00
coryb 568f0be821 Merge pull request #283 from go-jira/sprig
add sprig template functions, replaces [#215]
2019-10-02 10:53:09 -07:00
Cory Bennett 719f7a68a7 add sprig template functions, replaces [#215]
http://masterminds.github.io/sprig/
2019-10-02 08:24:04 -07:00
Cory Bennett 979910f8dd Merge branch 'arenstar-feature/projectversion' 2019-10-01 23:50:19 -07:00
Cory Bennett 90f01ce60a [#232] fix api to use common Version schema
also rewrote the schema fetcher to use Go
2019-10-01 23:40:33 -07:00
Cory Bennett 2c9d957304 version bump 2019-10-01 21:33:10 -07:00
Cory Bennett 4445255914 Updated Changelog 2019-10-01 21:33:10 -07:00
Cory Bennett a13b046fad fix syntax 2019-10-01 21:33:10 -07:00
Adriano 997b6e1f24 Add 'pctOf' and 'fit' template functions 2019-10-01 21:33:10 -07:00
Patrick Cockwell 8ede63c37e Address comments for direct name match 2019-10-01 21:33:10 -07:00
Patrick Cockwell 62ccffaf05 Choose exact transition match if available 2019-10-01 21:33:10 -07:00
Mike Pountney 2062dffc60 fix _t/test_binaries.sh to work on Linux + MacOS 2019-10-01 21:33:10 -07:00
Mike Pountney 435747f152 Ensure travis makes and tests binaries 2019-10-01 21:33:10 -07:00
Mike Pountney d343852592 Update from xgo to gox; add basic test for binaries 2019-10-01 21:33:10 -07:00
Mike Pountney 22c72f2351 version bump 2019-10-01 21:33:10 -07:00
Mike Pountney a057957086 Updated Changelog 2019-10-01 21:33:10 -07:00
Mike Pountney 3333859bf0 Updated Changelog 2019-10-01 21:33:10 -07:00
Cory Bennett 8b56ee9fb9 update to more actively supported xgo for module support 2019-10-01 21:33:10 -07:00
Mike Pountney a467a5c5e5 Add 1.13.x build test to travis 2019-10-01 21:33:10 -07:00
Cory Bennett 0d7d4dc4b8 [#277] update figtree to latest 2019-10-01 21:33:10 -07:00
Mike Pountney ba7cc13145 Switch over to using github.com/go-jira/jira, from gopkg.in
There should be no reason to use gopkg.in versioned imports now that
we're using go modules. I think, IANAE.

gopkg.in kind of gets in the way of modules, as it only pulls over
tagged releases from github.com -- this then means that you need to use
go modules 'replace' syntax in the go.mod to use a non-versioned commit
or branch. This is feasible, but kind of ugly.

go modules defaults to pulling the latest version, so the default
behavior is the same as when pulling go-jira.v1 from gopkg.in.
2019-10-01 21:29:46 -07:00
Mike Pountney 3984d0d484 Fixes #228: make ':' gpg files temporary to fix go mod 2019-10-01 21:29:45 -07:00
Matthias Bethke 0037a21a95 fix worklog template to allow multiline comments 2019-10-01 21:29:45 -07:00
Justin Ko b99dfbfbf6 Allow reading password from stdin
Allow reading password from stdin in `jira login`. This is useful for
combining the jira tool with other command-line utilities.
2019-10-01 21:29:45 -07:00
Cory Bennett 8e4245e5bb add CODEOWNERS file 2019-10-01 21:29:45 -07:00
Daniel Martí bb9790f287 all: unindent some code 2019-10-01 21:29:45 -07:00
Daniel Martí 17003717d9 don't use ReadAll when decoding JSON
An empty stream isn't valid JSON, so we shouldn't silently ignore it.
2019-10-01 21:29:45 -07:00
Daniel Martí dc9a9de165 README: trim down the content
This README is huge; the document shouldn't take more than two or three
screens. If we need more docs, they should be linked to and live
elsewhere.

For now, start by removing unnecessary sections. Gitter has been
completely unused since 2017, so remove it. The table of contents also
takes a lot of vertical space, when we don't want to have that much
content to begin with.

Tips on forking are also unnecessary, since that's the same for all Go
projects. Moreover, this is out of date now that the project is a Go
module.

Remove the help output, as that can be obtained extremely easily by just
running 'jira -h'.

Finally, remove the v0-v1 changes, as v0 was last released over three
years ago. It's extremely unlikely that anyone still has to upgrade from
the older version.
2019-10-01 21:29:45 -07:00
Daniel Martí 30998cbb18 start making staticcheck happier 2019-10-01 21:29:45 -07:00
Daniel Martí 89fe2ecf16 all: convert to a Go module
And remove vendor/, as it's now unnecessary. go.sum ensures that
dependencies aren't tampered with, and proxy.golang.org keeps copies of
all the archives.
2019-10-01 21:29:45 -07:00
Daniel Martí 8994b42f71 t: rename to _t to fix module support
The following two files contain characters which aren't valid in source
files within a Go module:

	t/.password-store/GoJira/api-token:gojira@corybennett.org.gpg
	t/.password-store/GoJira/api-token:mothra@corybennett.org.gpg

The directory only contains test scripts, so it doesn't need to be
included in the module. The simplest way to do that is to start the
directory with an underscore.

Fixes #228.
2019-10-01 21:29:45 -07:00
Daniel Martí 80743e4da8 CI: test on Go 1.12.x, cleanup
We can also use the apt addon to install packages. We also don't need
fast_finish, since we don't use allow_failures anywhere.

Finally, the 'go get' line was pointless, as all dependencies are
vendored, and 'go test' will catch build failures.
2019-10-01 21:29:45 -07:00
Cory Bennett 9f46c8499d make automatic pagination on search optional, fix tests 2019-10-01 21:29:45 -07:00
Julien Graglia bca064be1f API Token auth requires "user" config
API Token authentication requires the `user ` to be defined in the config
2019-10-01 21:29:45 -07:00
Julian Swagemakers 48c15e2daa docs: update pass documentation with password-name
This will update the README.md to include setting the configuration
option password-name when using pass.
2019-10-01 21:29:45 -07:00
CodeLingo Bot 3cf2e56e1f Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-10-01 21:29:45 -07:00
Cory Bennett c270f20d21 add test for --limit 2019-10-01 21:29:45 -07:00
Cory Bennett a6bf26052c prefer defer resp.Body.Close to avoid leaks on subsequent errors 2019-10-01 21:29:45 -07:00
Cory Bennett 954a97eca3 version bump 2019-10-01 21:29:45 -07:00
Cory Bennett dd6901b2cd Updated Changelog 2019-10-01 21:29:45 -07:00
Miles Maddox 9186205b9e add pagination to search 2019-10-01 21:29:45 -07:00
Cory Bennett 78c66dba6f version bump 2019-10-01 21:20:00 -07:00
Cory Bennett 87112c0f98 Updated Changelog 2019-10-01 21:20:00 -07:00
Cory Bennett 94dd489a10 fix syntax 2019-10-01 21:20:00 -07:00
coryb 050a2b4819 Merge pull request #273 from acaloiaro/master
Add 'pctOf' and 'fit' template functions
2019-10-01 21:15:20 -07:00
coryb d3b3c03f90 Merge pull request #282 from pcockwell/fix/choose-direct-transition-match-if-available
Choose exact transition match if available
2019-09-30 17:06:30 -07:00
Patrick Cockwell a70384b03b Address comments for direct name match 2019-09-30 16:57:14 -07:00
Patrick Cockwell a646f76b1f Choose exact transition match if available 2019-09-30 16:41:44 -07:00
Mike Pountney 9bb0ff379d Merge pull request #280 from go-jira/cut_v1_0_21
Cut v1.0.21 onto master; make binaries with gox not xgo, and test them.
2019-09-28 23:50:13 -07:00
Mike Pountney 0726101762 fix _t/test_binaries.sh to work on Linux + MacOS 2019-09-17 22:27:28 -07:00
Mike Pountney 2d13725ccf Ensure travis makes and tests binaries 2019-09-17 22:19:37 -07:00
Mike Pountney 490a47db43 Merge branch 'use_gox_not_xgo' into cut_v1_0_21 2019-09-17 21:55:24 -07:00
Mike Pountney 396ae5fb6a Update from xgo to gox; add basic test for binaries 2019-09-17 21:48:59 -07:00
Mike Pountney ff12f26f81 version bump 2019-09-16 18:40:18 -07:00
Mike Pountney 7424ebc606 Updated Changelog 2019-09-16 18:40:18 -07:00
Mike Pountney 85de83a6e2 Updated Changelog 2019-09-16 18:36:52 -07:00
Cory Bennett fc5be16ac6 update to more actively supported xgo for module support 2019-09-16 17:54:35 -07:00
Mike Pountney 000a923189 Merge pull request #275 from go-jira/remove_gopkg_in
Migrate from gopkg.in to github.com, to support 'go mod' more cleanly
2019-09-16 15:08:34 -07:00
Mike Pountney d5e4ce3df1 Add 1.13.x build test to travis 2019-09-16 14:42:29 -07:00
Mike Pountney 7320d4afef resolve merge conflict in cmd/jira/main.go 2019-09-16 08:34:26 -07:00
Mike Pountney 3ecca6895d Merge pull request #278 from go-jira/update-figtree
[#277] update figtree to latest
2019-09-16 08:27:49 -07:00
Cory Bennett 0e520a49ae [#277] update figtree to latest 2019-09-15 23:41:42 -07:00
Mike Pountney 27f57b2bbe Switch over to using github.com/go-jira/jira, from gopkg.in
There should be no reason to use gopkg.in versioned imports now that
we're using go modules. I think, IANAE.

gopkg.in kind of gets in the way of modules, as it only pulls over
tagged releases from github.com -- this then means that you need to use
go modules 'replace' syntax in the go.mod to use a non-versioned commit
or branch. This is feasible, but kind of ugly.

go modules defaults to pulling the latest version, so the default
behavior is the same as when pulling go-jira.v1 from gopkg.in.
2019-09-14 21:31:11 -07:00
coryb 71aaa88b13 Merge pull request #276 from go-jira/fix_228
Fixes #228: make ':' gpg files temporary to fix go mod
2019-09-13 22:13:01 -07:00
Mike Pountney 52a577ea48 Fixes #228: make ':' gpg files temporary to fix go mod 2019-09-13 21:38:25 -07:00
Adriano 027adeef46 Add 'pctOf' and 'fit' template functions 2019-08-25 15:20:48 -04:00
coryb b8e73a5cb0 Merge pull request #266 from mbethke/fix-multiline-worklog-comment
Fix worklog template for multiline comments
2019-07-05 11:43:48 -07:00
Matthias Bethke 43e07f1197 fix worklog template to allow multiline comments 2019-07-05 09:07:09 +02:00
coryb 957696bed8 Merge pull request #263 from kojustin/master
Allow reading password from stdin
2019-06-05 14:24:50 -07:00
Justin Ko 225e1dcc05 Allow reading password from stdin
Allow reading password from stdin in `jira login`. This is useful for
combining the jira tool with other command-line utilities.
2019-06-05 14:08:09 -07:00
Cory Bennett f1390760b4 add CODEOWNERS file 2019-05-28 17:31:23 -07:00
Daniel Martí 31c113d1ba all: unindent some code 2019-05-28 11:01:51 +01:00
Daniel Martí 9bcdcc128f don't use ReadAll when decoding JSON
An empty stream isn't valid JSON, so we shouldn't silently ignore it.
2019-05-27 13:09:31 +01:00
Daniel Martí 098d963881 README: trim down the content
This README is huge; the document shouldn't take more than two or three
screens. If we need more docs, they should be linked to and live
elsewhere.

For now, start by removing unnecessary sections. Gitter has been
completely unused since 2017, so remove it. The table of contents also
takes a lot of vertical space, when we don't want to have that much
content to begin with.

Tips on forking are also unnecessary, since that's the same for all Go
projects. Moreover, this is out of date now that the project is a Go
module.

Remove the help output, as that can be obtained extremely easily by just
running 'jira -h'.

Finally, remove the v0-v1 changes, as v0 was last released over three
years ago. It's extremely unlikely that anyone still has to upgrade from
the older version.
2019-05-27 13:08:36 +01:00
Daniel Martí 9b9186f7d4 start making staticcheck happier 2019-05-27 10:49:15 +01:00
Daniel Martí f125ef3fa9 all: convert to a Go module
And remove vendor/, as it's now unnecessary. go.sum ensures that
dependencies aren't tampered with, and proxy.golang.org keeps copies of
all the archives.
2019-05-26 23:40:16 +01:00
coryb 5cc009af4c Merge pull request #253 from mvdan/module
t: rename to _t to fix module support
2019-05-26 14:41:18 -07:00
Daniel Martí d237e86cda t: rename to _t to fix module support
The following two files contain characters which aren't valid in source
files within a Go module:

	t/.password-store/GoJira/api-token:gojira@corybennett.org.gpg
	t/.password-store/GoJira/api-token:mothra@corybennett.org.gpg

The directory only contains test scripts, so it doesn't need to be
included in the module. The simplest way to do that is to start the
directory with an underscore.

Fixes #228.
2019-05-26 22:34:24 +01:00
Daniel Martí 664c5cad24 CI: test on Go 1.12.x, cleanup
We can also use the apt addon to install packages. We also don't need
fast_finish, since we don't use allow_failures anywhere.

Finally, the 'go get' line was pointless, as all dependencies are
vendored, and 'go test' will catch build failures.
2019-05-26 21:34:53 +01:00
Cory Bennett 36c99ce040 make automatic pagination on search optional, fix tests 2019-05-25 17:06:03 -07:00
coryb 58a300422b Merge pull request #240 from jgraglia/patch-1
API Token auth requires "user" config
2019-05-25 15:34:25 -07:00
coryb eb90676bbc Merge pull request #219 from kerhac/master
docs: update pass documentation with password-name
2019-05-25 15:33:39 -07:00
coryb d54a549d24 Merge pull request #236 from CodeLingoBot/rewrite
Fix function comments based on best practices from Effective Go
2019-05-25 14:12:06 -07:00
Cory Bennett 3d00c294f4 add test for --limit 2019-05-25 14:10:18 -07:00
Cory Bennett 181bd74f1b prefer defer resp.Body.Close to avoid leaks on subsequent errors 2019-05-25 14:09:48 -07:00
Cory Bennett f6809e32f4 version bump 2019-05-25 14:09:12 -07:00
Cory Bennett cbcac1755a Updated Changelog 2019-05-25 14:09:12 -07:00
coryb 890b9aa724 Merge pull request #245 from justmiles/211
add pagination to search (closes #211)
2019-05-25 14:08:09 -07:00
Miles Maddox 76dd1d8982 add pagination to search 2019-04-21 07:33:17 -05:00
Julien Graglia 271289a3c9 API Token auth requires "user" config
API Token authentication requires the `user ` to be defined in the config
2019-03-26 09:49:29 +01:00
Julian Swagemakers d8189f0a01 docs: update pass documentation with password-name
This will update the README.md to include setting the configuration
option password-name when using pass.
2019-03-13 07:48:50 +01:00
CodeLingo Bot 23ac11872b Fix function comments based on best practices from Effective Go
Signed-off-by: CodeLingo Bot <bot@codelingo.io>
2019-02-28 21:20:03 +00:00
David Arena 410df68354 Returning upstream 2019-02-05 17:21:51 +01:00
David Arena aaa72012a7 Adding ProjectVersion 2019-02-04 18:36:11 +01:00
coryb 514c1491c7 Merge pull request #220 from ejsuncy/master
docs: Fix grammar typos (#1)
2018-11-29 19:52:02 -08:00
Dan Bunker 9258d4df15 Fix grammar typos (#1) 2018-11-29 11:20:55 -07:00
Cory Bennett ee69afadd0 [#201] update required library, failing to populate cookiejar from cookies file 2018-08-04 14:20:03 -07:00
Cory Bennett a87bdf4038 version bump 2018-08-02 23:07:00 -07:00
Cory Bennett 68c2588153 Updated Changelog 2018-08-02 23:07:00 -07:00
Cory Bennett 0cba806942 [#199] [#198] update http client library, fix issues with internal login retries 2018-08-02 23:05:01 -07:00
Cory Bennett df9dbe65b4 update amp in pom, prevents dumb prompt at jira startup 2018-08-02 23:05:01 -07:00
coryb 492754f059 Merge pull request #197 from kojiromike/spellcheck
Fix Spelling
2018-07-30 08:32:49 -07:00
Michael A. Smith 97d8c5f6e0 Fix Spelling 2018-07-30 09:20:04 -04:00
Cory Bennett 1e619ea690 version bump 2018-07-29 14:56:46 -07:00
Cory Bennett b7d8a9c324 Updated Changelog 2018-07-29 14:56:46 -07:00
Cory Bennett 8b717de870 Updated Usage 2018-07-29 14:56:46 -07:00
Cory Bennett f5921077ca [#196] add jira session command to show session information if user is authenticated 2018-07-29 14:54:21 -07:00
Cory Bennett c9a4e30606 [#192] fix template usage for 'fixVersions' in transition template 2018-07-29 13:24:19 -07:00
Cory Bennett ef9b731bac move HandleExit to the jiracli package 2018-07-28 17:21:18 -07:00
Cory Bennett 62303ed81b add missing vendored files 2018-07-28 16:55:36 -07:00
Cory Bennett 7191c7751b they broke golang.org/x/net: ERROR: vendor/golang.org/x/net/proxy/socks5.go:11:2: use of internal package not allowed 2018-07-28 16:41:16 -07:00
Cory Bennett d16bcc2f51 udpate deps 2018-07-28 16:29:51 -07:00
Cory Bennett 07ba74b34a udpate for figtree api changes 2018-07-28 15:50:13 -07:00
Cory Bennett 462ef1c485 udpate to use latest dep, update figtree 2018-07-28 15:49:57 -07:00
Cory Bennett eead13aef1 Merge branch 'pr/171' 2018-05-25 21:52:44 -07:00
Cory Bennett 213a7e04af [#171] change proposed PasswordPath to PasswordName 2018-05-25 21:50:28 -07:00
Cory Bennett 49e44670d9 fix usage generation after #178 2018-05-24 00:23:29 -07:00
Cory Bennett 5503e53168 Updated Changelog 2018-05-24 00:23:15 -07:00
Cory Bennett 9ebd2cd64e fix IsTerminal usage for windows 2018-05-24 00:23:15 -07:00
Cory Bennett 84b6155b0d version bump 2018-05-24 00:23:15 -07:00
Cory Bennett c23ad75957 Updated Changelog 2018-05-24 00:23:15 -07:00
coryb 3c478004d2 Merge pull request #178 from vergenzt/patch-1
Move usage info higher up in readme
2018-05-24 00:22:51 -07:00
Tim Vergenz ed42ef920a Move usage info higher up in readme
It was frustrating wading through the whole readme when all I was trying to figure out was what typical usage looks like to decide whether this project is what I'm looking for. :) Putting basic usage sooner would have helped.
2018-05-14 10:35:11 -07:00
dvogt23 fa01ff5c46 add pass path to config 2018-04-27 12:09:53 +02:00
Cory Bennett b98da3612d Updated Changelog 2018-04-15 19:21:10 -07:00
Cory Bennett 7f9595cf15 fix IsTerminal usage for windows 2018-04-15 19:10:29 -07:00
Cory Bennett 09584981b6 version bump 2018-04-15 17:55:00 -07:00
Cory Bennett 1bc6b55b85 Updated Changelog 2018-04-15 17:55:00 -07:00
Cory Bennett d787ac030c [#166] fix issue when editing templates specified with full path 2018-04-15 17:40:22 -07:00
Cory Bennett 09a61c3ea1 only prompt on logout if stdin and stdout are terminals 2018-04-15 17:15:48 -07:00
Cory Bennett 64ce3812a6 only prompt on logout if stdin is an active terminal 2018-04-15 17:07:01 -07:00
Cory Bennett 9146346e2f [#163] fix url path join logic 2018-04-15 16:56:09 -07:00
Cory Bennett e639cce9af [#160] prompt when api-token is invalid to get new token 2018-04-15 15:30:30 -07:00
Cory Bennett 06b26c9e00 [#157] add password-directory: path to allow overriding PASSWORD_STORE_DIR from configs 2018-04-15 13:56:37 -07:00
coryb ac39f9ae1d Merge pull request #161 from vanniktech/patch-1
Add syntax highlighting to YAML blocks in README
2018-04-03 09:28:36 -07:00
Cory Bennett bd3cf994b8 [#160] allow jira logout to delete your api-token from keychain 2018-04-03 09:21:52 -07:00
Niklas Baudy 91059b3578 Add syntax highlighting to YAML blocks in README 2018-04-03 17:45:39 +02:00
Cory Bennett 4b9873b323 version bump 2018-04-01 12:04:52 -07:00
Cory Bennett cd106df78a Updated Changelog 2018-04-01 12:04:52 -07:00
Cory Bennett 50b5360cfe Updated Usage 2018-04-01 12:04:52 -07:00
Cory Bennett 359bec2fdf [#159] fix slice bounds out of range error in abbrev template function 2018-04-01 11:47:23 -07:00
Cory Bennett 79c83f6911 [#158] always print usage to stdout 2018-04-01 11:31:09 -07:00
coryb 585382eaea Merge pull request #150 from catskul/parameterized-go-makefile
make it easier to compile with aribtrary version of go via GO env var
2018-03-08 14:15:11 -08:00
Cory Bennett 9c818d427c use latest xgo since the project has been updated again 2018-03-08 13:54:04 -08:00
Cory Bennett 8621d9e698 version bump 2018-03-08 13:54:04 -08:00
Cory Bennett 5610707c30 Updated Changelog 2018-03-08 13:54:04 -08:00
Cory Bennett 0b4e16a35d Updated Usage 2018-03-08 13:54:04 -08:00
coryb 57bc97a378 Merge pull request #153 from catskul/document-shell-completion
Document shell completion
2018-03-08 13:48:56 -08:00
Andrew Somerville 2d02cf8132 fix md link 2018-03-08 16:47:25 -05:00
coryb 18a687e78a Merge pull request #152 from catskul/fix-missing-priority
prevent crash if priority is not set
2018-03-08 13:47:02 -08:00
Andrew Somerville 5d058536d2 Add in a stanza to the Usage section about tab completion 2018-03-08 16:38:36 -05:00
Cory Bennett d4153be0ec fix toc 2018-03-08 11:39:41 -08:00
Cory Bennett edb06621f8 [#148] [#149] add support for api token based authentication 2018-03-08 10:58:04 -08:00
coryb 161a68920d Merge pull request #151 from catskul/build-instructions
more explicit build instructions for newbies
2018-03-07 17:11:39 -08:00
Andrew Somerville fd30bc1392 prevent crash if priority is not set 2018-03-07 16:59:47 -05:00
Andrew Somerville 84f77be87c Add some text for newbies on handling forking and the difficulty of fully qualified import paths 2018-03-07 16:34:38 -05:00
Andrew Somerville dea794f037 make it easier to compile with aribtrary version of go via GO env var 2018-03-07 15:59:40 -05:00
Cory Bennett 43ebc846b1 refactor to simplify main 2018-03-06 22:36:32 -08:00
Cory Bennett 0d7c1a7931 refactor to simplify main 2018-03-06 22:34:49 -08:00
Cory Bennett 80325a5955 [#145] fix to match AuthProvider interface 2018-02-21 20:16:12 -08:00
Cory Bennett 20a9666fcd [#141] better handling in responseError for non-json error responses 2018-02-11 16:46:25 -08:00
coryb 4ae760f18f Merge pull request #142 from anthonyrisinger/patch-1
Update unexportTemplates.go
2018-01-19 12:40:13 -08:00
C Anthony Risinger 6da9974380 Update unexportTemplates.go
Logic error, `-d` can be set but was never used.
2018-01-19 13:29:21 -06:00
Cory Bennett 8c7ca383f6 [#139] add shellquote and toMinJson template functions 2018-01-07 10:49:00 -08:00
Cory Bennett 425fa63d33 [#137] update kingpeon dep to allow access to dynamic command structure 2018-01-06 17:18:34 -08:00
Cory Bennett 464742c9ba field name is "comment" not "comments" 2017-12-13 11:09:25 -08:00
Cory Bennett 7fbd87289f version bump 2017-11-04 15:32:40 -07:00
Cory Bennett d400b58019 Updated Changelog 2017-11-04 15:32:40 -07:00
Cory Bennett d4a3af862d Updated Usage 2017-11-04 15:32:40 -07:00
Cory Bennett 042bc48649 [#131] fix parsing global options before command execution (allow unixproxy/socksproxy to be set in config.yml) 2017-11-04 15:26:27 -07:00
Cory Bennett a2e36e808a add/update deps 2017-11-04 15:25:51 -07:00
Cory Bennett 84bd64a188 update 2017-11-02 15:02:17 -07:00
coryb efbd1dd96d Merge pull request #130 from onionjake/master
add support for using socks proxy
2017-11-02 13:45:03 -07:00
onionjake ff985f910b add support for using socks proxy 2017-11-02 14:30:19 -06:00
Cory Bennett 9597f9b56f fix transition comman 2017-10-28 14:46:50 -07:00
Cory Bennett 66c069e3b4 version bump 2017-10-28 14:26:38 -07:00
Cory Bennett 14189c197b Updated Changelog 2017-10-28 14:26:38 -07:00
Cory Bennett c9b5054cde fix default values to load after parsing configs 2017-10-28 14:23:27 -07:00
coryb f23b1c4370 Merge pull request #126 from schorsch3000/master
Add regexReplace template function
2017-10-28 14:07:25 -07:00
Cory Bennett 6c742dad0a ignore "composite literal uses unkeyed fields" vet checks 2017-10-28 12:42:48 -07:00
Cory Bennett 3966defc53 add test to make sure IssueType.Fields does not disappear on regeneration 2017-10-28 12:28:25 -07:00
Cory Bennett 794f8dd259 Merge branch 'thedillonb-fix-missing-fields' 2017-10-28 12:21:37 -07:00
Cory Bennett 41d1a7c9a1 add tests for validating changes to auto-generated jiradata files 2017-10-28 12:21:07 -07:00
Brian Lachniet 90007771bf Fix typo in 'logout' command help 2017-10-28 12:21:07 -07:00
Mark Harrison 7bfa241547 Add URL escaping to an additional issuetype call
In #34 a fix was made to escape the issue type to support issue types
with spaces in. This is an additional place where the issue type needs
escaping, otherwise you get 400 Bad Request when trying to create an
issue for an issuetype that has a space in.
2017-10-28 12:21:07 -07:00
Ivan Andrus e6600cf1a5 Add --resolution option 2017-10-28 12:21:07 -07:00
Cory Bennett 2e608207cb add tests for validating changes to auto-generated jiradata files 2017-10-28 12:19:36 -07:00
coryb bc1b994019 Merge pull request #129 from blachniet/logout-help-typo-fix
Fix typo in 'logout' command help
2017-10-28 09:21:15 -07:00
Brian Lachniet fd399d817e Fix typo in 'logout' command help 2017-10-28 11:04:02 -04:00
coryb f7b587ee91 Merge pull request #124 from gvol/master
Allow overriding resolution
2017-10-27 12:08:36 -07:00
coryb de69971c1c Merge pull request #128 from mivok/escape-issuetype
Add URL escaping to an additional issuetype call
2017-10-26 13:53:08 -07:00
Mark Harrison 2f9b8bb5c1 Add URL escaping to an additional issuetype call
In #34 a fix was made to escape the issue type to support issue types
with spaces in. This is an additional place where the issue type needs
escaping, otherwise you get 400 Bad Request when trying to create an
issue for an issuetype that has a space in.
2017-10-26 16:28:41 -04:00
Dillon Buchanan 093c510ca2 Create Metadata Not Populated Correctly
Fixes #123
2017-10-25 14:28:49 -04:00
Dirk Heilig d3e294e1ce add regexReplace template function 2017-10-19 14:58:11 +02:00
Ivan Andrus 4ed8edbd19 Add --resolution option 2017-10-13 12:22:12 -06:00
Cory Bennett 28d92eb659 version bump 2017-10-04 10:58:50 -04:00
Cory Bennett d16db04e58 Updated Changelog 2017-10-04 10:58:49 -04:00
Cory Bennett 4d74554300 add {{env.VARNAME}} template support to allow use of env vars 2017-10-03 18:47:33 -04:00
Cory Bennett 172793ea69 version bump 2017-09-26 22:50:54 -07:00
Cory Bennett dc504de271 Updated Changelog 2017-09-26 22:50:54 -07:00
Cory Bennett 986cc78ed5 [#115] fix transition template for description 2017-09-26 22:49:40 -07:00
Cory Bennett 3913726991 update edit command to set queryFields on search to match what is used in template 2017-09-19 00:27:11 -07:00
Cory Bennett 0ba8aa035b fix edit with query loop, allow continuation when not submitting previous issue 2017-09-18 14:45:21 -07:00
Cory Bennett 098eb99ed6 fix edit when priority is not set 2017-09-18 14:45:04 -07:00
Cory Bennett 2ddaed2c29 flatten CommandRegistry list to make it more readable 2017-09-18 14:44:36 -07:00
Cory Bennett 9a62d1a553 tweak format 2017-09-18 00:53:57 -07:00
Cory Bennett 74d7287589 fix formatting 2017-09-18 00:50:49 -07:00
Cory Bennett c6e4b3dc0e add TOC 2017-09-18 00:49:34 -07:00
Cory Bennett 8b5e7b7568 fix usage 2017-09-18 00:47:35 -07:00
Cory Bennett 4dea068113 version bump 2017-09-18 00:44:55 -07:00
Cory Bennett 28e4554fe3 Updated Changelog 2017-09-18 00:44:55 -07:00
Cory Bennett 065f9c8d77 Updated Usage 2017-09-18 00:44:55 -07:00
Cory Bennett 9f433acaa0 clean up usage formatting, print aliases 2017-09-18 00:44:08 -07:00
Cory Bennett e4c10be811 add jira edit tests 2017-09-17 20:33:40 -07:00
Cory Bennett 4c6b36c83a fix edit 2017-09-17 20:32:50 -07:00
Cory Bennett a8eaa97de1 fix named query template expansion 2017-09-17 20:31:14 -07:00
Cory Bennett cd3cfd820f fix usage message 2017-09-17 20:30:44 -07:00
Cory Bennett a04c3a4c61 add test using named query 2017-09-17 18:11:57 -07:00
Cory Bennett bb66e58dfd use svg rather than png for godoc badge 2017-09-17 16:36:22 -07:00
Cory Bennett e21f18e987 Updated Changelog 2017-09-17 16:30:41 -07:00
Cory Bennett 96bbbd7ce3 fix table tests for issuetype addition 2017-09-17 16:15:28 -07:00
Cory Bennett 3e8b9bd9f5 need issuetype to use the default list table template now 2017-09-17 16:15:00 -07:00
Cory Bennett 8fe0d98d54 version bump 2017-09-17 15:53:46 -07:00
Cory Bennett 1a3eaf340c Updated Changelog 2017-09-17 15:53:46 -07:00
Cory Bennett 96b4658dcb fix logic for detecting changes in README.md 2017-09-17 15:53:30 -07:00
Cory Bennett c9d8dfbe55 [#102] add issuetype into the default queryfields and add it to the default table list template 2017-09-17 15:49:05 -07:00
Cory Bennett 238e16fc09 version bump 2017-09-17 15:38:25 -07:00
Cory Bennett 22a354ce42 Updated Changelog 2017-09-17 15:38:24 -07:00
Cory Bennett d9736919bb Updated Usage 2017-09-17 15:38:24 -07:00
Cory Bennett 3c16e1754a fix whitespace, --help-long always returns non-zero exit 2017-09-17 15:38:16 -07:00
Cory Bennett 650bc4b50d fix whitespace 2017-09-17 15:33:10 -07:00
Cory Bennett b1c9bf5ae5 automatically update usage in README.md 2017-09-17 15:32:24 -07:00
Cory Bennett 66eb7bff38 [#100] add support for posting, fetching, listing and removing attachments 2017-09-17 15:18:06 -07:00
Cory Bennett abc82b909e version bump 2017-09-15 00:33:12 -07:00
Cory Bennett dabf4cf034 Updated Changelog 2017-09-15 00:33:12 -07:00
Cory Bennett 79a6381307 update usage 2017-09-15 00:31:43 -07:00
Cory Bennett 893454fc69 [#87] add various commands for interacting with epics 2017-09-15 00:28:56 -07:00
Cory Bennett d5b9631cf4 make test less error prone 2017-09-13 13:38:55 -07:00
Cory Bennett e841270b83 version bump 2017-09-13 12:31:16 -07:00
Cory Bennett 2ededeeaf7 Updated Changelog 2017-09-13 12:31:16 -07:00
Cory Bennett 00cba793ad tweaks for templates in named queries to work better 2017-09-13 12:17:59 -07:00
Cory Bennett fb43753c31 [#99] add support for named queries to be stored in configs 2017-09-13 11:12:58 -07:00
Cory Bennett 5085a14494 add license badge 2017-09-13 00:15:09 -07:00
Cory Bennett 5da04c1f86 [#98] add --status option for JQL filter on status with list command 2017-09-13 00:12:20 -07:00
Cory Bennett 052e038d73 version bump 2017-09-11 00:16:10 -07:00
Cory Bennett a7f1323f34 Updated Changelog 2017-09-11 00:16:10 -07:00
Cory Bennett 8d27b736ca track *.lock 2017-09-11 00:16:01 -07:00
Cory Bennett c3c008e53d running dep prune 2017-09-11 00:11:56 -07:00
Cory Bennett 608e586d1c use --gjq for GJson Query to filter json response data, remove --jq option 2017-09-10 22:48:40 -07:00
Cory Bennett 2c552ac530 fix field tag syntax 2017-09-09 19:13:58 -07:00
Cory Bennett 1d269183c3 add --jq option to run a json query against Jira service response json 2017-09-09 19:02:23 -07:00
Cory Bennett e0e1e5b941 use {{jira}} in custom-command docs 2017-09-09 17:44:56 -07:00
Cory Bennett 941824d7f8 add '{{jira}}' template macro to refer to path of currently running jira command 2017-09-09 17:40:26 -07:00
Cory Bennett c585244f3e add basic tests for custom-commands 2017-09-09 17:20:57 -07:00
Cory Bennett 29b95a52cb version bump 2017-09-08 18:54:34 -07:00
Cory Bennett f556375242 Updated Changelog 2017-09-08 18:54:34 -07:00
Cory Bennett 86b963bdb5 update deps for kingpeon update
use os.exec instead of syscall.exec for windows
2017-09-08 18:53:21 -07:00
Cory Bennett 036ebb4bf7 make custom-commands example copy/pasteable 2017-09-07 08:39:37 -07:00
Cory Bennett 7d481fe965 version bump 2017-09-06 23:23:47 -07:00
Cory Bennett 4709bbbe38 Updated Changelog 2017-09-06 23:23:47 -07:00
Cory Bennett 1c79a80389 add COLUMNS back in for jira ls --template table testing 2017-09-06 23:07:48 -07:00
Cory Bennett 6a879959be fix perms for test .gnupg directory 2017-09-06 22:34:15 -07:00
Cory Bennett d46f9495e7 assume tests always run in jira cloud 2017-09-06 22:30:59 -07:00
Cory Bennett e6faee1573 [#66] add --started option to jira worklog add to change the start time for worklog 2017-09-06 22:30:15 -07:00
Cory Bennett c4be59cae3 [#45] automatically add comment to issue even if transition does not support comment updates during transtion 2017-09-06 21:28:57 -07:00
Cory Bennett 9cc91f7108 use xgo tool rather than docker image directly 2017-09-06 12:29:06 -07:00
Cory Bennett da8ee59ebb version bump 2017-09-06 12:07:51 -07:00
Cory Bennett 4386b9c541 Updated Changelog 2017-09-06 12:06:37 -07:00
Cory Bennett aa876cd588 update dependencies 2017-09-06 11:35:00 -07:00
Cory Bennett 9453179251 update for github.com/AlecAivazis/survey => gopkg.in/AlecAivazis/survey.v1 package 2017-09-06 08:40:34 -07:00
Cory Bennett 4d79af4f5e use stdout to determin output terminal size 2017-09-06 00:33:53 -07:00
Cory Bennett 2cb6bbb10d Updated Changelog 2017-09-06 00:06:31 -07:00
Cory Bennett 1106558703 [#13] change default input syntax to not require escaping for special characters 2017-09-06 00:04:54 -07:00
Cory Bennett 6e027657c2 Updated Changelog 2017-09-05 23:47:40 -07:00
Cory Bennett d87ca7a55d remove cruft 2017-09-05 23:46:30 -07:00
Cory Bennett 1b854da23b fix build for windows 2017-09-05 23:45:29 -07:00
Cory Bennett 6719e926f0 Merge branch 'v1' 2017-09-05 23:26:01 -07:00
Cory Bennett 41e0adcf27 formatting 2017-09-05 23:03:34 -07:00
Cory Bennett d9fe99041d mention golang import 2017-09-05 23:01:37 -07:00
Cory Bennett f1b8c64e33 change the default log output format 2017-09-05 22:58:30 -07:00
Cory Bennett 808e370297 update docs 2017-09-05 16:59:03 -07:00
Cory Bennett 49fbc4fd81 update for peon change 2017-09-05 16:07:50 -07:00
Cory Bennett 49f6cdc54e tweak auto-login so it does not print the standard jira login command output 2017-09-04 19:09:38 -07:00
Cory Bennett c226077320 add --quiet global option 2017-09-04 18:12:32 -07:00
Cory Bennett c0358eb67c refactor to allow for --insecure and --unixproxy arguments 2017-09-04 17:53:01 -07:00
Cory Bennett 21920c5888 handle html response on expired cookies (require X-Ausername header to always be present) 2017-09-03 23:28:17 -07:00
Cory Bennett 7ab6c22751 allow login prompt to be interrupted 2017-09-03 18:57:08 -07:00
Cory Bennett bccf09f83a fmt -> log typo 2017-09-03 01:02:16 -07:00
Cory Bennett e72479ca2a make ~/.jira.d directory if not already present 2017-09-03 00:58:56 -07:00
Cory Bennett e5dd3a7acf use go 1.8 2017-09-03 00:54:50 -07:00
Cory Bennett e04b506c58 fix go vet 2017-09-03 00:52:11 -07:00
Cory Bennett ba35f55a48 fix tests 2017-09-03 00:40:43 -07:00
Cory Bennett dc021818bb add OK printf 2017-09-03 00:40:08 -07:00
Cory Bennett b120c0ba10 change --method to use -M for backwards compat 2017-09-03 00:39:28 -07:00
Cory Bennett 2638396606 add resolution to dup'd issues when necessary 2017-09-03 00:38:37 -07:00
Cory Bennett ad1a62a88d call correct function for labels remove|set commands 2017-09-02 19:54:18 -07:00
Cory Bennett 4b60313d32 data argument is optional (for GET and DELETE requests) 2017-09-02 19:53:51 -07:00
Cory Bennett 84119a2111 fix usage, overrides not serialized correctly 2017-09-02 19:53:25 -07:00
Cory Bennett fa4ac258d0 fix jira ISSUE-123 command line parsing 2017-09-02 18:04:53 -07:00
Cory Bennett aed952b59e add logger object to jiracmd 2017-09-02 14:09:49 -07:00
Cory Bennett 979da1f3a5 refactor for GlobalOptions and CommonOptions 2017-09-02 14:05:27 -07:00
Cory Bennett 65891e7b3b update for testing 2017-09-02 14:04:49 -07:00
Cory Bennett 0a5510b231 move commands from jiracli package to jiracmd package 2017-09-02 09:14:54 -07:00
Cory Bennett de1460ddc9 use cliError for all cli errors 2017-09-01 23:32:40 -07:00
Cory Bennett fb1bfeb8f5 use jiracli.Error object to disambiguate between kingpin errors and cli errors 2017-09-01 23:30:59 -07:00
Cory Bennett fce78dea68 use correct variables 2017-09-01 23:29:54 -07:00
Cory Bennett f54e619194 fix OK output 2017-09-01 23:29:47 -07:00
Cory Bennett f38a0b888a udpate oreo for request replays 2017-08-31 22:58:55 -07:00
Cory Bennett 560998253d fix bogus logic error 2017-08-31 22:58:26 -07:00
Cory Bennett 36c26c523a fix stray newline for list table template 2017-08-31 22:57:57 -07:00
Cory Bennett 0f12ba6ba5 add --saveFile for create 2017-08-31 22:57:31 -07:00
Cory Bennett af45280d9e remove accidentally commited binary 2017-08-31 16:15:21 -07:00
Cory Bennett 3942f6f5d6 fix dynamic table output when not on tty 2017-08-31 16:00:45 -07:00
Cory Bennett da9a2b2b90 when using --verbose set the JIRA_DEBUG environment variable so custom-commands can auto enable verbose output 2017-08-31 15:09:32 -07:00
Cory Bennett ec0858b09e make jira ISSUE-123 usage call jira view ISSUE-123 2017-08-31 15:09:01 -07:00
Cory Bennett 301a61f2f1 integrate kingpeon library to allow for custom commands via configuration 2017-08-31 15:08:24 -07:00
Cory Bennett b4d7845105 skip editing by default for the transition alias commands (ie done, progress, etc) 2017-08-31 15:04:58 -07:00
Cory Bennett 2a081dd767 use terminal width to adjust list table output 2017-08-30 18:31:49 -07:00
Cory Bennett f52d2c472a set yaml/json tags for option structs 2017-08-27 20:46:25 -07:00
Cory Bennett c89f11d5b5 update generated data files 2017-08-27 19:41:49 -07:00
Cory Bennett 21add544dc automatically login when anonymous user detected 2017-08-27 13:55:48 -07:00
Cory Bennett 1f345cedee refactor trivial objects in favor of arguments to static functions 2017-08-27 00:47:11 -07:00
Cory Bennett b68c44384f merge in edit template changes from v1 branch #105 2017-08-25 22:07:56 -07:00
Cory Bennett 5716a7cb59 set JIRA_OPERATION when parsing configs. Use figtree config types for options to make defaulting work 2017-08-24 16:57:21 -07:00
Cory Bennett 5d6170a81a add --browse option to more commands 2017-08-24 12:39:11 -07:00
Cory Bennett 89e3306254 set defaults in structs rather than kingpin so they can be overriden by configs 2017-08-24 10:59:58 -07:00
Cory Bennett b235dcc384 add better handing for usage error 2017-08-21 22:54:34 -05:00
Cory Bennett 56b1c9df04 adding request command, removing dead code 2017-08-21 09:33:57 -05:00
Cory Bennett a1c28495a7 adding Do required for request language 2017-08-21 09:33:07 -05:00
Cory Bennett a91b9d56b0 add browse command and implement -b option for most operations 2017-08-20 23:19:43 -05:00
Cory Bennett f32cc7079c fix IssueAssign 2017-08-20 23:08:45 -05:00
Cory Bennett 19d8686c01 merge in update for upstream changes #104 2017-08-20 22:51:32 -05:00
coryb 000b82fa19 Merge pull request #104 from wrouesnel/keyring-update
Handle keyring.ErrNotFound error instead of panicing.
2017-08-20 20:49:58 -07:00
Will Rouesnel 07854d6be5 Handle keyring.ErrNotFound error instead of panicing.
github.com/tmc/keyring returns keyring.ErrNotFound instead of a blank password
in newer libraries. Handle this case properly by nulling the error, to give the
user a chance to set a new password.
2017-08-21 13:24:10 +10:00
Cory Bennett abaad5611d add export-templates command 2017-08-20 22:12:55 -05:00
Cory Bennett da39323adf add issuetypes command 2017-08-19 23:55:38 -05:00
Cory Bennett 0bd3ca2fab add components command 2017-08-19 23:39:04 -05:00
Cory Bennett cc90610e72 add component add command 2017-08-19 22:57:41 -05:00
Cory Bennett 959524af23 add take, unassign and assign|give commands 2017-08-19 16:02:29 -07:00
Cory Bennett 916186161a adding labels [add|set|remove] commands 2017-08-19 15:09:47 -07:00
Cory Bennett 47a5ce25bc add issue to cmd options 2017-08-19 15:09:01 -07:00
Cory Bennett f0b08c5869 add comment command 2017-08-19 15:08:34 -07:00
Cory Bennett ec0ac3c4b8 add watch command 2017-08-14 08:59:59 -07:00
Cory Bennett 8b863d297b add rank ISSUE after|before ISSUE command 2017-08-13 23:54:22 -07:00
Cory Bennett a08c92f3aa add vote command 2017-08-13 23:08:40 -07:00
Cory Bennett 37f81a4631 add issuelinktypes command 2017-08-13 22:38:22 -07:00
Cory Bennett aacc9f44e4 add issuelink command 2017-08-13 22:37:56 -07:00
Cory Bennett fc696c3323 fix closing duplicate issue on dup command 2017-08-13 21:10:23 -07:00
Cory Bennett 36632a52f0 rewrite checkpoint 2017-08-13 18:23:38 -07:00
coryb b00021ccbd Merge pull request #90 from bbaugher/master
Use name field for fix version name value. Fixes #89
2017-07-11 14:08:15 -07:00
Bryan Baugher 2f8fecbbfe Use name field for fix version name value. Fixes #89 2017-07-11 16:03:39 -05:00
Cory Bennett 37b138376b Updated Changelog 2017-05-10 09:05:30 -07:00
Cory Bennett 8a5e588ce2 fix unsafe casting for --quiet flag 2017-05-10 09:03:47 -07:00
Cory Bennett 67c86e4858 [#80] add jira unassign and jira give ISSUE --default commands 2017-05-10 08:58:53 -07:00
Cory Bennett 445f8f1f84 Updated Changelog 2017-04-24 11:06:39 -07:00
Cory Bennett 485f73181c revert update 2017-04-24 11:06:31 -07:00
Cory Bennett 4d321ec202 work around github.com/tmc/keyring compile error for windows 2017-04-24 10:50:30 -07:00
Cory Bennett d7bce222b6 Updated Changelog 2017-04-24 10:30:33 -07:00
coryb f231f55d74 Merge pull request #78 from davidreuss/generic-issuelink
Added generic issuelink command
2017-04-24 09:10:31 -07:00
coryb 28242c9c7e Merge pull request #77 from davidreuss/fix-start-parameter-for-pagination
Added --start parameter for pagination on results
2017-04-24 09:07:05 -07:00
David Reuss 05951f1c0d Added generic issuelink command
This allows adding generic links, and could replace 'blocks', and 'dups'
command, since it's pretty much just a copy/paste job.

Usage will be something like:

$ jira issuelink $INWARDISSUE "Relates" OUTWARDISSUE

Pulling the list of the names, for your issuelinktypes

$ jira issuelinktypes | jq '.issueLinkTypes | map(.name)'
[
  "Blocks",
  "Bonfire testing",
  "Clones",
  "Deprecates",
  "Duplicate",
  "Relates",
  "Risks"
]
2017-04-24 12:45:24 +02:00
David Reuss f47563048b Added --start parameter for pagination on results 2017-04-24 11:33:17 +02:00
Cory Bennett cd9976ae4e Updated Changelog 2017-03-22 22:25:25 -07:00
coryb f3aa2f4c1a Merge pull request #74 from clausb/BrowseOnWindows
Implement "browse" subcommand on Windows
2017-03-22 22:24:50 -07:00
Claus Brod f6230ca8c6 Implement "browse" subcommand on Windows 2017-03-22 22:36:21 +01:00
Cory Bennett 412174f8a9 Updated Changelog 2017-02-26 22:58:28 -08:00
Cory Bennett 52085417e6 [#69] add subtask command 2017-02-26 22:38:47 -08:00
Cory Bennett 7a2490c0e6 Updated Changelog 2017-02-08 08:45:42 -08:00
Cory Bennett 437532ae89 minor tweak to 'all' target 2017-02-08 08:45:09 -08:00
coryb 69b565eeaa Merge pull request #65 from mlbright/patch-1
Update README.md
2017-01-24 22:26:17 -08:00
Martin-Louis Bright cc393a3498 Update README.md 2017-01-24 21:35:20 -05:00
coryb c6ba4c681b Merge pull request #64 from astrostl/patch-2
Noting implied usage for the keyring provider
2017-01-05 14:55:15 -08:00
Cory Bennett 63bc2ae15a Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira 2017-01-05 14:54:09 -08:00
Cory Bennett 7d6a5d143d fix random sort ordering in "watchers" response 2017-01-05 14:53:44 -08:00
Justin Honold 0ca0f09aa8 Noting implied usage for the keyring provider 2017-01-05 15:06:25 -06:00
coryb 75242a5204 Merge pull request #62 from astrostl/patch-1
Doc tweak: add info for setting username
2017-01-05 12:55:39 -08:00
Justin Honold e6faa4eab1 Doc tweak: add info for setting username
Couple sentences of cleanup
2017-01-05 14:41:08 -06:00
Cory Bennett 9b53a617a7 update .bashrc for GPG 2016-12-21 17:46:22 -08:00
Cory Bennett d5eed3a635 set GPG_TTY in .bashrc 2016-12-19 16:07:33 -08:00
Cory Bennett 4017339b56 fix typos 2016-12-18 22:41:13 -08:00
Cory Bennett a40b17deed update docs for authentication 2016-12-18 22:04:25 -08:00
Cory Bennett 33807cbbec run full test suite now 2016-12-18 15:56:53 -08:00
Cory Bennett 989c072b94 force password in case password already exists 2016-12-18 15:53:00 -08:00
Cory Bennett d187eee826 fix gpg file permissions after checkout 2016-12-18 15:43:55 -08:00
Cory Bennett 6d34ef3f28 debugging travis 2016-12-18 15:37:23 -08:00
Cory Bennett 7852883202 tweak how prove is run 2016-12-18 15:15:46 -08:00
Cory Bennett cb70941aad refactor password source, allow for "pass" to be used, update tests to use password-source: pass 2016-12-18 15:07:17 -08:00
Cory Bennett 24fd8f6fad update changelog 2016-12-18 09:49:20 -08:00
Cory Bennett ba08d51437 Updated Changelog 2016-12-18 09:48:21 -08:00
Cory Bennett 09d718b5d8 stabbing in the dark 2016-12-17 19:57:45 -08:00
Cory Bennett e3e84d7aa0 only test jira cloud service 2016-12-17 18:52:07 -08:00
Cory Bennett a4f1d754e4 debugging tests 2016-12-17 18:50:20 -08:00
Cory Bennett 683541de1e add verbose test 2016-12-17 18:40:21 -08:00
Cory Bennett e0fd6bab66 only warn about needing login when not already running the login command 2016-12-17 18:32:47 -08:00
Cory Bennett 5ca096ab6e use go-jira.atlassian.net for testing via travis 2016-12-17 17:25:11 -08:00
Cory Bennett ac515e2743 Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira 2016-12-17 14:13:39 -08:00
Cory Bennett be4a5f9156 update for isolated xgo build 2016-12-17 14:13:00 -08:00
coryb 7f10eaa667 Merge pull request #61 from sylus/feature-proxy
fix(http): Add proxy transport
2016-12-17 14:06:45 -08:00
William Hearn b326623ed2 fix(http): Add proxy transport 2016-12-17 16:50:34 -05:00
William Hearn 72c78c6c1c fix(http): Add proxy transport 2016-12-17 14:13:20 -05:00
coryb 5df5a39405 Merge pull request #60 from facundoolano/patch-1
fix typo in readme
2016-12-15 14:00:31 -08:00
Facundo Olano bd54ecc4f6 fix typo in readme 2016-12-15 15:18:11 -03:00
Cory Bennett 073e0bdcce Updated Changelog 2016-11-24 00:11:53 -08:00
Cory Bennett 1347ebe6b6 [#12] integrate with keyring for password storage and provide http basic auth
credentials for every request since most jira services have websudo enabled with
does not allow cookie based authentication
2016-11-23 23:43:29 -08:00
coryb c7565b08a1 Merge pull request #53 from jshirley/master
Add support for a unix socket proxy
2016-09-22 19:14:07 -07:00
Jay Shirley 01067e859c Cleaning up usage 2016-09-22 18:54:52 -07:00
Jay Shirley 8b174625d9 Update usage 2016-09-20 06:46:04 -07:00
Cory Bennett 8acc177627 use gopkg.in for links to maintain version compatibility 2016-09-18 12:44:00 -07:00
Cory Bennett 8d9db0e399 remove extraneous tee 2016-08-29 01:00:35 -07:00
Cory Bennett 998e4601c0 reduce mega verbosity 2016-08-29 01:00:01 -07:00
Cory Bennett 2df70edd00 up plan count for the sleep 2016-08-29 00:58:23 -07:00
Cory Bennett f73b3a5dc8 add missing src directory 2016-08-29 00:49:10 -07:00
Cory Bennett e74c94b030 move start.log to directory 2016-08-29 00:23:05 -07:00
Cory Bennett c18d2140e4 try travis cache and log atlas-run start output 2016-08-29 00:19:27 -07:00
Cory Bennett 2b56833c1c break setup to debug in travis 2016-08-29 00:04:21 -07:00
Cory Bennett fe69ad1cec wait for docker service to start? 2016-08-28 23:47:34 -07:00
Cory Bennett 3b18a1863c make maven cache directory local so we can ensure it is always there for travis testing 2016-08-28 23:36:37 -07:00
Cory Bennett d6d6578b11 make prove verbose 2016-08-28 23:32:03 -07:00
Cory Bennett 2b433dda40 golint 2016-08-28 23:30:25 -07:00
Cory Bennett 08a24e7dc3 require docker, run prove after build 2016-08-28 23:24:12 -07:00
Cory Bennett a746ddc6fb use altas-run to build jira test service in docker container 2016-08-28 23:10:54 -07:00
Cory Bennett e254435734 add "rank" command allow ordering backlog issues in agile projects 2016-08-26 19:44:38 -07:00
Jay Shirley 14298bfa52 Adding a unixproxy mechanism 2016-08-25 10:27:59 -07:00
Cory Bennett a3633aa537 Updated Changelog 2016-08-24 12:27:42 -07:00
coryb 2a8b6521dc Merge pull request #52 from dbrower/master
Prefer transition names which match exactly
2016-08-24 12:26:56 -07:00
Don Brower 4cc172de6b Prefer transition names which match exactly
Some transitions are substrings of other transitions, and the current
loop sometimes never chose the correct one. For example, it would never
choose "QA" if there were also a transtion "Deploy to QA". Ditto for
"Open" and "Reopen".
2016-08-24 14:36:23 -04:00
Cory Bennett 0dd6061992 update tempates to make them more readable with space trimming added to go-1.6 2016-08-21 23:51:45 -07:00
Cory Bennett 9d12f56332 add simple test for the "table" list output 2016-08-21 23:51:30 -07:00
Cory Bennett 824dd2f725 Updated Changelog 2016-08-21 14:39:54 -07:00
Cory Bennett 657bc59c8f make "worklogs" command print output through template
allow "add worklog" command to open edit template
2016-08-21 14:31:30 -07:00
Cory Bennett ec1914dfde remove extra newline at end of worklogs template 2016-08-21 14:31:11 -07:00
Cory Bennett a22911a3f9 adding worklog related templates 2016-08-21 14:27:50 -07:00
Cory Bennett 1f6191425f add vet and link make targets 2016-08-21 14:22:27 -07:00
Cory Bennett f896555299 Updated Changelog 2016-08-21 12:42:47 -07:00
Cory Bennett e0b2c2d240 add GoDoc badge 2016-08-21 10:24:07 -07:00
Cory Bennett a5cb93f112 add travis badge 2016-08-21 10:16:06 -07:00
Cory Bennett cbbf335439 add travis build 2016-08-21 00:46:03 -07:00
Cory Bennett 92b5e38912 update for golint 2016-08-21 00:45:07 -07:00
Cory Bennett 6260e4964f fix for go vet 2016-08-19 10:19:04 -07:00
Cory Bennett 485d65f12b [#51] add missing data directory with generated structs 2016-08-19 08:52:42 -07:00
Cory Bennett 1f33400288 Updated Changelog 2016-08-12 13:32:13 -07:00
Cory Bennett 37332354b7 ignore t/.jira.d/templates which are exported in 000setup.t 2016-08-12 13:31:16 -07:00
Cory Bennett 7530b309e2 add tests for "Task Management" type projects 2016-08-12 13:30:24 -07:00
Cory Bennett e93bf71fea add tests for "Process Management" type projects 2016-08-12 13:29:56 -07:00
Cory Bennett d022f0ad70 add tests for "Project Management" type projects 2016-08-12 13:29:01 -07:00
Cory Bennett 4d5076230c when running "dups" on a Process Management Project type, you have to start/stop the task to resolve it 2016-08-12 13:27:51 -07:00
Cory Bennett 3cbd2f85a4 allow for defaultResolution option for transition command 2016-08-12 12:13:37 -07:00
Cory Bennett 970876851b add tests for Kanban Software Project type issues 2016-08-10 10:52:45 -07:00
Cory Bennett f74c45d7d7 add tests for Scrum Software Project type issues 2016-08-10 10:52:17 -07:00
Cory Bennett 4e7e52288d add test for Basic Software Project type issues 2016-08-10 10:51:55 -07:00
Cory Bennett 63f41e5e88 add comments 2016-08-10 10:50:04 -07:00
Cory Bennett dbf6a5a265 add extra "mojira" user for testing voting and ownership reassignment 2016-08-10 10:49:11 -07:00
Cory Bennett b2056be287 add "backlog" command for Kanban related Issues 2016-08-10 10:48:02 -07:00
Cory Bennett 6beb941d82 fix --noedit flag with "dups" command 2016-08-09 23:51:04 -07:00
Cory Bennett b297d5a4ef add "votes" and "labels" to default view template 2016-08-09 23:48:28 -07:00
Cory Bennett bf7f38de87 gofmt 2016-08-09 23:16:41 -07:00
Cory Bennett f7ed1ed8d8 gofmt 2016-08-09 23:16:20 -07:00
Cory Bennett 280c0f24b3 add "blockerType" config param, for issueLinkType use for "blocks" command 2016-08-09 23:09:31 -07:00
Cory Bennett 6e296052f5 add "debug" make target 2016-08-09 23:06:46 -07:00
Cory Bennett 189b0d252c update gitter room 2016-08-08 00:10:04 -07:00
Cory Bennett 0e453a45d3 fix typo 2016-08-05 13:11:31 -07:00
Cory Bennett 179596ff12 add gitter badge 2016-08-05 13:09:17 -07:00
Cory Bennett 50bac02419 make the bootstrapping simpler, move more setup to 000setup.t 2016-08-04 11:11:03 -07:00
Cory Bennett 4b7e24a199 fix links 2016-08-03 09:58:00 -07:00
Cory Bennett b9bf8455bd mention osht for testing 2016-08-03 09:56:54 -07:00
Cory Bennett 9111231545 start adding some basic integration tests 2016-08-03 00:13:53 -07:00
Cory Bennett 986528d4ea default issuetype to "Bug" for project that have Bug, otherwise try "Task" 2016-08-03 00:09:09 -07:00
Cory Bennett 9c1f028be2 make view template only show fields that have values 2016-08-02 23:16:08 -07:00
Cory Bennett e3c5051e5e make default create template only display fields if they are valid fields for the project 2016-08-02 22:44:24 -07:00
Cory Bennett 580ea50b37 ignore empty json fields when processing templates 2016-08-02 22:36:51 -07:00
Cory Bennett be31acde65 allow JIRA_LOG_FORMAT env variable to control log output format 2016-08-02 20:12:30 -07:00
Cory Bennett a2f8b7ef65 remove extraneous debug 2016-08-02 20:06:40 -07:00
Cory Bennett c28d46fe8f add logout command
modify password prompt to echo masked password
2016-08-02 20:04:11 -07:00
Cory Bennett 108a5b4976 tweak cookies to store hostname
dump all http request/response with --verbose
2016-08-02 19:23:24 -07:00
Cory Bennett e3d11357e1 load configs in order of closest to cwd (/etc/go-jira.yml is last) 2016-08-02 19:20:23 -07:00
Cory Bennett dfb10740f5 [#48] fix quoting for "make install" so it actually installs to homedir 2016-08-01 11:31:06 -07:00
Cory Bennett adc08935b4 Updated Changelog 2016-07-30 20:13:00 -07:00
Cory Bennett 073c8a3694 [#43] add support for jira done|todo|prog commands 2016-07-30 20:05:13 -07:00
Cory Bennett c4a31a498e [issue #46] add documentation for how to create/edit templates 2016-07-08 12:12:02 -07:00
coryb bcad37089a Merge pull request #24 from mikepea/edit_template_common
Reporter is not generally editable.
2016-06-30 08:53:34 -07:00
Cory Bennett b2ba8de15d Updated Changelog 2016-06-29 23:11:04 -07:00
Cory Bennett 6016bda571 [#44] Close tmpfile before rename to work around "The process cannot access the file because it is being used by another process" error on windows. 2016-06-29 23:09:27 -07:00
Cory Bennett 34ca09cf1a trim out unused platforms, we can add then back in on request
publish windows binaries as .exe
2016-06-29 23:08:54 -07:00
Cory Bennett d7fb88ee41 fix for versions with 'v' prefix 2016-06-28 23:07:06 -07:00
Cory Bennett de4fe76fec fix v in version prefix 2016-06-28 23:02:03 -07:00
Cory Bennett 5b870cb7a2 Updated Changelog 2016-06-28 23:00:49 -07:00
Cory Bennett 89bb82b3f2 use USERPROFILE instead of HOME for windows, rework paths to use
filepath.Join for better cross platform support
2016-06-29 06:57:59 +01:00
Cory Bennett dd0f5efd32 Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira 2016-06-29 01:40:21 +01:00
Cory Bennett 68b5e60dd9 make binary name .exe for windows 2016-06-29 01:26:28 +01:00
Cory Bennett 71acc5d7fc update Makefile so it builds under cygwin on windows 2016-06-27 15:51:21 -07:00
Cory Bennett 4f91cecf25 fix build under Cygwin on Windows 2016-06-27 15:46:14 -07:00
coryb 688b987895 Merge pull request #39 from mikepea/system_template_dir
Include templates from a system path
2016-03-30 14:47:17 -07:00
Mike Pountney 71bb04fabb Include templates from a system path
I've found that several of the built-in templates need a bit of work
to be useful with our JIRA installation (eg #24), so this allows for admins
to make a site-specific set of defaults easily.
2016-03-30 20:20:55 +01:00
coryb 3a9f763f9d Merge pull request #38 from jglick/patch-1
Noting jira login
2016-03-30 08:48:21 -07:00
Jesse Glick d86d85f7b2 Noting jira login 2016-03-30 09:39:49 -04:00
coryb 4b798cbfb4 Merge pull request #37 from tobyjoe/add-resource-expansion
Added support for the ```expand``` option for Issues
2016-02-22 09:04:54 -08:00
tobyjoe 598924b51d Added support for the ``expand`` option for Issues
The ```expand``` option is used to specify resource expansion in the
Jira REST API.

It's particularly useful for things like fetching the ```changelog``` of
an Issue.

This PR adds the support to the ```ListIssues``` and ```ViewIssue```
functions of the ```jira.Cli``` struct.

I'm happy to add tests, but there is currently no test suite in the
master branch, so I did not want to bog down the PR with tangential features.
2016-02-22 08:46:08 -05:00
Cory Bennett 674957af5d change for api changes to go-logging 2016-02-11 15:11:06 -08:00
coryb c568d7e921 fix #36, build instructions needed updating 2016-02-10 17:03:27 -08:00
coryb 6eb3567ca5 Merge pull request #35 from QuinnyPig/fix-readme
Fix path for installation instructions
2016-02-02 12:06:48 -08:00
Corey Quinn 87ec73c5c3 Fix path for command 2016-02-02 11:19:54 -08:00
coryb 23551abb11 Merge pull request #34 from jonathanio/fix/issuetypes-url-escaping
Fix issuetype calls adding URL escaping
2016-02-01 08:46:21 -08:00
Jonathan Wright 693e1441f7 Fix issuetype calls adding URL escaping
It is valid within JIRA to have issue types with spaces (for example we use
"Pro-Active Task") however the issuetype variable is not escaped prior to
formatting into the uri string.

This fix imports "net/url" and escapes all inclusions of issuetype into uri.
The only other variables formatted into uri are c.endpoint and issue which
shouldn't contain special characters.
2016-02-01 11:10:30 +00:00
Cory Bennett 6e5cc9821e Updated Changelog 2016-01-29 09:04:49 -08:00
Cory Bennett 9e90376816 Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira 2016-01-29 09:02:39 -08:00
coryb 20b32c2ed6 Merge pull request #33 from mikepea/make_jirad
Fixes #32 - make path to cookieFile if it's not present
2016-01-29 09:01:29 -08:00
Mike Pountney ac170e9ab1 Fixes #32 - make path to cookieFile if it's not present
TL;DR, this ensures ~/jira.d is present, with 0755 perms.

If ~/jira.d isn't present, we can't write to the cookieFile, which
breaks CmdLogin. This is particularly an issue when using /etc/go-jira.yml
to get an entire team using go-jira easily :)

This fixes this by ensuring the cookieFile dir is present before
writing to it.
2016-01-29 11:12:25 +00:00
coryb d8bce08d3a Merge pull request #31 from mikepea/component_mgmt
Add component/components support: add and list for now.
2016-01-28 16:46:06 -08:00
Cory Bennett 382bf4faeb Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira 2016-01-28 16:42:08 -08:00
Mike Pountney 595a5212b4 Add component/components support: add and list for now.
This adds the basics of the component API:

* listing of components assigned to a project
* adding new components to a project.

The interface to 'add component' is similar to that of 'labels', as
previously discussed. We can implement remove/update later.
2016-01-29 00:22:26 +00:00
coryb f595801202 Merge pull request #30 from mikepea/unwatch_support
Support for removing a given watcher
2016-01-23 22:54:05 -08:00
coryb 404caf6400 Merge pull request #26 from mikepea/vote_support
Add 'vote' and 'unvote'
2016-01-23 22:52:31 -08:00
Mike Pountney f7eb04e36d Tweak the CmdWatch contract and add watcher remove support
This adjusts the CmdWatch interface as per discussion in
https://github.com/Netflix-Skunkworks/go-jira/pull/26

It also exposes public versions of the c.getOptString and c.getOptBool
utility functions, again as discussed.

The interface to CmdWatch now includes the user to be watched (rather than
depending on the opt[] map. This makes CmdWatch more useful externally.

A '--remove' option has been created, to allow for removal of a given watcher.
This was deliberately not included in the defaults map, as it is specifically only
used for 'watch' command right now. It should be moved up to a default if it becomes
a more common option, I guess (as 'remove is false' isn't a bad default)
2016-01-24 03:00:39 +00:00
Mike Pountney b0d4f7273d Amend vote/unvote to be vote/vote --down
This simplifies the interface to voting, as per the discussion in
https://github.com/Netflix-Skunkworks/go-jira/pull/26

Basically, DRY out the logic into a single CmdVote function based
around an 'up' bool. Similarly, make a single CLI command with an
option to do the downvote.
2016-01-24 02:23:08 +00:00
Mike Pountney a927181db1 Merge branch 'master' into vote_support 2016-01-23 18:06:16 +00:00
Cory Bennett b5417ef585 update version tag to prefix with v 2016-01-21 17:38:50 -08:00
Cory Bennett c5af781c41 Updated Changelog 2016-01-21 17:36:23 -08:00
Cory Bennett f2c4df9b3e [issue #28] check to make sure we got back issuetypes for create metadata 2016-01-21 17:35:18 -08:00
Cory Bennett 1dde7e06e6 gofmt 2016-01-21 10:52:15 -08:00
coryb 7bc1897792 Merge pull request #27 from blalor/insecure-skip-verify
Add insecure option for TLS endpoints
2016-01-21 10:15:29 -08:00
Brian Lalor 37aab3580b Add insecure option for TLS endpoints
This gives the option of disabling TLS certificate verification for
the server.

Closes #25
2016-01-21 12:30:23 -05:00
Mike Pountney ff56136937 Add 'vote' and 'unvote'
This adds support for voting on issues via CmdVote() and CmdUnvote()

Voting on issues is always done as the logged in user, it appears you
can't case a vote for another user:

https://docs.atlassian.com/jira/REST/latest/#api/2/issue-addVote

This required adding a cli.delete() handler, naturally with no content
(as per RFC2616)

This is ripe for DRY-ing out, but I will leave that for a future PR.

Worth noting is that you cannot vote for your own issues, this results in:

    2016-01-13T21:35:41.315Z ERROR [cli.go:184] response status: 404 Not Found
    2016-01-13T21:35:41.315Z ERROR [commands.go:439] Unexpected Response From POST:
    {snip}
    {"errorMessages":["You cannot vote for an issue you have reported."],"errors":{}}
2016-01-13 21:41:34 +00:00
coryb 42990d8ca0 Merge pull request #21 from mikepea/label_command
Add 'labels' command to set/add/remove labels
2016-01-04 08:50:15 -08:00
Mike Pountney e58625b00c Reporter is not generally editable.
Support the lowest common denominator for default_edit_template, as per #23

`reporter` is not usually editable by unprivileged users. Even if it is left as-is,
the PUT request is trying to update it, resulting in the following error:

    {"errorMessages":[],"errors":{"reporter":"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."}}

Commenting out the field leaves the information visible, so is a reasonable compromise.
2016-01-03 22:25:05 -08:00
Mike Pountney 8e662462da Correct naming of parameter: set/add/remove are actions.
'command' is not approprirate for the set/add/remove operations, and is
confusing. Rename to 'action' to remove this confusion.
2016-01-03 20:28:02 -08:00
Mike Pountney ad7bb2b724 Tweak CmdLabels args so that magic happens with CLI
The CLI looks for commands (like 'labels') in the first two positional args. This
is how commands like 'BLOCKER blocks ISSUE' work.

As per @coryb's comments in #21 - this allows us to support set/add/remove in a
consistent way for other types: components for example.

This commit rearranges the command to be as follows:

    jira (set/add/remove) labels ISSUE LABELS...

The options to CmdLabels have been reordered accordingly.
2016-01-03 20:10:49 -08:00
Mike Pountney a8cce44178 Merge branch 'master' into label_command 2016-01-03 19:50:47 -08:00
coryb 35955a7a93 Merge pull request #22 from mikepea/library_break_out
Expose key functionality for library consumption
2015-12-31 12:22:09 -08:00
Mike Pountney f349e25bb9 Expose ViewTicket as per FindIssues
This allows external users of the API to retreive issue details, in the same
manner that FindIssues provides for lists of issues.
2015-12-31 12:06:04 -08:00
Mike Pountney a92a93b282 Add exposed versions of getTemplate and runTemplate
GetTemplate and RunTemplate allow external users to access the template system,
and in particular allow them to provide their own Buffer to write the output to.

I've implemented exposed versions calling the private functions, rather than breaking
the internal API. If this isn't a concern, we should remove getTemplate and runTemplate
in a future commit.
2015-12-31 12:03:22 -08:00
Mike Pountney 8645ef11f1 go fmt 2015-12-31 11:52:55 -08:00
Mike Pountney e042a3e62a Add 'labels' command to set/add/remove labels
This adds 'labels' command, which allows for the setting, addition and removal
of labels on an issue.

'set' action resets the issue labels to the list provided.
'add' action adds the supplied labels to the issue
'remove' action removes the supplied labels from the issue

The API already gracefully handles duplication, removal of non-existant labels, and the
supplying of an empty list of labels (which is useful in the case of 'set')

Eg

jira labels TEST-123 add label1 label2 label3
jira labels TEST-123 remove label1 label2
jira labels TEST-123 set label1 label2 label3
jira labels TEST-123 set # clears any labels on the issue
jira labels TEST-123 add # no-op
jira labels TEST-123 remove # no-op

This mirrors the functionality of the API.
2015-12-24 11:30:52 -08:00
coryb a738d1515e Merge pull request #20 from mikepea/add_join_template_func
Add a 'join' func to the template engine
2015-12-23 12:05:34 -08:00
Mike Pountney d4f15ae5c6 Add a 'join' func to the template engine
I needed this so that I can display JIRA labels in my 'list' template.
2015-12-23 06:15:31 -08:00
Cory Bennett bc70b43868 make "jira" golang package, move code from jira/cli to root, move jira/main.go to main/main.go 2015-12-22 17:56:53 -08:00
Cory Bennett e24b431b7a Updated Changelog 2015-12-09 20:58:11 -08:00
Cory Bennett 101bc1da68 fix jira trans TRANS ISSUE (case sensitivity issue), also go fmt 2015-12-09 20:57:10 -08:00
Cory Bennett 63e035c5c1 Updated Changelog 2015-12-03 14:47:55 -08:00
Cory Bennett 40bafc9b66 need to default "quiet" to false 2015-12-03 14:47:31 -08:00
Cory Bennett 5d863ffed4 Updated Changelog 2015-12-03 12:56:18 -08:00
Cory Bennett 577394b0bd add --quiet command to not print the OK ..
add --saveFile option to print the issue/link to a file on create command
2015-12-03 12:55:14 -08:00
Cory Bennett c1a7e1bbdb fix overrides 2015-12-03 12:21:55 -08:00
Cory Bennett f904f3c089 add abstract request wrapper to allow you to access/process random apis
supported by Jira but not yet supported by go-jira
2015-12-03 11:35:51 -08:00
Cory Bennett e35e518368 Updated Changelog 2015-11-23 17:09:17 -08:00
Cory Bennett 159d142f37 jira edit should not require one arguemnt (allow for --query) 2015-11-23 17:08:40 -08:00
Cory Bennett df84d47552 fix CURVER in case of building from src tar.gz 2015-11-23 14:35:41 -08:00
Cory Bennett fa4ce5647d tweak build 2015-11-23 14:23:29 -08:00
Cory Bennett 713d300a57 Updated Changelog 2015-11-23 14:17:41 -08:00
Cory Bennett c8ae7fc685 [#17] print usage on missing arguments 2015-11-23 14:17:09 -08:00
Cory Bennett 80322b648e bump version 2015-11-17 12:30:11 -08:00
Cory Bennett f2076a0977 Updated Changelog 2015-11-17 12:30:11 -08:00
coryb 886adb5db2 Merge pull request #16 from oschrenk/fix-typo
s/enpoint/endpoint/g
2015-10-16 08:50:52 -07:00
Oliver Schrenk 3bdbdbdaff s/enpoint/endpoint/g 2015-10-16 11:12:25 +02:00
coryb 544b923fab Merge pull request #14 from mikepea/ls_with_updated
Add 'updated' to queryfields; dateFormat template command; bug fix.
2015-10-15 08:37:47 -07:00
Mike Pountney 13a69e6f44 Implement dateFormat template command
Wrapper around time.Format, so that we can make concise lists without
the whole JIRA ISO timestamp, eg:

{{ dateFormat "2006-01-02T15:04" .fields.updated }}
2015-10-15 12:43:03 +01:00
Mike Pountney fae9f94817 Add 'updated' field to default queryfields.
This is pretty essential if you want to get an idea of how stale a ticket is.
2015-10-15 12:35:07 +01:00
Mike Pountney 7d90672736 Fix export-templates option (typo) 2015-10-15 12:05:33 +01:00
Cory Bennett 20faa959aa when yaml element resolves to "\n" strip it out so we dont post it to jira 2015-10-06 11:54:05 -07:00
Cory Bennett aaff47d606 print PUT/POST data when using --dryrun to help debug 2015-10-06 11:50:47 -07:00
Cory Bennett 7bfb2946d4 bump version 2015-09-19 00:17:32 -07:00
Cory Bennett 9884281079 Updated Changelog 2015-09-19 00:17:32 -07:00
Cory Bennett 03fce96eb5 replace dead/deprecated code.google.com/p/gopass with golang.org/x/crypto/ssh/terminal for reading password from stdin 2015-09-19 00:17:08 -07:00
Cory Bennett 8f9e6f7d85 bump version 2015-09-18 23:26:16 -07:00
Cory Bennett 65c0240d34 Updated Changelog 2015-09-18 23:26:16 -07:00
Cory Bennett ccec749a0b fix exception from "jira create" 2015-09-18 23:24:50 -07:00
Cory Bennett 6a9901f171 add some debug messages to help diagnose login failures 2015-09-18 23:18:38 -07:00
Cory Bennett 868764ac86 bump version 2015-09-16 23:22:06 -07:00
Cory Bennett f1e7514a00 Updated Changelog 2015-09-16 23:22:06 -07:00
Cory Bennett 92d10c3498 update version when we create changelog entries 2015-09-16 23:21:36 -07:00
Cory Bennett a9c6b865b6 add --version 2015-09-16 23:16:51 -07:00
Cory Bennett 9cc55a13c1 Updated Changelog 2015-09-16 23:05:02 -07:00
Cory Bennett b116764d3e fix command line parser broken in 0.0.10 2015-09-16 23:04:36 -07:00
Cory Bennett a4aa52fb58 update changelog 2015-09-15 23:43:57 -07:00
Cory Bennett 582f37866f Updated Changelog 2015-09-15 23:41:20 -07:00
Cory Bennett ab7f194647 gofmt 2015-09-15 23:40:41 -07:00
Cory Bennett e8ba1d6053 update usage 2015-09-15 23:29:56 -07:00
Cory Bennett 4dc23487ba allow for command aliasing in conjunction with executable config files 2015-09-15 23:27:06 -07:00
Cory Bennett 8f44cc5de7 update usage 2015-09-15 22:55:19 -07:00
Cory Bennett a989198630 Updated Changelog 2015-09-15 20:34:19 -07:00
Cory Bennett 7f85842df3 * use forked yaml.v2 so as to not lose line terminations present in jira fields
* adding a |~ literal yaml syntax to just chomp a single newline (again to preserve
existing formatting in jira fields)
* for indent/comment allow for unicode line termination characters that yaml will use for parsing
2015-09-15 19:31:38 -07:00
Cory Bennett f1921454d6 fix "edit" default option, change how defaults are dealt with for filters 2015-09-14 12:31:53 -07:00
Cory Bennett d7f6638f2a for edit template add issue id as comment, also add "comments" as comment
so you can review the comment details while editing
2015-09-14 12:30:26 -07:00
Cory Bennett ae285b5a55 add "comment" template filter to comment out multiline statements 2015-09-14 12:29:30 -07:00
Cory Bennett 5d8dc9f9d8 add getOpt wrappers to get options with defaults 2015-09-14 12:29:05 -07:00
Cory Bennett ade9f5f1f5 make --dryrun work
refactor config/option loading so command options override settings in config files
allow query options to be used on the "edit" command to iterate editing
2015-09-14 00:14:13 -07:00
Cory Bennett a990fdf7bb move remove duplication for defaults 2015-09-13 17:31:28 -07:00
Cory Bennett 0f217cefb5 adding "clean" target 2015-09-13 17:13:55 -07:00
Cory Bennett 38b3e90198 use optigo for option parsing, drop docopt 2015-09-13 17:00:03 -07:00
Cory Bennett 80b6f5a198 allow "abort: true" to be set while editing to cancel the edit operation 2015-09-11 23:47:09 -07:00
Cory Bennett 794654dcd7 gofmt 2015-09-11 22:13:23 -07:00
Cory Bennett a36bf387fa tweak changelog generation 2015-09-11 22:13:12 -07:00
Cory Bennett b134e7c6f7 fix missing arg of Sprintf 2015-09-11 22:12:38 -07:00
Cory Bennett b8889c656d if no changes are made on edit templates then abort edit 2015-09-11 22:04:02 -07:00
Cory Bennett 8949c12354 updated for 0.0.8 2015-09-11 21:18:27 -07:00
Cory Bennett 880b45c90b bump version 2015-07-31 11:12:24 -07:00
Cory Bennett 6c508f9ce1 update for max_results option 2015-07-31 11:11:36 -07:00
coryb cf14b5af97 Merge pull request #11 from mikepea/max_results_option
Add --max_results option for 'ls'
2015-07-31 10:37:04 -07:00
Mike Pountney 43a2753451 Add --max_results option for 'ls'
This closes #10

Shifts the hardcoded maxResults value for the cmdList json body
into a 'max_results' option.

Note that testing against our JIRA instance, in a project with
more than 1000 open issues, suggests that the JIRA has an internal
limit of 1000 results in a single query.
2015-07-31 17:38:45 +01:00
Cory Bennett 66596f3aa5 update Changelog 2015-07-01 10:22:06 -07:00
Cory Bennett 3a68ccdd3f fix the "all" build 2015-07-01 10:20:48 -07:00
Cory Bennett 91c57d496c add cross-compile setup task 2015-07-01 09:13:03 -07:00
Cory Bennett 87ab7291e1 udpate version 2015-07-01 09:12:40 -07:00
Cory Bennett b72040bfd4 Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira 2015-07-01 08:50:40 -07:00
coryb 2dcc840a06 Merge pull request #9 from nelfin/quickfix/take-user
fix "take" command not honouring user option
2015-06-30 23:29:09 -07:00
Andrew Haigh 10c4aef671 fix "take" command not honouring user option
"take" was simply a partial on "assign", but accidentally used the value
of $USER from the environment rather than `opts["user"]`, preventing the
user from overriding this value in config.yml or as a command-line
argument.
2015-07-01 16:21:26 +10:00
Cory Bennett b5643e545b fix typo 2015-03-02 14:54:24 -08:00
Cory Bennett fc00743095 strip binaries when building "all" 2015-03-02 14:34:38 -08:00
Cory Bennett 6a3e2aa4d4 updating 2015-02-27 17:52:07 -08:00
Cory Bennett abc3953448 bump version 2015-02-27 17:50:08 -08:00
Cory Bennett 52eb7f4ed7 allow --sort= to disable sort override 2015-02-24 17:49:21 -08:00
Cory Bennett a5c7a133c0 fix default JIRA_OPERATION env variable 2015-02-24 17:48:59 -08:00
Cory Bennett f42d0b6366 automatically close duplicate issues with "Duplicate" resolution 2015-02-23 12:09:40 -08:00
Cory Bennett 8040746bcf set JIRA_OPERATION to "view" when no operation used (ie: jira GOJIRA-123) 2015-02-23 12:08:54 -08:00
Cory Bennett 90a8ee7c33 add --sort option to "list" command 2015-02-23 12:08:33 -08:00
227 changed files with 24493 additions and 1913 deletions
+60
View File
@@ -0,0 +1,60 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]
{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- [{{.Hash.Short}}]({{ $.Info.RepositoryURL }}/commit/{{ .Hash.Long }}): {{ .Subject }}
{{ if .Refs -}}{{ range .Refs }} -{{if .Action}}{{ .Action }} {{ end }} [#{{ .Ref }}]({{ $.Info.RepositoryURL }}/issues/{{ .Ref }}){{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- [{{.Hash.Short}}]({{ $.Info.RepositoryURL }}/commit/{{ .Hash.Long }}): {{ .Subject }}
{{ if .Refs -}}{{ range .Refs }} - {{if .Action}}{{ .Action }}{{ end }} [#{{ .Ref }}]({{ $.Info.RepositoryURL }}/issues/{{ .Ref }}){{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}
{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}
{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}
{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
{{ end -}}
+29
View File
@@ -0,0 +1,29 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/go-jira/go-jira
options:
commits:
sort_by: Scope
commit_groups:
group_by: Scope
header:
pattern: '^(.*):\s*(.*)$'
pattern_maps:
- Scope
- Subject
issues:
prefix:
- "#"
refs:
actions:
- Closes
- Fixes
- PullRequest
notes:
keywords:
- BREAKING CHANGE
- NOTE
+2
View File
@@ -0,0 +1,2 @@
# one of these users must approve the PR before merging
* @coryb @mikepea @ldelossa @georgettica
+23
View File
@@ -0,0 +1,23 @@
---
name: CI
on: [push, pull_request]
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
container: docker.io/library/golang:${{ matrix.go }}
strategy:
matrix:
go: ['1.13', '1.14']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: add gox
run: go install github.com/mitchellh/gox
- name: make binaries
run: make all
- name: perform tests
run: go test -v ./...
+40
View File
@@ -0,0 +1,40 @@
---
name: Prepare Release
on:
workflow_dispatch:
inputs:
branch:
description: 'the branch to prepare the release against'
required: true
deault: 'master'
tag:
description: 'the tag to be released'
required: true
jobs:
prepare:
name: Prepare Release
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Changelog
shell: bash
run: |
curl -L -o /tmp/git-chglog.tar.gz https://github.com/git-chglog/git-chglog/releases/download/v0.14.2/git-chglog_0.14.2_linux_amd64.tar.gz
tar xf /tmp/git-chglog.tar.gz -C /tmp git-chglog
chmod u+x /tmp/git-chglog
echo "creating change log for tag: ${{ github.event.inputs.tag }}"
/tmp/git-chglog --next-tag "${{ github.event.inputs.tag }}" -o CHANGELOG.md
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3.8.2
with:
title: "${{ github.event.inputs.tag }} Changelog Bump"
body: "This is an automated changelog commit."
commit-message: "chore: ${{ github.event.inputs.tag }} changelog bump"
branch: "ready-${{ github.event.inputs.tag }}"
signoff: "gh-actions"
+103
View File
@@ -0,0 +1,103 @@
---
name: Release
on:
push:
tags:
- v1.*
jobs:
release:
name: Release
runs-on: 'ubuntu-latest'
container: docker.io/library/golang:1.14
steps:
# This step is for local testing using https://github.com/nektos/act
- name: install node
run: |
apt update
apt install -y nodejs
- name: Setup
run: |
tag=`basename ${{ github.ref }}`
echo "VERSION=${tag}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: add gox
run: go install github.com/mitchellh/gox
- name: ChangeLog
shell: bash
run: |
curl -o git-chglog -L https://github.com/git-chglog/git-chglog/releases/download/0.9.1/git-chglog_linux_amd64
chmod u+x git-chglog
tag=`basename ${{ github.ref }}`
echo "creating change log for tag: $tag"
chglog="$(./git-chglog ${tag})"
chglog="${chglog//'%'/'%25'}"
chglog="${chglog//$'\n'/'%0A'}"
chglog="${chglog//$'\r'/'%0D'}"
echo "CHANGELOG=${chglog}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.VERSION }} Release
body: |
${{ env.CHANGELOG }}
prerelease: ${{ contains(env.VERSION, 'alpha') || contains(env.VERSION, 'beta') || contains(env.VERSION, 'rc') }}
# perform production release of artifacts
- name: Build Artifacts
run: |
VERSION=${{ env.VERSION }} make all
- name: "Publish Darwin AMD64"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/github.com/go-jira/jira-darwin-amd64
asset_name: jira-darwin-amd64
asset_content_type: application/octet-stream
- name: "Publish Linux 386"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/github.com/go-jira/jira-linux-386
asset_name: jira-linux-386
asset_content_type: application/octet-stream
- name: "Publish Linux AMD64"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/github.com/go-jira/jira-linux-amd64
asset_name: jira-linux-amd64
asset_content_type: application/octet-stream
- name: "Publish Windows 386"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/github.com/go-jira/jira-windows-386.exe
asset_name: jira-windows-386.exe
asset_content_type: application/octet-stream
- name: "Publish Windows AMD64"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/github.com/go-jira/jira-windows-amd64.exe
asset_name: jira-windows-amd64.exe
asset_content_type: application/octet-stream
+12 -7
View File
@@ -1,7 +1,12 @@
bin/
pkg/
src/code.google.com/
src/github.com/docopt/
src/github.com/mgutz/
src/github.com/op/
src/gopkg.in/
jira
schemas/*.json
/_t/.gnupg/random_seed
/_t/issue.props
/_t/attach.props
/_t/garbage.bin
/_t/attach1.txt
/_t/binary.out
/_t/foobar.bin
/_t/.password-store/GoJira/api-token:gojira@corybennett.org.gpg
/_t/.password-store/GoJira/api-token:mothra@corybennett.org.gpg
dist
+12
View File
@@ -0,0 +1,12 @@
config:
stop: true
password-source: pass
endpoint: https://go-jira.atlassian.net
user: admin
login: atlassian@corybennett.org
queries:
todo: |
resolution = unresolved {{if .project}}AND project = '{{.project}}'{{end}} AND status = 'To Do'
open: |
resolution = unresolved {{if .project}}AND project = '{{.project}}'{{end}} AND status = 'Open'
+502 -18
View File
@@ -1,29 +1,513 @@
# Changelog
<a name="unreleased"></a>
## [Unreleased]
## 0.0.5 - 2015-02-21
* handle editor having arguments [Cory Bennett] [[7186fb3](https://github.com/Netflix-Skunkworks/go-jira/commit/7186fb3)]
* add more template error handling [Cory Bennett] [[3e6f2b3](https://github.com/Netflix-Skunkworks/go-jira/commit/3e6f2b3)]
* allow create template to specify defalt watchers with -o watchers=... [Cory Bennett] [[4db2e4e](https://github.com/Netflix-Skunkworks/go-jira/commit/4db2e4e)]
* if config files are executable then run them and parse the output [Cory Bennett] [[7a2f7f5](https://github.com/Netflix-Skunkworks/go-jira/commit/7a2f7f5)]
<a name="v1.0.28"></a>
## [v1.0.28] - 2021-05-05
## 0.0.4 - 2015-02-19
<a name="v1.0.27"></a>
## [v1.0.27] - 2020-10-01
### Block
- [f7587f4](https://github.com/go-jira/go-jira/commit/f7587f43f12bcf0b47e52a5abe775daf6cbb3229): reverse order of arguments
### Chore
- [2c7a9b2](https://github.com/go-jira/go-jira/commit/2c7a9b283025202428db629b1a9ecdc63a9b704f): V1.0.27 changelog bump
### Templates
- [0e3082f](https://github.com/go-jira/go-jira/commit/0e3082fab6e12a337f5fe26c3e2dec5cb51425d8): add wrap helper function
* add --template option to export-templates to export a single template [Cory Bennett] [[343fbb6](https://github.com/Netflix-Skunkworks/go-jira/commit/343fbb6)]
* add "table" template to be used with "list" command [Cory Bennett] [[8954ec1](https://github.com/Netflix-Skunkworks/go-jira/commit/8954ec1)]
<a name="v1.0.26"></a>
## [v1.0.26] - 2020-09-11
### Chore
- [c3d22b7](https://github.com/go-jira/go-jira/commit/c3d22b765a6f3cd93445033da5c19fc0feaeaece): v1.0.26 changelog bump
### Cicd
- [96ec333](https://github.com/go-jira/go-jira/commit/96ec3339a4cc810da20450a9d9e91612c2b9aad4): automated releases fixes
- [31f7b03](https://github.com/go-jira/go-jira/commit/31f7b0397890388947f2312cf42af494c7a6979f): automated changelog and release
## 0.0.3 - 2015-02-19
<a name="v1.0.25"></a>
## [v1.0.25] - 2020-09-11
### Bugfix
- [aa8dae7](https://github.com/go-jira/go-jira/commit/aa8dae7c5b7035e086bd60b3d354ffa43c30caf7): only build jira tool with gox
### Chore
- [578c44c](https://github.com/go-jira/go-jira/commit/578c44c628e3134e4d46f3250baf46d6b054cfe8): v1.0.25 release
### Fix(Changelog)
- [ff5decc](https://github.com/go-jira/go-jira/commit/ff5decc114b297e9b393f8d4af72bbace0037c73): fix changelog version
### Tests
- [a8c961f](https://github.com/go-jira/go-jira/commit/a8c961fe19f424df3fdbe108a374cc56b8ff9fe0): rework passive tests into native go tests
* [issue [#8](https://github.com/Netflix-Skunkworks/go-jira/issues/8)] detect X-Seraph-Loginreason: AUTHENTICATION_DENIED header to catch login failures [Cory Bennett] [[2dcf665](https://github.com/Netflix-Skunkworks/go-jira/commit/2dcf665)]
* project should always be uppercase [Jay Buffington] [[1b69d12](https://github.com/Netflix-Skunkworks/go-jira/commit/1b69d12)]
* if response is 400, check json for errorMessages and log them [Jay Buffington] [[4924dfa](https://github.com/Netflix-Skunkworks/go-jira/commit/4924dfa)]
* validate project [Jay Buffington] [[dc5ae42](https://github.com/Netflix-Skunkworks/go-jira/commit/dc5ae42)]
<a name="v1.0.24"></a>
## [v1.0.24] - 2020-09-04
### Cicd
- [d093bcf](https://github.com/go-jira/go-jira/commit/d093bcf63adbd1d4e88640307aa8a5c8669ac535): deflake tests
### Tests
- [3bc5e42](https://github.com/go-jira/go-jira/commit/3bc5e42bd0186dbc5c47f022b9528207140fa297): transition if under review
### Transition
- [3c1c4d9](https://github.com/go-jira/go-jira/commit/3c1c4d95e199a717499f1f4259649152a6832e9f): map field name to id
### Username-Deprecation
- [6a27e28](https://github.com/go-jira/go-jira/commit/6a27e28c61c45f4b2a6aff473cf28852a2df64a2): use email and display names
### Pull Requests
- Merge pull request [#367](https://github.com/go-jira/go-jira/issues/367) from bbkane/master
- Merge pull request [#349](https://github.com/go-jira/go-jira/issues/349) from aszenz/patch-1
- Merge pull request [#355](https://github.com/go-jira/go-jira/issues/355) from go-jira/vanniktech-patch-1
- Merge pull request [#323](https://github.com/go-jira/go-jira/issues/323) from tjamet/issue-comment
## 0.0.2 - 2015-02-18
* add missing --override options on transition command
* add browse command
<a name="v1.0.23"></a>
## [v1.0.23] - 2020-02-26
### Add Sprig Template Functions, Replaces [#215] Http
- [719f7a6](https://github.com/go-jira/go-jira/commit/719f7a68a7f2c01e428a1ad3519a611c92268d27): //masterminds.github.io/sprig/
- [#215](https://github.com/go-jira/go-jira/issues/215)### All
- [31c113d](https://github.com/go-jira/go-jira/commit/31c113d1baf2dba814bca3e1dcc519ab8b0269e9): unindent some code
- [f125ef3](https://github.com/go-jira/go-jira/commit/f125ef3fa9c7a64e8dfda9a643cadf0241b09bc7): convert to a Go module
### CI
- [664c5ca](https://github.com/go-jira/go-jira/commit/664c5cad246cbd4c861b615eb567d3874151d1a1): test on Go 1.12.x, cleanup
### Docs
- [d8189f0](https://github.com/go-jira/go-jira/commit/d8189f0a018d1afd364237e51ca8ed43ea1aabb1): update pass documentation with password-name
### Fixes #228: Make '
- [52a577e](https://github.com/go-jira/go-jira/commit/52a577ea48afea9efb7a1f4163301129a66f7b76): ' gpg files temporary to fix go mod
- Fixes [#228](https://github.com/go-jira/go-jira/issues/228)### Merge Branch 'Make-Password-Source-Binary-Exchangeable' Of Https
- [e26fbfc](https://github.com/go-jira/go-jira/commit/e26fbfcb142f2ce8c7c33a977d4cf0b436d743eb): //github.com/patrickpichler/jira into patrickpichler-make-password-source-binary-exchangeable
### README
- [098d963](https://github.com/go-jira/go-jira/commit/098d963881322c2b2efba48ef6a39f235bdae881): trim down the content
### T
- [d237e86](https://github.com/go-jira/go-jira/commit/d237e86cda3812b23f432e90d120ec21e749a854): rename to _t to fix module support
- Fixes [#228](https://github.com/go-jira/go-jira/issues/228)### Update All Usage Of User.Name To User.AccountId For Privacy Migration: Https
- [a26683e](https://github.com/go-jira/go-jira/commit/a26683e01dc7e161e735b1b387d1633bc32da2fe): //developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/
### Pull Requests
- Merge pull request [#318](https://github.com/go-jira/go-jira/issues/318) from jrschumacher/patch-1
- Merge pull request [#317](https://github.com/go-jira/go-jira/issues/317) from go-jira/privacy-migration
- Merge pull request [#302](https://github.com/go-jira/go-jira/issues/302) from go-jira/simplify-template-tables
- Merge pull request [#292](https://github.com/go-jira/go-jira/issues/292) from pdecat/cache_password
- Merge pull request [#301](https://github.com/go-jira/go-jira/issues/301) from go-jira/allow-issue-ints
- Merge pull request [#286](https://github.com/go-jira/go-jira/issues/286) from patrickpichler/add-gopass-instructions-to-readme
- Merge pull request [#285](https://github.com/go-jira/go-jira/issues/285) from patrickpichler/add-gopass-support
- Merge pull request [#283](https://github.com/go-jira/go-jira/issues/283) from go-jira/sprig
- Merge pull request [#273](https://github.com/go-jira/go-jira/issues/273) from acaloiaro/master
- Merge pull request [#282](https://github.com/go-jira/go-jira/issues/282) from pcockwell/fix/choose-direct-transition-match-if-available
- Merge pull request [#280](https://github.com/go-jira/go-jira/issues/280) from go-jira/cut_v1_0_21
- Merge pull request [#275](https://github.com/go-jira/go-jira/issues/275) from go-jira/remove_gopkg_in
- Merge pull request [#278](https://github.com/go-jira/go-jira/issues/278) from go-jira/update-figtree
- Merge pull request [#276](https://github.com/go-jira/go-jira/issues/276) from go-jira/fix_228
- Merge pull request [#266](https://github.com/go-jira/go-jira/issues/266) from mbethke/fix-multiline-worklog-comment
- Merge pull request [#263](https://github.com/go-jira/go-jira/issues/263) from kojustin/master
- Merge pull request [#253](https://github.com/go-jira/go-jira/issues/253) from mvdan/module
- Merge pull request [#240](https://github.com/go-jira/go-jira/issues/240) from jgraglia/patch-1
- Merge pull request [#219](https://github.com/go-jira/go-jira/issues/219) from kerhac/master
- Merge pull request [#236](https://github.com/go-jira/go-jira/issues/236) from CodeLingoBot/rewrite
- Merge pull request [#245](https://github.com/go-jira/go-jira/issues/245) from justmiles/211
<a name="v1.0.22"></a>
## [v1.0.22] - 2019-09-30
### All
- [bb9790f](https://github.com/go-jira/go-jira/commit/bb9790f28783c1b82a3685a9c4657241e906826a): unindent some code
- [89fe2ec](https://github.com/go-jira/go-jira/commit/89fe2ecf16709511c3e04e02f7c7906a5ac6865a): convert to a Go module
### CI
- [80743e4](https://github.com/go-jira/go-jira/commit/80743e4da870a1febcc65d18d08242bb201b744d): test on Go 1.12.x, cleanup
### Docs
- [48c15e2](https://github.com/go-jira/go-jira/commit/48c15e2daa7b3f4c84526bd9f030828f378edfc2): update pass documentation with password-name
### Fixes #228: Make '
- [3984d0d](https://github.com/go-jira/go-jira/commit/3984d0d4848fdfe790f46ec18bd3b71782e36c32): ' gpg files temporary to fix go mod
- Fixes [#228](https://github.com/go-jira/go-jira/issues/228)### README
- [dc9a9de](https://github.com/go-jira/go-jira/commit/dc9a9de165859057e4596aa47961e84de34b0b4b): trim down the content
### T
- [8994b42](https://github.com/go-jira/go-jira/commit/8994b42f714f8fc5b224bda8b5835f003d96ef02): rename to _t to fix module support
- Fixes [#228](https://github.com/go-jira/go-jira/issues/228)
<a name="v1.0.21"></a>
## [v1.0.21] - 2019-09-16
### All
- [31c113d](https://github.com/go-jira/go-jira/commit/31c113d1baf2dba814bca3e1dcc519ab8b0269e9): unindent some code
- [f125ef3](https://github.com/go-jira/go-jira/commit/f125ef3fa9c7a64e8dfda9a643cadf0241b09bc7): convert to a Go module
### CI
- [664c5ca](https://github.com/go-jira/go-jira/commit/664c5cad246cbd4c861b615eb567d3874151d1a1): test on Go 1.12.x, cleanup
### Docs
- [d8189f0](https://github.com/go-jira/go-jira/commit/d8189f0a018d1afd364237e51ca8ed43ea1aabb1): update pass documentation with password-name
### Fixes #228: Make '
- [52a577e](https://github.com/go-jira/go-jira/commit/52a577ea48afea9efb7a1f4163301129a66f7b76): ' gpg files temporary to fix go mod
- Fixes [#228](https://github.com/go-jira/go-jira/issues/228)### README
- [098d963](https://github.com/go-jira/go-jira/commit/098d963881322c2b2efba48ef6a39f235bdae881): trim down the content
### T
- [d237e86](https://github.com/go-jira/go-jira/commit/d237e86cda3812b23f432e90d120ec21e749a854): rename to _t to fix module support
- Fixes [#228](https://github.com/go-jira/go-jira/issues/228)### Pull Requests
- Merge pull request [#275](https://github.com/go-jira/go-jira/issues/275) from go-jira/remove_gopkg_in
- Merge pull request [#278](https://github.com/go-jira/go-jira/issues/278) from go-jira/update-figtree
- Merge pull request [#276](https://github.com/go-jira/go-jira/issues/276) from go-jira/fix_228
- Merge pull request [#266](https://github.com/go-jira/go-jira/issues/266) from mbethke/fix-multiline-worklog-comment
- Merge pull request [#263](https://github.com/go-jira/go-jira/issues/263) from kojustin/master
- Merge pull request [#253](https://github.com/go-jira/go-jira/issues/253) from mvdan/module
- Merge pull request [#240](https://github.com/go-jira/go-jira/issues/240) from jgraglia/patch-1
- Merge pull request [#219](https://github.com/go-jira/go-jira/issues/219) from kerhac/master
- Merge pull request [#236](https://github.com/go-jira/go-jira/issues/236) from CodeLingoBot/rewrite
- Merge pull request [#245](https://github.com/go-jira/go-jira/issues/245) from justmiles/211
- Merge pull request [#220](https://github.com/go-jira/go-jira/issues/220) from ejsuncy/master
<a name="v1.0.20"></a>
## [v1.0.20] - 2018-08-04
<a name="v1.0.19"></a>
## [v1.0.19] - 2018-08-02
### Pull Requests
- Merge pull request [#197](https://github.com/go-jira/go-jira/issues/197) from kojiromike/spellcheck
<a name="v1.0.18"></a>
## [v1.0.18] - 2018-07-29
### They Broke Golang.Org/X/Net: ERROR: Vendor/Golang.Org/X/Net/Proxy/Socks5.Go:11:2
- [7191c77](https://github.com/go-jira/go-jira/commit/7191c7751b2d18d7f951d089fa3235acf5748d4b): use of internal package not allowed
### Pull Requests
- Merge pull request [#178](https://github.com/go-jira/go-jira/issues/178) from vergenzt/patch-1
<a name="v1.0.17"></a>
## [v1.0.17] - 2018-04-15
### [#157] Add `Password-Directory
- [06b26c9](https://github.com/go-jira/go-jira/commit/06b26c9e00384318ec7a51fa1c5ff5de63ea686b): path` to allow overriding PASSWORD_STORE_DIR from configs
- [#157](https://github.com/go-jira/go-jira/issues/157)### Pull Requests
- Merge pull request [#161](https://github.com/go-jira/go-jira/issues/161) from vanniktech/patch-1
<a name="v1.0.16"></a>
## [v1.0.16] - 2018-04-01
### Pull Requests
- Merge pull request [#150](https://github.com/go-jira/go-jira/issues/150) from catskul/parameterized-go-makefile
- Merge pull request [#153](https://github.com/go-jira/go-jira/issues/153) from catskul/document-shell-completion
- Merge pull request [#152](https://github.com/go-jira/go-jira/issues/152) from catskul/fix-missing-priority
<a name="v1.0.15"></a>
## [v1.0.15] - 2018-03-08
### Pull Requests
- Merge pull request [#151](https://github.com/go-jira/go-jira/issues/151) from catskul/build-instructions
- Merge pull request [#142](https://github.com/go-jira/go-jira/issues/142) from anthonyrisinger/patch-1
<a name="v1.0.14"></a>
## [v1.0.14] - 2017-11-04
### Pull Requests
- Merge pull request [#130](https://github.com/go-jira/go-jira/issues/130) from onionjake/master
<a name="v1.0.13"></a>
## [v1.0.13] - 2017-10-28
### Pull Requests
- Merge pull request [#126](https://github.com/go-jira/go-jira/issues/126) from schorsch3000/master
- Merge pull request [#129](https://github.com/go-jira/go-jira/issues/129) from blachniet/logout-help-typo-fix
- Merge pull request [#124](https://github.com/go-jira/go-jira/issues/124) from gvol/master
- Merge pull request [#128](https://github.com/go-jira/go-jira/issues/128) from mivok/escape-issuetype
<a name="v1.0.12"></a>
## [v1.0.12] - 2017-10-04
<a name="v1.0.11"></a>
## [v1.0.11] - 2017-09-26
<a name="v1.0.10"></a>
## [v1.0.10] - 2017-09-18
<a name="v1.0.9"></a>
## [v1.0.9] - 2017-09-17
<a name="v1.0.8"></a>
## [v1.0.8] - 2017-09-17
<a name="v1.0.7"></a>
## [v1.0.7] - 2017-09-15
<a name="v1.0.6"></a>
## [v1.0.6] - 2017-09-13
<a name="v1.0.5"></a>
## [v1.0.5] - 2017-09-11
<a name="v1.0.4"></a>
## [v1.0.4] - 2017-09-08
<a name="v1.0.3"></a>
## [v1.0.3] - 2017-09-06
<a name="v1.0.2"></a>
## [v1.0.2] - 2017-09-06
<a name="v1.0.1"></a>
## [v1.0.1] - 2017-09-06
<a name="v1.0.0"></a>
## [v1.0.0] - 2017-09-05
<a name="v0.1.15"></a>
## [v0.1.15] - 2017-08-25
### Pull Requests
- Merge pull request [#104](https://github.com/go-jira/go-jira/issues/104) from wrouesnel/keyring-update
- Merge pull request [#90](https://github.com/go-jira/go-jira/issues/90) from bbaugher/master
<a name="v0.1.14"></a>
## [v0.1.14] - 2017-05-10
<a name="v0.1.13"></a>
## [v0.1.13] - 2017-04-24
### Pull Requests
- Merge pull request [#78](https://github.com/go-jira/go-jira/issues/78) from davidreuss/generic-issuelink
- Merge pull request [#77](https://github.com/go-jira/go-jira/issues/77) from davidreuss/fix-start-parameter-for-pagination
<a name="v0.1.12"></a>
## [v0.1.12] - 2017-03-22
### Pull Requests
- Merge pull request [#74](https://github.com/go-jira/go-jira/issues/74) from clausb/BrowseOnWindows
<a name="v0.1.11"></a>
## [v0.1.11] - 2017-02-26
<a name="v0.1.10"></a>
## [v0.1.10] - 2017-02-08
### Doc Tweak
- [e6faa4e](https://github.com/go-jira/go-jira/commit/e6faa4eab1a8d6a7fb624b79bb58a641d02e876b): add info for setting username
### Merge Branch 'Master' Of Github.Com
- [63bc2ae](https://github.com/go-jira/go-jira/commit/63bc2ae15a2ebafa16861965951800e0d5c122bd): Netflix-Skunkworks/go-jira
### Refactor Password Source, Allow For "Pass" To Be Used, Update Tests To Use `Password-Source
- [cb70941](https://github.com/go-jira/go-jira/commit/cb70941aad2b8198f5c8ad8d1e1a7a98dc820cd9): pass`
### Pull Requests
- Merge pull request [#65](https://github.com/go-jira/go-jira/issues/65) from mlbright/patch-1
- Merge pull request [#64](https://github.com/go-jira/go-jira/issues/64) from astrostl/patch-2
- Merge pull request [#62](https://github.com/go-jira/go-jira/issues/62) from astrostl/patch-1
<a name="v0.1.9"></a>
## [v0.1.9] - 2016-12-18
### Fix(Http)
- [b326623](https://github.com/go-jira/go-jira/commit/b326623ed22677a3ff76d2c4c67bb7ca7ecb3877): Add proxy transport
- [72c78c6](https://github.com/go-jira/go-jira/commit/72c78c6c1c63a70d837c8e367754792c8a30ae06): Add proxy transport
### Merge Branch 'Master' Of Github.Com
- [ac515e2](https://github.com/go-jira/go-jira/commit/ac515e2743e1bcf5f492a0e25d2b084f3311f0d0): Netflix-Skunkworks/go-jira
### Pull Requests
- Merge pull request [#61](https://github.com/go-jira/go-jira/issues/61) from sylus/feature-proxy
- Merge pull request [#60](https://github.com/go-jira/go-jira/issues/60) from facundoolano/patch-1
<a name="v0.1.8"></a>
## [v0.1.8] - 2016-11-24
### Pull Requests
- Merge pull request [#53](https://github.com/go-jira/go-jira/issues/53) from jshirley/master
<a name="v0.1.7"></a>
## [v0.1.7] - 2016-08-24
### Pull Requests
- Merge pull request [#52](https://github.com/go-jira/go-jira/issues/52) from dbrower/master
<a name="v0.1.6"></a>
## [v0.1.6] - 2016-08-21
<a name="v0.1.5"></a>
## [v0.1.5] - 2016-08-21
<a name="v0.1.4"></a>
## [v0.1.4] - 2016-08-12
<a name="v0.1.3"></a>
## [v0.1.3] - 2016-07-30
### Pull Requests
- Merge pull request [#24](https://github.com/go-jira/go-jira/issues/24) from mikepea/edit_template_common
<a name="v0.1.2"></a>
## [v0.1.2] - 2016-06-29
<a name="v0.1.1"></a>
## [v0.1.1] - 2016-06-28
### Merge Branch 'Master' Of Github.Com
- [dd0f5ef](https://github.com/go-jira/go-jira/commit/dd0f5efd3247157686c2c88817d3ad375de399ea): Netflix-Skunkworks/go-jira
### Pull Requests
- Merge pull request [#39](https://github.com/go-jira/go-jira/issues/39) from mikepea/system_template_dir
- Merge pull request [#38](https://github.com/go-jira/go-jira/issues/38) from jglick/patch-1
- Merge pull request [#37](https://github.com/go-jira/go-jira/issues/37) from tobyjoe/add-resource-expansion
- Merge pull request [#35](https://github.com/go-jira/go-jira/issues/35) from QuinnyPig/fix-readme
- Merge pull request [#34](https://github.com/go-jira/go-jira/issues/34) from jonathanio/fix/issuetypes-url-escaping
<a name="v0.1.0"></a>
## [v0.1.0] - 2016-01-29
### Add Component/Components Support
- [595a521](https://github.com/go-jira/go-jira/commit/595a5212b43be28e01a0d5a6cf98a8de89383e41): add and list for now.
### Merge Branch 'Master' Of Github.Com
- [9e90376](https://github.com/go-jira/go-jira/commit/9e90376816c295d3a75b4f51703c24fd95873625): Netflix-Skunkworks/go-jira
- [382bf4f](https://github.com/go-jira/go-jira/commit/382bf4faeb17198b54950a05b0fdb3e126af8d73): Netflix-Skunkworks/go-jira
### Pull Requests
- Merge pull request [#33](https://github.com/go-jira/go-jira/issues/33) from mikepea/make_jirad
- Merge pull request [#31](https://github.com/go-jira/go-jira/issues/31) from mikepea/component_mgmt
- Merge pull request [#30](https://github.com/go-jira/go-jira/issues/30) from mikepea/unwatch_support
- Merge pull request [#26](https://github.com/go-jira/go-jira/issues/26) from mikepea/vote_support
<a name="v0.0.20"></a>
## [v0.0.20] - 2016-01-21
### Correct Naming Of Parameter
- [8e66246](https://github.com/go-jira/go-jira/commit/8e662462dac6cccdf8af277797777caeff3ad2bc): set/add/remove are actions.
### Pull Requests
- Merge pull request [#27](https://github.com/go-jira/go-jira/issues/27) from blalor/insecure-skip-verify
- Merge pull request [#21](https://github.com/go-jira/go-jira/issues/21) from mikepea/label_command
- Merge pull request [#22](https://github.com/go-jira/go-jira/issues/22) from mikepea/library_break_out
- Merge pull request [#20](https://github.com/go-jira/go-jira/issues/20) from mikepea/add_join_template_func
<a name="0.0.19"></a>
## [0.0.19] - 2015-12-09
<a name="0.0.18"></a>
## [0.0.18] - 2015-12-03
<a name="0.0.17"></a>
## [0.0.17] - 2015-12-03
<a name="0.0.16"></a>
## [0.0.16] - 2015-11-23
<a name="0.0.15"></a>
## [0.0.15] - 2015-11-23
<a name="0.0.14"></a>
## [0.0.14] - 2015-11-17
### Pull Requests
- Merge pull request [#16](https://github.com/go-jira/go-jira/issues/16) from oschrenk/fix-typo
- Merge pull request [#14](https://github.com/go-jira/go-jira/issues/14) from mikepea/ls_with_updated
<a name="0.0.13"></a>
## [0.0.13] - 2015-09-19
<a name="0.0.12"></a>
## [0.0.12] - 2015-09-18
<a name="0.0.11"></a>
## [0.0.11] - 2015-09-16
<a name="0.0.10"></a>
## [0.0.10] - 2015-09-15
<a name="0.0.9"></a>
## [0.0.9] - 2015-09-15
### Allow "Abort
- [80b6f5a](https://github.com/go-jira/go-jira/commit/80b6f5a198fbe17aa0245c470d47c2988d8624c3): true" to be set while editing to cancel the edit operation
<a name="0.0.8"></a>
## [0.0.8] - 2015-07-31
### Pull Requests
- Merge pull request [#11](https://github.com/go-jira/go-jira/issues/11) from mikepea/max_results_option
### Note
that testing against our JIRA instance, in a project with
more than 1000 open issues, suggests that the JIRA has an internal
limit of 1000 results in a single query.
<a name="0.0.7"></a>
## [0.0.7] - 2015-07-01
### Merge Branch 'Master' Of Github.Com
- [b72040b](https://github.com/go-jira/go-jira/commit/b72040bfd413bcdc88ca2c3f6843a7f6dee2e898): Netflix-Skunkworks/go-jira
### Pull Requests
- Merge pull request [#9](https://github.com/go-jira/go-jira/issues/9) from nelfin/quickfix/take-user
<a name="0.0.6"></a>
## [0.0.6] - 2015-02-27
### Set JIRA_OPERATION To "View" When No Operation Used (Ie
- [8040746](https://github.com/go-jira/go-jira/commit/8040746bcf6aac6e3ff6e419c349661a8fc9bf99): jira GOJIRA-123)
<a name="0.0.5"></a>
## [0.0.5] - 2015-02-21
<a name="0.0.4"></a>
## [0.0.4] - 2015-02-19
<a name="0.0.3"></a>
## [0.0.3] - 2015-02-19
### [Issue #8] Detect X-Seraph-Loginreason
- [f3feff7](https://github.com/go-jira/go-jira/commit/f3feff796fbecca6477ecbc1e9dae6a2b78e755c): AUTHENTICATION_DENIED header to catch login failures
- [#8](https://github.com/go-jira/go-jira/issues/8)### Pull Requests
- Merge pull request [#7](https://github.com/go-jira/go-jira/issues/7) from jaybuff/empty-projects
<a name="0.0.2"></a>
## [0.0.2] - 2015-02-18
<a name="0.0.1"></a>
## 0.0.1 - 2015-02-18
### Adding Commands
- [18f10fd](https://github.com/go-jira/go-jira/commit/18f10fd12521584c7d85b20dff2b1c2da0854cb9): * create * dups * blocks * watch
### Merge Branch 'Nil-Assignee' Of Https
- [25539ef](https://github.com/go-jira/go-jira/commit/25539efedda0e06e103fc942e16405c0c09ba621): //github.com/jaybuff/go-jira into jaybuff-nil-assignee
### Work In Progress, Minor Refactor. Added Commands
- [acbc24b](https://github.com/go-jira/go-jira/commit/acbc24b2096f31a5805fa48984724a4a6c1da431): * login * editmeta ISSUE * edit ISSUE * issuetypes [-p PROJECT] * createmeta [-p PROJECT] [-i ISSUETYPE] * transitions ISSUE
### Pull Requests
- Merge pull request [#2](https://github.com/go-jira/go-jira/issues/2) from jaybuff/clean-up
* Initial experimental release
[Unreleased]: https://github.com/go-jira/go-jira/compare/v1.0.28...HEAD
[v1.0.28]: https://github.com/go-jira/go-jira/compare/v1.0.27...v1.0.28
[v1.0.27]: https://github.com/go-jira/go-jira/compare/v1.0.26...v1.0.27
[v1.0.26]: https://github.com/go-jira/go-jira/compare/v1.0.25...v1.0.26
[v1.0.25]: https://github.com/go-jira/go-jira/compare/v1.0.24...v1.0.25
[v1.0.24]: https://github.com/go-jira/go-jira/compare/v1.0.23...v1.0.24
[v1.0.23]: https://github.com/go-jira/go-jira/compare/v1.0.22...v1.0.23
[v1.0.22]: https://github.com/go-jira/go-jira/compare/v1.0.21...v1.0.22
[v1.0.21]: https://github.com/go-jira/go-jira/compare/v1.0.20...v1.0.21
[v1.0.20]: https://github.com/go-jira/go-jira/compare/v1.0.19...v1.0.20
[v1.0.19]: https://github.com/go-jira/go-jira/compare/v1.0.18...v1.0.19
[v1.0.18]: https://github.com/go-jira/go-jira/compare/v1.0.17...v1.0.18
[v1.0.17]: https://github.com/go-jira/go-jira/compare/v1.0.16...v1.0.17
[v1.0.16]: https://github.com/go-jira/go-jira/compare/v1.0.15...v1.0.16
[v1.0.15]: https://github.com/go-jira/go-jira/compare/v1.0.14...v1.0.15
[v1.0.14]: https://github.com/go-jira/go-jira/compare/v1.0.13...v1.0.14
[v1.0.13]: https://github.com/go-jira/go-jira/compare/v1.0.12...v1.0.13
[v1.0.12]: https://github.com/go-jira/go-jira/compare/v1.0.11...v1.0.12
[v1.0.11]: https://github.com/go-jira/go-jira/compare/v1.0.10...v1.0.11
[v1.0.10]: https://github.com/go-jira/go-jira/compare/v1.0.9...v1.0.10
[v1.0.9]: https://github.com/go-jira/go-jira/compare/v1.0.8...v1.0.9
[v1.0.8]: https://github.com/go-jira/go-jira/compare/v1.0.7...v1.0.8
[v1.0.7]: https://github.com/go-jira/go-jira/compare/v1.0.6...v1.0.7
[v1.0.6]: https://github.com/go-jira/go-jira/compare/v1.0.5...v1.0.6
[v1.0.5]: https://github.com/go-jira/go-jira/compare/v1.0.4...v1.0.5
[v1.0.4]: https://github.com/go-jira/go-jira/compare/v1.0.3...v1.0.4
[v1.0.3]: https://github.com/go-jira/go-jira/compare/v1.0.2...v1.0.3
[v1.0.2]: https://github.com/go-jira/go-jira/compare/v1.0.1...v1.0.2
[v1.0.1]: https://github.com/go-jira/go-jira/compare/v1.0.0...v1.0.1
[v1.0.0]: https://github.com/go-jira/go-jira/compare/v0.1.15...v1.0.0
[v0.1.15]: https://github.com/go-jira/go-jira/compare/v0.1.14...v0.1.15
[v0.1.14]: https://github.com/go-jira/go-jira/compare/v0.1.13...v0.1.14
[v0.1.13]: https://github.com/go-jira/go-jira/compare/v0.1.12...v0.1.13
[v0.1.12]: https://github.com/go-jira/go-jira/compare/v0.1.11...v0.1.12
[v0.1.11]: https://github.com/go-jira/go-jira/compare/v0.1.10...v0.1.11
[v0.1.10]: https://github.com/go-jira/go-jira/compare/v0.1.9...v0.1.10
[v0.1.9]: https://github.com/go-jira/go-jira/compare/v0.1.8...v0.1.9
[v0.1.8]: https://github.com/go-jira/go-jira/compare/v0.1.7...v0.1.8
[v0.1.7]: https://github.com/go-jira/go-jira/compare/v0.1.6...v0.1.7
[v0.1.6]: https://github.com/go-jira/go-jira/compare/v0.1.5...v0.1.6
[v0.1.5]: https://github.com/go-jira/go-jira/compare/v0.1.4...v0.1.5
[v0.1.4]: https://github.com/go-jira/go-jira/compare/v0.1.3...v0.1.4
[v0.1.3]: https://github.com/go-jira/go-jira/compare/v0.1.2...v0.1.3
[v0.1.2]: https://github.com/go-jira/go-jira/compare/v0.1.1...v0.1.2
[v0.1.1]: https://github.com/go-jira/go-jira/compare/v0.1.0...v0.1.1
[v0.1.0]: https://github.com/go-jira/go-jira/compare/v0.0.20...v0.1.0
[v0.0.20]: https://github.com/go-jira/go-jira/compare/0.0.19...v0.0.20
[0.0.19]: https://github.com/go-jira/go-jira/compare/0.0.18...0.0.19
[0.0.18]: https://github.com/go-jira/go-jira/compare/0.0.17...0.0.18
[0.0.17]: https://github.com/go-jira/go-jira/compare/0.0.16...0.0.17
[0.0.16]: https://github.com/go-jira/go-jira/compare/0.0.15...0.0.16
[0.0.15]: https://github.com/go-jira/go-jira/compare/0.0.14...0.0.15
[0.0.14]: https://github.com/go-jira/go-jira/compare/0.0.13...0.0.14
[0.0.13]: https://github.com/go-jira/go-jira/compare/0.0.12...0.0.13
[0.0.12]: https://github.com/go-jira/go-jira/compare/0.0.11...0.0.12
[0.0.11]: https://github.com/go-jira/go-jira/compare/0.0.10...0.0.11
[0.0.10]: https://github.com/go-jira/go-jira/compare/0.0.9...0.0.10
[0.0.9]: https://github.com/go-jira/go-jira/compare/0.0.8...0.0.9
[0.0.8]: https://github.com/go-jira/go-jira/compare/0.0.7...0.0.8
[0.0.7]: https://github.com/go-jira/go-jira/compare/0.0.6...0.0.7
[0.0.6]: https://github.com/go-jira/go-jira/compare/0.0.5...0.0.6
[0.0.5]: https://github.com/go-jira/go-jira/compare/0.0.4...0.0.5
[0.0.4]: https://github.com/go-jira/go-jira/compare/0.0.3...0.0.4
[0.0.3]: https://github.com/go-jira/go-jira/compare/0.0.2...0.0.3
[0.0.2]: https://github.com/go-jira/go-jira/compare/0.0.1...0.0.2
+492
View File
@@ -0,0 +1,492 @@
# Changelog
## 1.0.25 - 2020-09-11
* Ensure body is NPE safe [Louis DeLosSantos] [[42e5d23](https://github.com/Netflix-Skunkworks/go-jira/commit/42e5d23)]
* Support empty responses in request commands [Louis DeLosSantos] [[b572037](https://github.com/Netflix-Skunkworks/go-jira/commit/b572037)]
## 1.0.24 - 2020-09-04
* Make -h flag show --help [Benjamin Kane] [[4bf1d03](https://github.com/Netflix-Skunkworks/go-jira/commit/4bf1d03)]
* transition: map field name to id [Louis DeLosSantos] [[3c1c4d9](https://github.com/Netflix-Skunkworks/go-jira/commit/3c1c4d9)]
* username-deprecation: use email and display names [Louis DeLosSantos] [[6a27e28](https://github.com/Netflix-Skunkworks/go-jira/commit/6a27e28)]
* Add support to get all comments for an issue [Thibault Jamet] [[a311d0d](https://github.com/Netflix-Skunkworks/go-jira/commit/a311d0d)]
* update all usage of user.name to user.accountId for privacy migration: https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/ [Cory Bennett] [[a26683e](https://github.com/Netflix-Skunkworks/go-jira/commit/a26683e)]
* add template functions to handle table output, fixes [#176](https://github.com/Netflix-Skunkworks/go-jira/issues/176), replaces [#296](https://github.com/Netflix-Skunkworks/go-jira/issues/296) [Cory Bennett] [[7e97463](https://github.com/Netflix-Skunkworks/go-jira/commit/7e97463)]
* use `password-source-path` to allow overriding binary and/or path to binary [Cory Bennett] [[d6173ce](https://github.com/Netflix-Skunkworks/go-jira/commit/d6173ce)]
* allow issues on command line to automatically prefix with project when defined [Cory Bennett] [[d002d7f](https://github.com/Netflix-Skunkworks/go-jira/commit/d002d7f)]
* Forgot you use TAB instead of spaces [Cory Bennett] [[789886c](https://github.com/Netflix-Skunkworks/go-jira/commit/789886c)]
* Fixed append project to view [Cory Bennett] [[8a46215](https://github.com/Netflix-Skunkworks/go-jira/commit/8a46215)]
* Added a line break removal function [Cory Bennett] [[9cbd993](https://github.com/Netflix-Skunkworks/go-jira/commit/9cbd993)]
* Pushed Readfile to .jira.d directory instead of pwd [Cory Bennett] [[db53622](https://github.com/Netflix-Skunkworks/go-jira/commit/db53622)]
* Cache password to avoid invoking password source on each API request [Patrick Decat] [[0f059a5](https://github.com/Netflix-Skunkworks/go-jira/commit/0f059a5)]
* Add support to switch out password source binary [Patrick Pichler] [[659a5c8](https://github.com/Netflix-Skunkworks/go-jira/commit/659a5c8)]
* Add error handling to pass password-source [Patrick Pichler] [[3339303](https://github.com/Netflix-Skunkworks/go-jira/commit/3339303)]
* Add gopass support [Patrick Pichler] [[3c0a62e](https://github.com/Netflix-Skunkworks/go-jira/commit/3c0a62e)]
* add sprig template functions, replaces [[#215](https://github.com/Netflix-Skunkworks/go-jira/issues/215)] http://masterminds.github.io/sprig/ [Cory Bennett] [[719f7a6](https://github.com/Netflix-Skunkworks/go-jira/commit/719f7a6)]
* [[#232](https://github.com/Netflix-Skunkworks/go-jira/issues/232)] fix api to use common Version schema also rewrote the schema fetcher to use Go [Cory Bennett] [[90f01ce](https://github.com/Netflix-Skunkworks/go-jira/commit/90f01ce)]
* fix syntax [Cory Bennett] [[94dd489](https://github.com/Netflix-Skunkworks/go-jira/commit/94dd489)]
* Address comments for direct name match [Patrick Cockwell] [[a70384b](https://github.com/Netflix-Skunkworks/go-jira/commit/a70384b)]
* Choose exact transition match if available [Patrick Cockwell] [[a646f76](https://github.com/Netflix-Skunkworks/go-jira/commit/a646f76)]
* [[#277](https://github.com/Netflix-Skunkworks/go-jira/issues/277)] update figtree to latest [Cory Bennett] [[0e520a4](https://github.com/Netflix-Skunkworks/go-jira/commit/0e520a4)]
* Switch over to using github.com/go-jira/jira, from gopkg.in [Mike Pountney] [[27f57b2](https://github.com/Netflix-Skunkworks/go-jira/commit/27f57b2)]
* Add 'pctOf' and 'fit' template functions [Adriano Caloiaro] [[027adee](https://github.com/Netflix-Skunkworks/go-jira/commit/027adee)]
* fix worklog template to allow multiline comments [Matthias Bethke] [[43e07f1](https://github.com/Netflix-Skunkworks/go-jira/commit/43e07f1)]
* Allow reading password from stdin [Justin Ko] [[225e1dc](https://github.com/Netflix-Skunkworks/go-jira/commit/225e1dc)]
* all: unindent some code [Daniel Martí] [[31c113d](https://github.com/Netflix-Skunkworks/go-jira/commit/31c113d)]
* don't use ReadAll when decoding JSON [Daniel Martí] [[9bcdcc1](https://github.com/Netflix-Skunkworks/go-jira/commit/9bcdcc1)]
* start making staticcheck happier [Daniel Martí] [[9b9186f](https://github.com/Netflix-Skunkworks/go-jira/commit/9b9186f)]
* all: convert to a Go module [Daniel Martí] [[f125ef3](https://github.com/Netflix-Skunkworks/go-jira/commit/f125ef3)]
* CI: test on Go 1.12.x, cleanup [Daniel Martí] [[664c5ca](https://github.com/Netflix-Skunkworks/go-jira/commit/664c5ca)]
* make automatic pagination on search optional, fix tests [Cory Bennett] [[36c99ce](https://github.com/Netflix-Skunkworks/go-jira/commit/36c99ce)]
* prefer defer resp.Body.Close to avoid leaks on subsequent errors [Cory Bennett] [[181bd74](https://github.com/Netflix-Skunkworks/go-jira/commit/181bd74)]
* add pagination to search [Miles Maddox] [[76dd1d8](https://github.com/Netflix-Skunkworks/go-jira/commit/76dd1d8)]
* Fix function comments based on best practices from Effective Go [CodeLingo Bot] [[23ac118](https://github.com/Netflix-Skunkworks/go-jira/commit/23ac118)]
## 1.0.23 - 2020-02-26
* update all usage of user.name to user.accountId for privacy migration: https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/ [Cory Bennett] [[a26683e](https://github.com/Netflix-Skunkworks/go-jira/commit/a26683e)]
* add template functions to handle table output, fixes [#176](https://github.com/Netflix-Skunkworks/go-jira/issues/176), replaces [#296](https://github.com/Netflix-Skunkworks/go-jira/issues/296) [Cory Bennett] [[7e97463](https://github.com/Netflix-Skunkworks/go-jira/commit/7e97463)]
* use `password-source-path` to allow overriding binary and/or path to binary [Cory Bennett] [[d6173ce](https://github.com/Netflix-Skunkworks/go-jira/commit/d6173ce)]
* allow issues on command line to automatically prefix with project when defined [Cory Bennett] [[d002d7f](https://github.com/Netflix-Skunkworks/go-jira/commit/d002d7f)]
* Forgot you use TAB instead of spaces [Cory Bennett] [[789886c](https://github.com/Netflix-Skunkworks/go-jira/commit/789886c)]
* Fixed append project to view [Cory Bennett] [[8a46215](https://github.com/Netflix-Skunkworks/go-jira/commit/8a46215)]
* Added a line break removal function [Cory Bennett] [[9cbd993](https://github.com/Netflix-Skunkworks/go-jira/commit/9cbd993)]
* Pushed Readfile to .jira.d directory instead of pwd [Cory Bennett] [[db53622](https://github.com/Netflix-Skunkworks/go-jira/commit/db53622)]
* Cache password to avoid invoking password source on each API request [Patrick Decat] [[0f059a5](https://github.com/Netflix-Skunkworks/go-jira/commit/0f059a5)]
* Add support to switch out password source binary [Patrick Pichler] [[659a5c8](https://github.com/Netflix-Skunkworks/go-jira/commit/659a5c8)]
* Add error handling to pass password-source [Patrick Pichler] [[3339303](https://github.com/Netflix-Skunkworks/go-jira/commit/3339303)]
* Add gopass support [Patrick Pichler] [[3c0a62e](https://github.com/Netflix-Skunkworks/go-jira/commit/3c0a62e)]
* add sprig template functions, replaces [[#215](https://github.com/Netflix-Skunkworks/go-jira/issues/215)] http://masterminds.github.io/sprig/ [Cory Bennett] [[719f7a6](https://github.com/Netflix-Skunkworks/go-jira/commit/719f7a6)]
* [[#232](https://github.com/Netflix-Skunkworks/go-jira/issues/232)] fix api to use common Version schema also rewrote the schema fetcher to use Go [Cory Bennett] [[90f01ce](https://github.com/Netflix-Skunkworks/go-jira/commit/90f01ce)]
## 1.0.22 - 2019-09-30
* fix syntax [Cory Bennett] [[807ca76](https://github.com/Netflix-Skunkworks/go-jira/commit/807ca76)]
* Address comments for direct name match [Patrick Cockwell] [[a70384b](https://github.com/Netflix-Skunkworks/go-jira/commit/a70384b)]
* Choose exact transition match if available [Patrick Cockwell] [[a646f76](https://github.com/Netflix-Skunkworks/go-jira/commit/a646f76)]
## 1.0.21 - 2019-09-16
* [[#277](https://github.com/Netflix-Skunkworks/go-jira/issues/277)] update figtree to latest [Cory Bennett] [[0e520a4](https://github.com/Netflix-Skunkworks/go-jira/commit/0e520a4)]
* Switch over to using github.com/go-jira/jira, from gopkg.in [Mike Pountney] [[27f57b2](https://github.com/Netflix-Skunkworks/go-jira/commit/27f57b2)]
* fix worklog template to allow multiline comments [Matthias Bethke] [[43e07f1](https://github.com/Netflix-Skunkworks/go-jira/commit/43e07f1)]
* Allow reading password from stdin [Justin Ko] [[225e1dc](https://github.com/Netflix-Skunkworks/go-jira/commit/225e1dc)]
* all: unindent some code [Daniel Martí] [[31c113d](https://github.com/Netflix-Skunkworks/go-jira/commit/31c113d)]
* don't use ReadAll when decoding JSON [Daniel Martí] [[9bcdcc1](https://github.com/Netflix-Skunkworks/go-jira/commit/9bcdcc1)]
* start making staticcheck happier [Daniel Martí] [[9b9186f](https://github.com/Netflix-Skunkworks/go-jira/commit/9b9186f)]
* all: convert to a Go module [Daniel Martí] [[f125ef3](https://github.com/Netflix-Skunkworks/go-jira/commit/f125ef3)]
* CI: test on Go 1.12.x, cleanup [Daniel Martí] [[664c5ca](https://github.com/Netflix-Skunkworks/go-jira/commit/664c5ca)]
* make automatic pagination on search optional, fix tests [Cory Bennett] [[36c99ce](https://github.com/Netflix-Skunkworks/go-jira/commit/36c99ce)]
* prefer defer resp.Body.Close to avoid leaks on subsequent errors [Cory Bennett] [[181bd74](https://github.com/Netflix-Skunkworks/go-jira/commit/181bd74)]
* add pagination to search [Miles Maddox] [[76dd1d8](https://github.com/Netflix-Skunkworks/go-jira/commit/76dd1d8)]
* Fix function comments based on best practices from Effective Go [CodeLingo Bot] [[23ac118](https://github.com/Netflix-Skunkworks/go-jira/commit/23ac118)]
* [[#201](https://github.com/Netflix-Skunkworks/go-jira/issues/201)] update required library, failing to populate cookiejar from cookies file [Cory Bennett] [[ee69afa](https://github.com/Netflix-Skunkworks/go-jira/commit/ee69afa)]
## 1.0.20 - 2018-08-04
* [[#201](https://github.com/Netflix-Skunkworks/go-jira/issues/201)] update required library, failing to populate cookiejar from cookies file [Cory Bennett] [[ee69afa](https://github.com/Netflix-Skunkworks/go-jira/commit/ee69afa)]
## 1.0.19 - 2018-08-02
* [[#199](https://github.com/Netflix-Skunkworks/go-jira/issues/199)] [[#198](https://github.com/Netflix-Skunkworks/go-jira/issues/198)] update http client library, fix issues with internal login retries [Cory Bennett] [[0cba806](https://github.com/Netflix-Skunkworks/go-jira/commit/0cba806)]
## 1.0.18 - 2018-07-29
* [[#196](https://github.com/Netflix-Skunkworks/go-jira/issues/196)] add `jira session` command to show session information if user is authenticated [Cory Bennett] [[f592107](https://github.com/Netflix-Skunkworks/go-jira/commit/f592107)]
* [[#192](https://github.com/Netflix-Skunkworks/go-jira/issues/192)] fix template usage for 'fixVersions' in transition template [Cory Bennett] [[c9a4e30](https://github.com/Netflix-Skunkworks/go-jira/commit/c9a4e30)]
* move HandleExit to the jiracli package [Cory Bennett] [[ef9b731](https://github.com/Netflix-Skunkworks/go-jira/commit/ef9b731)]
* they broke golang.org/x/net: ERROR: vendor/golang.org/x/net/proxy/socks5.go:11:2: use of internal package not allowed [Cory Bennett] [[7191c77](https://github.com/Netflix-Skunkworks/go-jira/commit/7191c77)]
* udpate deps [Cory Bennett] [[d16bcc2](https://github.com/Netflix-Skunkworks/go-jira/commit/d16bcc2)]
* udpate for figtree api changes [Cory Bennett] [[07ba74b](https://github.com/Netflix-Skunkworks/go-jira/commit/07ba74b)]
* udpate to use latest dep, update figtree [Cory Bennett] [[462ef1c](https://github.com/Netflix-Skunkworks/go-jira/commit/462ef1c)]
* [[#171](https://github.com/Netflix-Skunkworks/go-jira/issues/171)] change proposed PasswordPath to PasswordName [Cory Bennett] [[213a7e0](https://github.com/Netflix-Skunkworks/go-jira/commit/213a7e0)]
* add pass path to config [dvogt23] [[fa01ff5](https://github.com/Netflix-Skunkworks/go-jira/commit/fa01ff5)]
## 1.0.17 - 2018-04-15
* fix IsTerminal usage for windows [Cory Bennett] [[7f9595c](https://github.com/Netflix-Skunkworks/go-jira/commit/7f9595c)]
* [[#166](https://github.com/Netflix-Skunkworks/go-jira/issues/166)] fix issue when editing templates specified with full path [Cory Bennett] [[d787ac0](https://github.com/Netflix-Skunkworks/go-jira/commit/d787ac0)]
* only prompt on logout if stdin and stdout are terminals [Cory Bennett] [[09a61c3](https://github.com/Netflix-Skunkworks/go-jira/commit/09a61c3)]
* [[#163](https://github.com/Netflix-Skunkworks/go-jira/issues/163)] fix url path join logic [Cory Bennett] [[9146346](https://github.com/Netflix-Skunkworks/go-jira/commit/9146346)]
* [[#160](https://github.com/Netflix-Skunkworks/go-jira/issues/160)] prompt when api-token is invalid to get new token [Cory Bennett] [[e639cce](https://github.com/Netflix-Skunkworks/go-jira/commit/e639cce)]
* [[#157](https://github.com/Netflix-Skunkworks/go-jira/issues/157)] add `password-directory: path` to allow overriding PASSWORD_STORE_DIR from configs [Cory Bennett] [[06b26c9](https://github.com/Netflix-Skunkworks/go-jira/commit/06b26c9)]
* [[#160](https://github.com/Netflix-Skunkworks/go-jira/issues/160)] allow `jira logout` to delete your api-token from keychain [Cory Bennett] [[bd3cf99](https://github.com/Netflix-Skunkworks/go-jira/commit/bd3cf99)]
## 1.0.16 - 2018-04-01
* [[#159](https://github.com/Netflix-Skunkworks/go-jira/issues/159)] fix `slice bounds out of range` error in `abbrev` template function [Cory Bennett] [[359bec2](https://github.com/Netflix-Skunkworks/go-jira/commit/359bec2)]
* [[#158](https://github.com/Netflix-Skunkworks/go-jira/issues/158)] always print usage to stdout [Cory Bennett] [[79c83f6](https://github.com/Netflix-Skunkworks/go-jira/commit/79c83f6)]
## 1.0.15 - 2018-03-08
* [[#147](https://github.com/Netflix-Skunkworks/go-jira/issues/147)] [[#148](https://github.com/Netflix-Skunkworks/go-jira/issues/148)] add support for api token based authentication [Cory Bennett] [[edb0662](https://github.com/Netflix-Skunkworks/go-jira/commit/edb0662)]
* refactor to simplify main [Cory Bennett] [[43ebc84](https://github.com/Netflix-Skunkworks/go-jira/commit/43ebc84)] [[0d7c1a7](https://github.com/Netflix-Skunkworks/go-jira/commit/0d7c1a7)]
* [[#145](https://github.com/Netflix-Skunkworks/go-jira/issues/145)] fix to match AuthProvider interface [Cory Bennett] [[80325a5](https://github.com/Netflix-Skunkworks/go-jira/commit/80325a5)]
* [[#141](https://github.com/Netflix-Skunkworks/go-jira/issues/141)] better handling in responseError for non-json error responses [Cory Bennett] [[20a9666](https://github.com/Netflix-Skunkworks/go-jira/commit/20a9666)]
* Update unexportTemplates.go [GitHub] [[6da9974](https://github.com/Netflix-Skunkworks/go-jira/commit/6da9974)]
* [[#139](https://github.com/Netflix-Skunkworks/go-jira/issues/139)] add shellquote and toMinJson template functions [Cory Bennett] [[8c7ca38](https://github.com/Netflix-Skunkworks/go-jira/commit/8c7ca38)]
* [[#137](https://github.com/Netflix-Skunkworks/go-jira/issues/137)] update kingpeon dep to allow access to dynamic command structure [Cory Bennett] [[425fa63](https://github.com/Netflix-Skunkworks/go-jira/commit/425fa63)]
* field name is "comment" not "comments" [Cory Bennett] [[464742c](https://github.com/Netflix-Skunkworks/go-jira/commit/464742c)]
## 1.0.14 - 2017-11-04
* [[#131](https://github.com/Netflix-Skunkworks/go-jira/issues/131)] fix parsing global options before command execution (allow unixproxy/socksproxy to be set in config.yml) [Cory Bennett] [[042bc48](https://github.com/Netflix-Skunkworks/go-jira/commit/042bc48)]
* add/update deps [Cory Bennett] [[a2e36e8](https://github.com/Netflix-Skunkworks/go-jira/commit/a2e36e8)]
* add support for using socks proxy [onionjake] [[ff985f9](https://github.com/Netflix-Skunkworks/go-jira/commit/ff985f9)]
## 1.0.13 - 2017-10-28
* fix transition command [Cory Bennett] [[9597f9b](https://github.com/Netflix-Skunkworks/go-jira/commit/9597f9b)]
* fix default values to load after parsing configs [Cory Bennett] [[c9b5054](https://github.com/Netflix-Skunkworks/go-jira/commit/c9b5054)]
* add test to make sure IssueType.Fields does not disappear on regeneration [Cory Bennett] [[3966def](https://github.com/Netflix-Skunkworks/go-jira/commit/3966def)]
* add tests for validating changes to auto-generated jiradata files [Cory Bennett] [[41d1a7c](https://github.com/Netflix-Skunkworks/go-jira/commit/41d1a7c)]
* Fix typo in 'logout' command help [Cory Bennett] [[9000777](https://github.com/Netflix-Skunkworks/go-jira/commit/9000777)]
* Add URL escaping to an additional issuetype call [Cory Bennett] [[7bfa241](https://github.com/Netflix-Skunkworks/go-jira/commit/7bfa241)]
* Add --resolution option [Cory Bennett] [[e6600cf](https://github.com/Netflix-Skunkworks/go-jira/commit/e6600cf)]
* Create Metadata Not Populated Correctly [Dillon Buchanan] [[093c510](https://github.com/Netflix-Skunkworks/go-jira/commit/093c510)]
* add regexReplace template function [Dirk Heilig] [[d3e294e](https://github.com/Netflix-Skunkworks/go-jira/commit/d3e294e)]
## 1.0.12 - 2017-10-04
* add `{{env.VARNAME}}` template support to allow use of env vars [Cory Bennett] [[4d74554](https://github.com/Netflix-Skunkworks/go-jira/commit/4d74554)]
## 1.0.11 - 2017-09-26
* [[#115](https://github.com/Netflix-Skunkworks/go-jira/issues/115)] fix transition template for description [Cory Bennett] [[986cc78](https://github.com/Netflix-Skunkworks/go-jira/commit/986cc78)]
* update edit command to set queryFields on search to match what is used in template [Cory Bennett] [[3913726](https://github.com/Netflix-Skunkworks/go-jira/commit/3913726)]
* fix edit with query loop, allow continuation when not submitting previous issue [Cory Bennett] [[0ba8aa0](https://github.com/Netflix-Skunkworks/go-jira/commit/0ba8aa0)]
* fix edit when priority is not set [Cory Bennett] [[098eb99](https://github.com/Netflix-Skunkworks/go-jira/commit/098eb99)]
* flatten CommandRegistry list to make it more readable [Cory Bennett] [[2ddaed2](https://github.com/Netflix-Skunkworks/go-jira/commit/2ddaed2)]
## 1.0.10 - 2017-09-18
* clean up usage formatting, print aliases [Cory Bennett] [[9f433ac](https://github.com/Netflix-Skunkworks/go-jira/commit/9f433ac)]
* fix edit [Cory Bennett] [[4c6b36c](https://github.com/Netflix-Skunkworks/go-jira/commit/4c6b36c)]
* fix named query template expansion [Cory Bennett] [[a8eaa97](https://github.com/Netflix-Skunkworks/go-jira/commit/a8eaa97)]
* fix usage message [Cory Bennett] [[cd3cfd8](https://github.com/Netflix-Skunkworks/go-jira/commit/cd3cfd8)]
## 1.0.9 - 2017-09-17
* need issuetype to use the default list table template now [Cory Bennett] [[3e8b9bd](https://github.com/Netflix-Skunkworks/go-jira/commit/3e8b9bd)]
* [[#102](https://github.com/Netflix-Skunkworks/go-jira/issues/102)] add issuetype into the default queryfields and add it to the default `table` list template [Cory Bennett] [[c9d8dfb](https://github.com/Netflix-Skunkworks/go-jira/commit/c9d8dfb)]
## 1.0.8 - 2017-09-17
* [[#100](https://github.com/Netflix-Skunkworks/go-jira/issues/100)] add support for posting, fetching, listing and removing attachments [Cory Bennett] [[66eb7bf](https://github.com/Netflix-Skunkworks/go-jira/commit/66eb7bf)]
## 1.0.7 - 2017-09-15
* [[#87](https://github.com/Netflix-Skunkworks/go-jira/issues/87)] add various commands for interacting with epics [Cory Bennett] [[893454f](https://github.com/Netflix-Skunkworks/go-jira/commit/893454f)]
## 1.0.6 - 2017-09-13
* tweaks for templates in named queries to work better [Cory Bennett] [[00cba79](https://github.com/Netflix-Skunkworks/go-jira/commit/00cba79)]
* [[#99](https://github.com/Netflix-Skunkworks/go-jira/issues/99)] add support for named queries to be stored in configs [Cory Bennett] [[fb43753](https://github.com/Netflix-Skunkworks/go-jira/commit/fb43753)]
* [[#98](https://github.com/Netflix-Skunkworks/go-jira/issues/98)] add `--status` option for JQL filter on status with `list` command [Cory Bennett] [[5da04c1](https://github.com/Netflix-Skunkworks/go-jira/commit/5da04c1)]
## 1.0.5 - 2017-09-11
* use --gjq for GJson Query to filter json response data [Cory Bennett] [[608e586](https://github.com/Netflix-Skunkworks/go-jira/commit/608e586)]
* fix field tag syntax [Cory Bennett] [[2c552ac](https://github.com/Netflix-Skunkworks/go-jira/commit/2c552ac)]
* add '{{jira}}' template macro to refer to path of currently running jira command [Cory Bennett] [[941824d](https://github.com/Netflix-Skunkworks/go-jira/commit/941824d)]
## 1.0.4 - 2017-09-08
* update deps for kingpeon update use os.exec instead of syscall.exec for windows [Cory Bennett] [[86b963b](https://github.com/Netflix-Skunkworks/go-jira/commit/86b963b)]
## 1.0.3 - 2017-09-06
* [[#66](https://github.com/Netflix-Skunkworks/go-jira/issues/66)] add --started option to `jira worklog add` to change the start time for worklog [Cory Bennett] [[e6faee1](https://github.com/Netflix-Skunkworks/go-jira/commit/e6faee1)]
* [[#45](https://github.com/Netflix-Skunkworks/go-jira/issues/45)] automatically add comment to issue even if transition does not support comment updates during transtion [Cory Bennett] [[c4be59c](https://github.com/Netflix-Skunkworks/go-jira/commit/c4be59c)]
## 1.0.2 - 2017-09-06
* update dependencies [Cory Bennett] [[aa876cd](https://github.com/Netflix-Skunkworks/go-jira/commit/aa876cd)]
* update for github.com/AlecAivazis/survey => gopkg.in/AlecAivazis/survey.v1 package [Cory Bennett] [[9453179](https://github.com/Netflix-Skunkworks/go-jira/commit/9453179)]
* use stdout to determin output terminal size [Cory Bennett] [[4d79af4](https://github.com/Netflix-Skunkworks/go-jira/commit/4d79af4)]
## 1.0.1 - 2017-09-06
* [[#13](https://github.com/Netflix-Skunkworks/go-jira/issues/13)] change default input syntax to not require escaping for special characters [Cory Bennett] [[1106558](https://github.com/Netflix-Skunkworks/go-jira/commit/1106558)]
## 1.0.0 - 2017-09-05
* fix build for windows [Cory Bennett] [[1b854da](https://github.com/Netflix-Skunkworks/go-jira/commit/1b854da)]
* change the default log output format [Cory Bennett] [[f1b8c64](https://github.com/Netflix-Skunkworks/go-jira/commit/f1b8c64)]
* tweak auto-login so it does not print the standard `jira login` command output [Cory Bennett] [[49f6cdc](https://github.com/Netflix-Skunkworks/go-jira/commit/49f6cdc)]
* add --quiet global option [Cory Bennett] [[c226077](https://github.com/Netflix-Skunkworks/go-jira/commit/c226077)]
* refactor to allow for --insecure and --unixproxy arguments [Cory Bennett] [[c0358eb](https://github.com/Netflix-Skunkworks/go-jira/commit/c0358eb)]
* handle html response on expired cookies (require X-Ausername header to always be present) [Cory Bennett] [[21920c5](https://github.com/Netflix-Skunkworks/go-jira/commit/21920c5)]
* allow login prompt to be interrupted [Cory Bennett] [[7ab6c22](https://github.com/Netflix-Skunkworks/go-jira/commit/7ab6c22)]
* fmt -> log typo [Cory Bennett] [[bccf09f](https://github.com/Netflix-Skunkworks/go-jira/commit/bccf09f)]
* make ~/.jira.d directory if not already present [Cory Bennett] [[e72479c](https://github.com/Netflix-Skunkworks/go-jira/commit/e72479c)]
* fix go vet [Cory Bennett] [[e04b506](https://github.com/Netflix-Skunkworks/go-jira/commit/e04b506)]
* fix tests [Cory Bennett] [[ba35f55](https://github.com/Netflix-Skunkworks/go-jira/commit/ba35f55)]
* add OK printf [Cory Bennett] [[dc02181](https://github.com/Netflix-Skunkworks/go-jira/commit/dc02181)]
* change --method to use -M for backwards compat [Cory Bennett] [[b120c0b](https://github.com/Netflix-Skunkworks/go-jira/commit/b120c0b)]
* add resolution to dup'd issues when necessary [Cory Bennett] [[2638396](https://github.com/Netflix-Skunkworks/go-jira/commit/2638396)]
* call correct function for `labels remove|set` commands [Cory Bennett] [[ad1a62a](https://github.com/Netflix-Skunkworks/go-jira/commit/ad1a62a)]
* data argument is optional (for GET and DELETE requests) [Cory Bennett] [[4b60313](https://github.com/Netflix-Skunkworks/go-jira/commit/4b60313)]
* fix usage, overrides not serialized correctly [Cory Bennett] [[84119a2](https://github.com/Netflix-Skunkworks/go-jira/commit/84119a2)]
* fix `jira ISSUE-123` command line parsing [Cory Bennett] [[fa4ac25](https://github.com/Netflix-Skunkworks/go-jira/commit/fa4ac25)]
* add logger object to jiracmd [Cory Bennett] [[aed952b](https://github.com/Netflix-Skunkworks/go-jira/commit/aed952b)]
* refactor for GlobalOptions and CommonOptions [Cory Bennett] [[979da1f](https://github.com/Netflix-Skunkworks/go-jira/commit/979da1f)]
* move commands from jiracli package to jiracmd package [Cory Bennett] [[0a5510b](https://github.com/Netflix-Skunkworks/go-jira/commit/0a5510b)]
* use jiracli.Error object to disambiguate between kingpin errors and cli errors [Cory Bennett] [[fb1bfeb](https://github.com/Netflix-Skunkworks/go-jira/commit/fb1bfeb)]
* fix stray newline for list table template [Cory Bennett] [[36c26c5](https://github.com/Netflix-Skunkworks/go-jira/commit/36c26c5)]
* fix dynamic table output when not on tty [Cory Bennett] [[3942f6f](https://github.com/Netflix-Skunkworks/go-jira/commit/3942f6f)]
* when using --verbose set the JIRA_DEBUG environment variable so custom-commands can auto enable verbose output [Cory Bennett] [[da9a2b2](https://github.com/Netflix-Skunkworks/go-jira/commit/da9a2b2)]
* make `jira ISSUE-123` usage call `jira view ISSUE-123` [Cory Bennett] [[ec0858b](https://github.com/Netflix-Skunkworks/go-jira/commit/ec0858b)]
* integrate kingpeon library to allow for custom commands via configuration [Cory Bennett] [[301a61f](https://github.com/Netflix-Skunkworks/go-jira/commit/301a61f)]
* use terminal width to adjust list table output [Cory Bennett] [[2a081dd](https://github.com/Netflix-Skunkworks/go-jira/commit/2a081dd)]
* set yaml/json tags for option structs [Cory Bennett] [[f52d2c4](https://github.com/Netflix-Skunkworks/go-jira/commit/f52d2c4)]
* update generated data files [Cory Bennett] [[c89f11d](https://github.com/Netflix-Skunkworks/go-jira/commit/c89f11d)]
* automatically login when anonymous user detected [Cory Bennett] [[21add54](https://github.com/Netflix-Skunkworks/go-jira/commit/21add54)]
* refactor trivial objects in favor of arguments to static functions [Cory Bennett] [[1f345ce](https://github.com/Netflix-Skunkworks/go-jira/commit/1f345ce)]
* set JIRA_OPERATION when parsing configs. Use figtree config types for options to make defaulting work [Cory Bennett] [[5716a7c](https://github.com/Netflix-Skunkworks/go-jira/commit/5716a7c)]
* add better handing for usage error [Cory Bennett] [[b235dcc](https://github.com/Netflix-Skunkworks/go-jira/commit/b235dcc)]
* adding `request` command, removing dead code [Cory Bennett] [[56b1c9d](https://github.com/Netflix-Skunkworks/go-jira/commit/56b1c9d)]
* adding Do required for request language [Cory Bennett] [[a1c2849](https://github.com/Netflix-Skunkworks/go-jira/commit/a1c2849)]
* add `browse` command and implement -b option for most operations [Cory Bennett] [[a91b9d5](https://github.com/Netflix-Skunkworks/go-jira/commit/a91b9d5)]
* fix IssueAssign [Cory Bennett] [[f32cc70](https://github.com/Netflix-Skunkworks/go-jira/commit/f32cc70)]
* merge in update for upstream changes [#104](https://github.com/Netflix-Skunkworks/go-jira/issues/104) [Cory Bennett] [[19d8686](https://github.com/Netflix-Skunkworks/go-jira/commit/19d8686)]
* add `export-templates` command [Cory Bennett] [[abaad56](https://github.com/Netflix-Skunkworks/go-jira/commit/abaad56)]
* add `issuetypes` command [Cory Bennett] [[da39323](https://github.com/Netflix-Skunkworks/go-jira/commit/da39323)]
* add `components` command [Cory Bennett] [[0bd3ca2](https://github.com/Netflix-Skunkworks/go-jira/commit/0bd3ca2)]
* add `component add` command [Cory Bennett] [[cc90610](https://github.com/Netflix-Skunkworks/go-jira/commit/cc90610)]
* add `take`, `unassign` and `assign|give` commands [Cory Bennett] [[959524a](https://github.com/Netflix-Skunkworks/go-jira/commit/959524a)]
* adding `labels [add|set|remove]` commands [Cory Bennett] [[9161861](https://github.com/Netflix-Skunkworks/go-jira/commit/9161861)]
* add `comment` command [Cory Bennett] [[f0b08c5](https://github.com/Netflix-Skunkworks/go-jira/commit/f0b08c5)]
* add `watch` command [Cory Bennett] [[ec0ac3c](https://github.com/Netflix-Skunkworks/go-jira/commit/ec0ac3c)]
* add `rank ISSUE after|before ISSUE` command [Cory Bennett] [[8b863d2](https://github.com/Netflix-Skunkworks/go-jira/commit/8b863d2)]
* add `vote` command [Cory Bennett] [[a08c92f](https://github.com/Netflix-Skunkworks/go-jira/commit/a08c92f)]
* add `issuelinktypes` command [Cory Bennett] [[37f81a4](https://github.com/Netflix-Skunkworks/go-jira/commit/37f81a4)]
* add `issuelink` command [Cory Bennett] [[aacc9f4](https://github.com/Netflix-Skunkworks/go-jira/commit/aacc9f4)]
* fix closing duplicate issue on `dup` command [Cory Bennett] [[fc696c3](https://github.com/Netflix-Skunkworks/go-jira/commit/fc696c3)]
* rewrite checkpoint [Cory Bennett] [[36632a5](https://github.com/Netflix-Skunkworks/go-jira/commit/36632a5)]
## 0.1.14 - 2017-05-10
* fix unsafe casting for --quiet flag [Cory Bennett] [[6f29f43](https://github.com/Netflix-Skunkworks/go-jira/commit/6f29f43)]
* [[#80](https://github.com/Netflix-Skunkworks/go-jira/issues/80)] add `jira unassign` and `jira give ISSUE --default` commands [Cory Bennett] [[03d8633](https://github.com/Netflix-Skunkworks/go-jira/commit/03d8633)]
## 0.1.13 - 2017-04-24
* work around `github.com/tmc/keyring` compile error for windows [Cory Bennett] [[85298e9](https://github.com/Netflix-Skunkworks/go-jira/commit/85298e9)]
* Added generic issuelink command [David Reuss] [[cc54d11](https://github.com/Netflix-Skunkworks/go-jira/commit/cc54d11)]
* Added --start parameter for pagination on results [David Reuss] [[9b94d9e](https://github.com/Netflix-Skunkworks/go-jira/commit/9b94d9e)]
## 0.1.12 - 2017-03-22
* Implement "browse" subcommand on Windows [Claus Brod] [[ca333d8](https://github.com/Netflix-Skunkworks/go-jira/commit/ca333d8)]
## 0.1.11 - 2017-02-26
* [[#69](https://github.com/Netflix-Skunkworks/go-jira/issues/69)] add subtask command [Cory Bennett] [[21a2ed5](https://github.com/Netflix-Skunkworks/go-jira/commit/21a2ed5)]
## 0.1.10 - 2017-02-08
* set GPG_TTY in .bashrc [Cory Bennett] [[b1e552f](https://github.com/Netflix-Skunkworks/go-jira/commit/b1e552f)]
* force password in case password already exists [Cory Bennett] [[d5a2c3b](https://github.com/Netflix-Skunkworks/go-jira/commit/d5a2c3b)]
* refactor password source, allow for "pass" to be used, update tests to use `password-source: pass` [Cory Bennett] [[5a71939](https://github.com/Netflix-Skunkworks/go-jira/commit/5a71939)]
## 0.1.9 - 2016-12-18
* only warn about needing login when not already running the login command [Cory Bennett] [[6c24e55](https://github.com/Netflix-Skunkworks/go-jira/commit/6c24e55)]
* fix(http): Add proxy transport [William Hearn] [[4bd740b](https://github.com/Netflix-Skunkworks/go-jira/commit/4bd740b)] [[2dff6c9](https://github.com/Netflix-Skunkworks/go-jira/commit/2dff6c9)]
## 0.1.8 - 2016-11-24
* [[#12](https://github.com/Netflix-Skunkworks/go-jira/issues/12)] integrate with keyring for password storage and provide http basic auth credentials for every request since most jira services have websudo enabled with does not allow cookie based authentication [Cory Bennett] [[b8a6e57](https://github.com/Netflix-Skunkworks/go-jira/commit/b8a6e57)]
* Cleaning up usage [Jay Shirley] [[8add52b](https://github.com/Netflix-Skunkworks/go-jira/commit/8add52b)]
* Update usage [Jay Shirley] [[b56e32a](https://github.com/Netflix-Skunkworks/go-jira/commit/b56e32a)]
* use gopkg.in for links to maintain version compatibility [Cory Bennett] [[1414d1f](https://github.com/Netflix-Skunkworks/go-jira/commit/1414d1f)]
* golint [Cory Bennett] [[44cdebf](https://github.com/Netflix-Skunkworks/go-jira/commit/44cdebf)]
* add "rank" command allow ordering backlog issues in agile projects [Cory Bennett] [[e4cc9c6](https://github.com/Netflix-Skunkworks/go-jira/commit/e4cc9c6)]
* Adding a unixproxy mechanism [Jay Shirley] [[5b9c0dd](https://github.com/Netflix-Skunkworks/go-jira/commit/5b9c0dd)]
## 0.1.7 - 2016-08-24
* Prefer transition names which match exactly [Don Brower] [[e40f9c1](https://github.com/Netflix-Skunkworks/go-jira/commit/e40f9c1)]
* update tempates to make them more readable with space trimming added to go-1.6 [Cory Bennett] [[693b3e4](https://github.com/Netflix-Skunkworks/go-jira/commit/693b3e4)]
## 0.1.6 - 2016-08-21
* make "worklogs" command print output through template allow "add worklog" command to open edit template [Cory Bennett] [[cc3fbee](https://github.com/Netflix-Skunkworks/go-jira/commit/cc3fbee)]
* remove extra newline at end of worklogs template [Cory Bennett] [[d08ef15](https://github.com/Netflix-Skunkworks/go-jira/commit/d08ef15)]
* adding worklog related templates [Cory Bennett] [[ab1cd27](https://github.com/Netflix-Skunkworks/go-jira/commit/ab1cd27)]
## 0.1.5 - 2016-08-21
* update for golint [Cory Bennett] [[5a4e17c](https://github.com/Netflix-Skunkworks/go-jira/commit/5a4e17c)]
* fix for go vet [Cory Bennett] [[355fb42](https://github.com/Netflix-Skunkworks/go-jira/commit/355fb42)]
## 0.1.4 - 2016-08-12
* when running "dups" on a Process Management Project type, you have to start/stop the task to resolve it [Cory Bennett] [[2c91905](https://github.com/Netflix-Skunkworks/go-jira/commit/2c91905)]
* allow for defaultResolution option for transition command [Cory Bennett] [[a328c2d](https://github.com/Netflix-Skunkworks/go-jira/commit/a328c2d)]
* add "backlog" command for Kanban related Issues [Cory Bennett] [[5d39b23](https://github.com/Netflix-Skunkworks/go-jira/commit/5d39b23)]
* fix --noedit flag with "dups" command [Cory Bennett] [[37c07fa](https://github.com/Netflix-Skunkworks/go-jira/commit/37c07fa)]
* add "votes" and "labels" to default view template [Cory Bennett] [[6f73b8c](https://github.com/Netflix-Skunkworks/go-jira/commit/6f73b8c)]
* add "blockerType" config param, for issueLinkType use for "blocks" command [Cory Bennett] [[30fd301](https://github.com/Netflix-Skunkworks/go-jira/commit/30fd301)]
* update gitter room [Cory Bennett] [[4b822b1](https://github.com/Netflix-Skunkworks/go-jira/commit/4b822b1)]
* default issuetype to "Bug" for project that have Bug, otherwise try "Task" [Cory Bennett] [[0c807b4](https://github.com/Netflix-Skunkworks/go-jira/commit/0c807b4)]
* make view template only show fields that have values [Cory Bennett] [[8238fe8](https://github.com/Netflix-Skunkworks/go-jira/commit/8238fe8)]
* make default create template only display fields if they are valid fields for the project [Cory Bennett] [[adc2ace](https://github.com/Netflix-Skunkworks/go-jira/commit/adc2ace)]
* ignore empty json fields when processing templates [Cory Bennett] [[f5f3e28](https://github.com/Netflix-Skunkworks/go-jira/commit/f5f3e28)]
* allow JIRA_LOG_FORMAT env variable to control log output format [Cory Bennett] [[469def0](https://github.com/Netflix-Skunkworks/go-jira/commit/469def0)]
* remove extraneous debug [Cory Bennett] [[752a94d](https://github.com/Netflix-Skunkworks/go-jira/commit/752a94d)]
* add logout command modify password prompt to echo masked password [Cory Bennett] [[8ad91be](https://github.com/Netflix-Skunkworks/go-jira/commit/8ad91be)]
* tweak cookies to store hostname dump all http request/response with --verbose [Cory Bennett] [[f93fe79](https://github.com/Netflix-Skunkworks/go-jira/commit/f93fe79)]
* load configs in order of closest to cwd (/etc/go-jira.yml is last) [Cory Bennett] [[f54267b](https://github.com/Netflix-Skunkworks/go-jira/commit/f54267b)]
## 0.1.3 - 2016-07-30
* [[#43](https://github.com/Netflix-Skunkworks/go-jira/issues/43)] add support for jira done|todo|prog commands [Cory Bennett] [[dd7d1cc](https://github.com/Netflix-Skunkworks/go-jira/commit/dd7d1cc)]
* Reporter is not generally editable. [Mike Pountney] [[a637b43](https://github.com/Netflix-Skunkworks/go-jira/commit/a637b43)]
## 0.1.2 - 2016-06-29
* [[#44](https://github.com/Netflix-Skunkworks/go-jira/issues/44)] Close tmpfile before rename to work around "The process cannot access the file because it is being used by another process" error on windows. [Cory Bennett] [[0980f8e](https://github.com/Netflix-Skunkworks/go-jira/commit/0980f8e)]
## 0.1.1 - 2016-06-28
* use USERPROFILE instead of HOME for windows, rework paths to use filepath.Join for better cross platform support [Cory Bennett] [[adcedc4](https://github.com/Netflix-Skunkworks/go-jira/commit/adcedc4)]
* Include templates from a system path [Mike Pountney] [[cf10f53](https://github.com/Netflix-Skunkworks/go-jira/commit/cf10f53)]
* Added support for the ```expand``` option for Issues [tobyjoe] [[fb4afc9](https://github.com/Netflix-Skunkworks/go-jira/commit/fb4afc9)]
* change for api changes to go-logging [Cory Bennett] [[7bfc6e8](https://github.com/Netflix-Skunkworks/go-jira/commit/7bfc6e8)]
* Fix issuetype calls adding URL escaping [Jonathan Wright] [[e4a25e2](https://github.com/Netflix-Skunkworks/go-jira/commit/e4a25e2)]
## 0.1.0 - 2016-01-29
* Fixes [#32](https://github.com/Netflix-Skunkworks/go-jira/issues/32) - make path to cookieFile if it's not present [Mike Pountney] [[6644579](https://github.com/Netflix-Skunkworks/go-jira/commit/6644579)]
* Add component/components support: add and list for now. [Mike Pountney] [[d7b3226](https://github.com/Netflix-Skunkworks/go-jira/commit/d7b3226)]
* Tweak the CmdWatch contract and add watcher remove support [Mike Pountney] [[383847a](https://github.com/Netflix-Skunkworks/go-jira/commit/383847a)]
* Amend vote/unvote to be vote/vote --down [Mike Pountney] [[797edef](https://github.com/Netflix-Skunkworks/go-jira/commit/797edef)]
* Add 'vote' and 'unvote' [Mike Pountney] [[c95e66e](https://github.com/Netflix-Skunkworks/go-jira/commit/c95e66e)]
## 0.0.20 - 2016-01-21
* [issue [#28](https://github.com/Netflix-Skunkworks/go-jira/issues/28)] check to make sure we got back issuetypes for create metadata [Cory Bennett] [[ee0e780](https://github.com/Netflix-Skunkworks/go-jira/commit/ee0e780)]
* Add insecure option for TLS endpoints [Brian Lalor] [[6a88bb9](https://github.com/Netflix-Skunkworks/go-jira/commit/6a88bb9)]
* Correct naming of parameter: set/add/remove are actions. [Mike Pountney] [[303784f](https://github.com/Netflix-Skunkworks/go-jira/commit/303784f)]
* Tweak CmdLabels args so that magic happens with CLI [Mike Pountney] [[40a7c65](https://github.com/Netflix-Skunkworks/go-jira/commit/40a7c65)]
* Expose ViewTicket as per FindIssues [Mike Pountney] [[8977f3d](https://github.com/Netflix-Skunkworks/go-jira/commit/8977f3d)]
* Add exposed versions of getTemplate and runTemplate [Mike Pountney] [[da6cbd5](https://github.com/Netflix-Skunkworks/go-jira/commit/da6cbd5)]
* Add 'labels' command to set/add/remove labels [Mike Pountney] [[230b52d](https://github.com/Netflix-Skunkworks/go-jira/commit/230b52d)]
* Add a 'join' func to the template engine [Mike Pountney] [[a7820fe](https://github.com/Netflix-Skunkworks/go-jira/commit/a7820fe)]
* make "jira" golang package, move code from jira/cli to root, move jira/main.go to main/main.go [Cory Bennett] [[7268b9e](https://github.com/Netflix-Skunkworks/go-jira/commit/7268b9e)]
## 0.0.19 - 2015-12-09
* fix jira trans TRANS ISSUE (case sensitivity issue), also go fmt [Cory Bennett] [[3c30f3b](https://github.com/Netflix-Skunkworks/go-jira/commit/3c30f3b)]
## 0.0.18 - 2015-12-03
* need to default "quiet" to false [Cory Bennett] [[4f4a89b](https://github.com/Netflix-Skunkworks/go-jira/commit/4f4a89b)]
## 0.0.17 - 2015-12-03
* add --quiet command to not print the OK .. add --saveFile option to print the issue/link to a file on create command [Cory Bennett] [[c9ac162](https://github.com/Netflix-Skunkworks/go-jira/commit/c9ac162)]
* fix overrides [Cory Bennett] [[eaddfe6](https://github.com/Netflix-Skunkworks/go-jira/commit/eaddfe6)]
* add abstract request wrapper to allow you to access/process random apis supported by Jira but not yet supported by go-jira [Cory Bennett] [[90ef56a](https://github.com/Netflix-Skunkworks/go-jira/commit/90ef56a)]
## 0.0.16 - 2015-11-23
* jira edit should not require one arguemnt (allow for --query) [Cory Bennett] [[a1eb4a1](https://github.com/Netflix-Skunkworks/go-jira/commit/a1eb4a1)]
## 0.0.15 - 2015-11-23
* [[#17](https://github.com/Netflix-Skunkworks/go-jira/issues/17)] print usage on missing arguments [Cory Bennett] [[fd2a2fe](https://github.com/Netflix-Skunkworks/go-jira/commit/fd2a2fe)]
## 0.0.14 - 2015-11-17
* s/enpoint/endpoint/g [Oliver Schrenk] [[c5d251d](https://github.com/Netflix-Skunkworks/go-jira/commit/c5d251d)]
* Implement dateFormat template command [Mike Pountney] [[68d3bae](https://github.com/Netflix-Skunkworks/go-jira/commit/68d3bae)]
* Add 'updated' field to default queryfields. [Mike Pountney] [[91e2475](https://github.com/Netflix-Skunkworks/go-jira/commit/91e2475)]
* Fix export-templates option (typo) [Mike Pountney] [[4d7fdb8](https://github.com/Netflix-Skunkworks/go-jira/commit/4d7fdb8)]
* when yaml element resolves to "\n" strip it out so we dont post it to jira [Cory Bennett] [[47ced2f](https://github.com/Netflix-Skunkworks/go-jira/commit/47ced2f)]
* print PUT/POST data when using --dryrun to help debug [Cory Bennett] [[618f245](https://github.com/Netflix-Skunkworks/go-jira/commit/618f245)]
## 0.0.13 - 2015-09-19
* replace dead/deprecated code.google.com/p/gopass with golang.org/x/crypto/ssh/terminal for reading password from stdin [Cory Bennett] [[909eb06](https://github.com/Netflix-Skunkworks/go-jira/commit/909eb06)]
## 0.0.12 - 2015-09-18
* fix exception from "jira create" [Cory Bennett] [[9348a4b](https://github.com/Netflix-Skunkworks/go-jira/commit/9348a4b)]
* add some debug messages to help diagnose login failures [Cory Bennett] [[1c08a7d](https://github.com/Netflix-Skunkworks/go-jira/commit/1c08a7d)]
## 0.0.11 - 2015-09-16
* add --version [Cory Bennett] [[8385ee2](https://github.com/Netflix-Skunkworks/go-jira/commit/8385ee2)]
* fix command line parser broken in 0.0.10 [Cory Bennett] [[15ae929](https://github.com/Netflix-Skunkworks/go-jira/commit/15ae929)]
## 0.0.10 - 2015-09-15
* allow for command aliasing in conjunction with executable config files. Issue #5 [Cory Bennett] [[23590d4](https://github.com/Netflix-Skunkworks/go-jira/commit/23590d4)]
* update usage [Cory Bennett] [[ef7a57e](https://github.com/Netflix-Skunkworks/go-jira/commit/ef7a57e)]
## 0.0.9 - 2015-09-15
* use forked yaml.v2 so as to not lose line terminations present in jira fields [Cory Bennett] [[f84e77f](https://github.com/Netflix-Skunkworks/go-jira/commit/f84e77f)]
* adding a |~ literal yaml syntax to just chomp a single newline (again to preserve existing formatting in jira fields) [Cory Bennett] [[f84e77f](https://github.com/Netflix-Skunkworks/go-jira/commit/f84e77f)]
* for indent/comment allow for unicode line termination characters that yaml will use for parsing [Cory Bennett] [[f84e77f](https://github.com/Netflix-Skunkworks/go-jira/commit/f84e77f)]
* fix "edit" default option, change how defaults are dealt with for filters [Cory Bennett] [[4265913](https://github.com/Netflix-Skunkworks/go-jira/commit/4265913)]
* for edit template add issue id as comment, also add "comments" as comment so you can review the comment details while editing [Cory Bennett] [[968a9df](https://github.com/Netflix-Skunkworks/go-jira/commit/968a9df)]
* add "comment" template filter to comment out multiline statements [Cory Bennett] [[d664868](https://github.com/Netflix-Skunkworks/go-jira/commit/d664868)]
* add getOpt wrappers to get options with defaults [Cory Bennett] [[c0070cf](https://github.com/Netflix-Skunkworks/go-jira/commit/c0070cf)]
* make --dryrun work [Cory Bennett] [[d229ac1](https://github.com/Netflix-Skunkworks/go-jira/commit/d229ac1)]
* refactor config/option loading so command options override settings in config files [Cory Bennett] [[d229ac1](https://github.com/Netflix-Skunkworks/go-jira/commit/d229ac1)]
* allow query options to be used on the "edit" command to iterate editing [Cory Bennett] [[d229ac1](https://github.com/Netflix-Skunkworks/go-jira/commit/d229ac1)]
* remove duplication for defaults [Cory Bennett] [[f8c8ddf](https://github.com/Netflix-Skunkworks/go-jira/commit/f8c8ddf)]
* use optigo for option parsing, drop docopt [Cory Bennett] [[7bbd571](https://github.com/Netflix-Skunkworks/go-jira/commit/7bbd571)]
* allow "abort: true" to be set while editing to cancel the edit operation [Cory Bennett] [[ea67a77](https://github.com/Netflix-Skunkworks/go-jira/commit/ea67a77)]
* if no changes are made on edit templates then abort edit [Cory Bennett] [[e69b65c](https://github.com/Netflix-Skunkworks/go-jira/commit/e69b65c)]
## 0.0.8 - 2015-07-31
* Add --max_results option for 'ls' [Mike Pountney] [[e06ff0c](https://github.com/Netflix-Skunkworks/go-jira/commit/e06ff0c)]
## 0.0.7 - 2015-07-01
* fix "take" command not honouring user option [Andrew Haigh] [[8f1d2b9](https://github.com/Netflix-Skunkworks/go-jira/commit/8f1d2b9)]
* fix typo [Cory Bennett] [[06f57fe](https://github.com/Netflix-Skunkworks/go-jira/commit/06f57fe)]
## 0.0.6 - 2015-02-27
* allow --sort= to disable sort override [Cory Bennett] [[701f091](https://github.com/Netflix-Skunkworks/go-jira/commit/701f091)]
* fix default JIRA_OPERATION env variable [Cory Bennett] [[82fd9b9](https://github.com/Netflix-Skunkworks/go-jira/commit/82fd9b9)]
* automatically close duplicate issues with "Duplicate" resolution [Cory Bennett] [[ebf1700](https://github.com/Netflix-Skunkworks/go-jira/commit/ebf1700)]
* set JIRA_OPERATION to "view" when no operation used (ie: jira GOJIRA-123) [Cory Bennett] [[050848a](https://github.com/Netflix-Skunkworks/go-jira/commit/050848a)]
* add --sort option to "list" command [Cory Bennett] [[f359030](https://github.com/Netflix-Skunkworks/go-jira/commit/f359030)]
## 0.0.5 - 2015-02-21
* handle editor having arguments [Cory Bennett] [[7186fb3](https://github.com/Netflix-Skunkworks/go-jira/commit/7186fb3)]
* add more template error handling [Cory Bennett] [[3e6f2b3](https://github.com/Netflix-Skunkworks/go-jira/commit/3e6f2b3)]
* allow create template to specify defalt watchers with -o watchers=... [Cory Bennett] [[4db2e4e](https://github.com/Netflix-Skunkworks/go-jira/commit/4db2e4e)]
* if config files are executable then run them and parse the output [Cory Bennett] [[7a2f7f5](https://github.com/Netflix-Skunkworks/go-jira/commit/7a2f7f5)]
## 0.0.4 - 2015-02-19
* add --template option to export-templates to export a single template [Cory Bennett] [[343fbb6](https://github.com/Netflix-Skunkworks/go-jira/commit/343fbb6)]
* add "table" template to be used with "list" command [Cory Bennett] [[8954ec1](https://github.com/Netflix-Skunkworks/go-jira/commit/8954ec1)]
## 0.0.3 - 2015-02-19
* [issue [#8](https://github.com/Netflix-Skunkworks/go-jira/issues/8)] detect X-Seraph-Loginreason: AUTHENTICATION_DENIED header to catch login failures [Cory Bennett] [[2dcf665](https://github.com/Netflix-Skunkworks/go-jira/commit/2dcf665)]
* project should always be uppercase [Jay Buffington] [[1b69d12](https://github.com/Netflix-Skunkworks/go-jira/commit/1b69d12)]
* if response is 400, check json for errorMessages and log them [Jay Buffington] [[4924dfa](https://github.com/Netflix-Skunkworks/go-jira/commit/4924dfa)]
* validate project [Jay Buffington] [[dc5ae42](https://github.com/Netflix-Skunkworks/go-jira/commit/dc5ae42)]
## 0.0.2 - 2015-02-18
* add missing --override options on transition command
* add browse command
## 0.0.1 - 2015-02-18
* Initial experimental release
+83 -36
View File
@@ -1,54 +1,101 @@
PLATFORMS= \
freebsd-386 \
freebsd-amd64 \
freebsd-arm \
linux-386 \
linux-amd64 \
linux-arm \
openbsd-386 \
openbsd-amd64 \
windows-386 \
windows-amd64 \
darwin-386 \
darwin-amd64 \
$(NULL)
NAME=jira
GO?=go
DIST=$(shell pwd)/dist
export GOPATH=$(shell pwd)
OS=$(shell uname -s)
ifeq ($(filter CYGWIN%,$(OS)),$(OS))
export CWD=$(shell cygpath -wa .)
export SEP=\\
export CYGWIN=winsymlinks:native
BIN ?= $(GOBIN)$(SEP)$(NAME).exe
else
export CWD=$(shell pwd)
export SEP=/
BIN ?= $(GOBIN)$(SEP)$(NAME)
endif
DIST=$(CWD)$(SEP)dist
GOBIN ?= $(CWD)
CURVER ?= $(patsubst v%,%,$(shell [ -d .git ] && git describe --abbrev=0 --tags || grep ^\#\# CHANGELOG.md | awk '{print $$2; exit}'))
LDFLAGS:= -w
VERSION ?= development
build:
cd src/github.com/Netflix-Skunkworks/go-jira/jira; \
go get -v
$(GO) build -gcflags="-e" -v -ldflags "$(LDFLAGS) -s" -o '$(BIN)' cmd/jira/main.go
vet:
@$(GO) vet .
@$(GO) vet ./jiracli
@$(GO) vet ./jiracmd
@$(GO) vet ./jiradata
@$(GO) vet ./cmd/jira
lint:
@$(GO) get github.com/golang/lint/golint
@golint .
@golint ./jiracli
@golint ./jiracmd
@golint ./jiradata
@golint ./cmd/jira
all:
mkdir -p $(DIST); \
cd src/github.com/Netflix-Skunkworks/go-jira/jira; \
go get -d; \
for p in $(PLATFORMS); do \
echo "Building for $$p"; \
GOOS=$${p/-*/} GOARCH=$${p/*-/} go build -v -o $(DIST)/jira-$$p; \
done
GO111MODULE=off $(GO) get -u github.com/mitchellh/gox
rm -rf dist
mkdir -p dist
gox -ldflags="-w -s" -ldflags="-X 'github.com/go-jira/jira.VERSION=$(VERSION)'" -output="dist/github.com/go-jira/jira-{{.OS}}-{{.Arch}}" -osarch="darwin/amd64 linux/386 linux/amd64 windows/386 windows/amd64" ./cmd/jira
fmt:
gofmt -s -w jira
install:
${MAKE} GOBIN=$$HOME/bin build
CURVER := $(shell grep '\#\#' CHANGELOG.md | awk '{print $$2; exit}')
NEWVER := $(shell awk -F'"' '/docopt.Parse/{print $$2}' jira/main.go)
NEWVER ?= $(shell echo $(CURVER) | awk -F. '{print $$1"."$$2"."$$3+1}')
TODAY := $(shell date +%Y-%m-%d)
changes:
@git log --pretty=format:"* %s [%cn] [%h]" --no-merges ^$(CURVER) HEAD jira | grep -v gofmt | grep -v "bump version"
@git log --pretty=format:"* %s [%cn] [%h]" --no-merges ^v$(CURVER) HEAD *.go jiracli/*.go jiradata/*.go jiracmd/*.go cmd/*/*.go *.lock | grep -vE 'gofmt|go fmt|version bump'
update-changelog:
update-changelog:
@echo "# Changelog" > CHANGELOG.md.new; \
echo >> CHANGELOG.md.new; \
echo "## $(NEWVER) - $(TODAY)" >> CHANGELOG.md.new; \
echo >> CHANGELOG.md.new; \
$(MAKE) changes | \
$(MAKE) --no-print-directory --silent changes | \
perl -pe 's{\[([a-f0-9]+)\]}{[[$$1](https://github.com/Netflix-Skunkworks/go-jira/commit/$$1)]}g' | \
perl -pe 's{\#(\d+)}{[#$$1](https://github.com/Netflix-Skunkworks/go-jira/issues/$$1)}g' >> CHANGELOG.md.new; \
tail +2 CHANGELOG.md >> CHANGELOG.md.new; \
mv CHANGELOG.md.new CHANGELOG.md
tail -n +2 CHANGELOG.md >> CHANGELOG.md.new; \
perl -pi -e 's{VERSION = "$(CURVER)"}{VERSION = "$(NEWVER)"}' jira.go; \
mv CHANGELOG.md.new CHANGELOG.md; \
$(NULL)
# https://github.com/Netflix-Skunkworks/go-jira/commit/d5330fd
# [#1349](https://github.com/bower/bower/issues/1349)
update-usage:
@perl -pi -e 'undef $$/; s|\n```\nusage.*?```|"\n```\n".qx{./jira --help}."```"|esg' README.md
release:
make update-usage
git diff --exit-code --quiet README.md || git commit -m "Updated Usage" README.md
git commit -m "Updated Changelog" CHANGELOG.md
git commit -m "version bump" jira.go
git tag v$(NEWVER)
git push --tags
version:
@echo $(CURVER)
clean: clean-password-store
rm -rf ./$(NAME)
clean-password-store:
rm -f "$(CWD)/_t/.password-store/GoJira/api-token:gojira@corybennett.org.gpg"
rm -f "$(CWD)/_t/.password-store/GoJira/api-token:mothra@corybennett.org.gpg"
test-password-store:
ln -s "api-token__gojira@corybennett.org.gpg" "$(CWD)/_t/.password-store/GoJira/api-token:gojira@corybennett.org.gpg"
ln -s "api-token__mothra@corybennett.org.gpg" "$(CWD)/_t/.password-store/GoJira/api-token:mothra@corybennett.org.gpg"
prove: test-password-store
chmod -R g-rwx,o-rwx $(CWD)/_t/.gnupg
OSHT_VERBOSE=1 prove -v _t/*.t
generate:
cd schemas && ./fetch-schemas.py
grep -h slipscheme jiradata/*.go | grep json | sort | uniq | awk -F\/\/ '{print $$2}' | while read cmd; do $$cmd; done
+338 -135
View File
@@ -1,109 +1,57 @@
[![Build Status](https://travis-ci.org/go-jira/jira.svg?branch=master)](https://travis-ci.org/go-jira/jira)
[![GoDoc](https://godoc.org/github.com/go-jira/jira?status.svg)](https://godoc.org/github.com/go-jira/jira)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
# go-jira
simple command line client for Atlassian's Jira service written in Go
## Synopsis
Simple command line client for Atlassian's Jira service written in Go.
```bash
jira ls -p GOJIRA # list all unresolved issues for project GOJRIA
jira ls -p GOJIRA -a mothra # as above also assigned to user mothra
jira ls -p GOJIRA -w mothra # lists GOJIRA unresolved issues watched by user mothra
jira ls -p GOJIRA -r mothra # list GOJIRA unresolved issues reported by user mothra
jira ls -t table -p GOJIRA # list all unresolved issues in pretty table output
## GDPR USERNAME DISCLAIMER
jira view GOJIRA-321 # print Issue using "view" template
jira GOJIRA-321 # same as above
When this tool was initial written the "username" parameter was widely used in the Atlassian API.
Due to GDPR restrictions this parameter was been almost completely phased out other then V1 login.
The "--user" field is still provided as a default global, however moving forward any usage of this field should be phased out in favor of the "--login" option.
jira edit GOJIRA-321 # open up the issue in an editor, when you exit the
# editor the issue will post the updates to the server
Commands which previously took a username will now expect an email address such as watch, create, assign, etc...
# edit the issue, using the overirdes on the command line, skip the interactive editor:
jira edit GOJIRA-321 --noedit \
-o assignee=mothra \
-o comment="mothra, please take care of this." \
-o priority=Major
## Install
jira create -p GOJIRA # create new "Bug" type issue for project GOJIRA
jira create -p GOJIRA -i Task # create new Task type issue
### Download
jira trans close GOJIRA-321 # close issue, with interactive editor to set fields
jira close GOJIRA-321 --edit # same as above
You can download one of the pre-built binaries for **go-jira** [here](https://github.com/go-jira/jira/releases).
# close the issue, set the resolution, and skip interactive editor:
jira trans close GOJIRA-321 -o resolution="Won't Fix" --noedit
# same as above
jira close GOJIRA-321 -o resolution="Won't Fix"
### Build
jira repopen GOJIRA-321 -m "reopening" # reopen issue
You can build and install the official repository with [Go](https://golang.org/dl/) (before running the below command, ensure you have `GO111MODULE=on` set in your environment):
jira watch GOJIRA-321 # add self as watcher to the issue
go get github.com/go-jira/jira/cmd/jira
jira comment GOJIRA-321 -m "done yet?" # add comment to the issue
This will checkout this repository into `$GOPATH/src/github.com/go-jira/jira/`, build, and install it.
jira take GOJIRA-321 # assign issue to self
It should then be available in $GOPATH/bin/jira.
jira give GOJIRA-321 mothra # assign issue to user mothra
## Usage
# create local project config to set defaults
mkdir .jira.d
echo "project: GOJIRA" > .jira.d/config.yml
jira ls # list all unresolved issues for project GOJRIA
jira ls -a mothra # as above also assigned to user mothra
jira ls -w mothra # lists GOJIRA unresolved issues watched by user mothra
jira ls -r mothra # list GOJIRA unresolved issues reported by user mothra
jira ls -t table # list all unresolved issues in pretty table output
#### Setting up TAB completion
jira create # create new "Bug" type issue for project GOJIRA
jira create -i Task # create new Task type issue
Since go-jira is built with the "kingpin" golang command line library we support bash/zsh shell completion automatically:
# make the table template your default "list" template:
jira export-templates -t table
mv $HOME/.jira.d/templates/table $HOME/.jira.d/templates/list
```
* <https://github.com/alecthomas/kingpin/tree/v2.2.5#bashzsh-shell-completion>
## Download
For example, in bash, adding something along the lines of:
You can download one of the pre-built binaries for **go-jira** [here](https://github.com/Netflix-Skunkworks/go-jira/releases).
`eval "$(jira --completion-script-bash)"`
## Build
* **NOTE** You will need **`go-1.4.1`** minimum
* If you do not have a **GOPATH** setup, these are simple build steps:
```bash
git clone git@github.com:Netflix-Skunkworks/go-jira.git
cd go-jira
export GOPATH=$(pwd)
export GOBIN=$GOPATH/bin
export PATH=$GOBIN:$PATH
cd src/github.com/Netflix-Skunkworks/go-jira/jira
go get -v
```
* If you do have a **GOPATH** setup, these are the standard steps to build:
```
cd $GOPATH
git clone git@github.com:Netflix-Skunkworks/go-jira.git src/github.com/Netflix-Skunkworks/go-jira
cd src/github.com/Netflix-Skunkworks/go-jira/jira
go get -v
```
to your bashrc, or .profile (assuming go-jira binary is already in your path) will cause jira to offer tab completion behavior.
## Configuration
**go-jira** uses a configuration hierarchy. When loading the configuration from disk it will recursively look through
all parent directories in your current path looking for a **.jira.d** directory. If your current directory is not
a child directory of your homedir, then your homedir will also be inspected for a **.jira.d** directory. From all of **.jira.d** directories
discovered **go-jira** will load a **config.yml** if found. The configuration properties found in a file closests to your current working directory
will have precedence. Properties overriden with command line options will have final precedence.
**go-jira** uses a configuration hierarchy. When loading the configuration from disk it will recursively look through all parent directories in your current path looking for a **.jira.d** directory. If your current directory is not a child directory of your homedir, then your homedir will also be inspected for a **.jira.d** directory. From all of **.jira.d** directories discovered **go-jira** will load a **&lt;command&gt;.yml** file (ie for `jira list` it will load `.jira.d/list.yml`) then it will merge in any properties from the **config.yml** if found. The configuration properties found in a file closest to your current working directory will have precedence. Properties overridden with command line options will have final precedence.
The complicated configuration heirarchy is used because **go-jira** attempts to be context aware. For example, if you are working on a "foo" project and
you `cd` into your project workspace, wouldn't it be nice if `jira ls` automatically knew to list only issues related to the "foo" project? Likewise when you
`cd` to the "bar" project then `jira ls` should only list issues related to "bar" project. You can do this with by creating a configuration under your project
workspace at **./.jira.d/config.yml** that looks like:
The complicated configuration hierarchy is used because **go-jira** attempts to be context aware. For example, if you are working on a "foo" project and you `cd` into your project workspace, wouldn't it be nice if `jira ls` automatically knew to list only issues related to the "foo" project? Likewise when you `cd` to the "bar" project then `jira ls` should only list issues related to "bar" project. You can do this with by creating a configuration under your project workspace at **./.jira.d/config.yml** that looks like:
```
```yaml
project: foo
```
@@ -117,6 +65,8 @@ endpoint: https://jira.mycompany.com
EOM
```
Then use `jira login` to authenticate yourself as $USER. To change your username, use the `-u` CLI flag or set `user:` in your config.yml
### Dynamic Configuration
If the **.jira.d/config.yml** file is executable, then **go-jira** will attempt to execute the file and use the stdout for configuration. You can use this to customize templates or other overrides depending on what type of operation you are running. For example if you would like to use the "table" template when ever you run `jira ls`, then you can create a template like this:
@@ -127,7 +77,7 @@ If the **.jira.d/config.yml** file is executable, then **go-jira** will attempt
echo "endpoint: https://jira.mycompany.com"
echo "editor: emacs -nw"
case $JIRA_OPERATION in
case $JIRA_OPERATION in
list)
echo "template: table";;
esac
@@ -147,10 +97,159 @@ case $JIRA_OPERATION in
esac
```
### Custom Commands
You can now create custom commands for `jira` just by editing your `.jira.d/config.yml` config file. These commands are effectively shell-scripts that can have documented options and arguments. The basic format is like:
```yaml
custom-commands:
- command1
- command2
```
##### Commands
Where the individual commands are maps with these keys:
* `name: string` [**required**] This is the command name, so for `jira foobar` you would have `name: foobar`
* `help: string` This is help message displayed in the usage for the command
* `hidden: bool` This command will be hidden from users, but still executable. Sometimes useful for constructing complex commands where one custom command might call another.
* `default: bool` Use this for compound command groups. If you wanted to have `jira foo bar` and `jira foo baz` you would have two commands with `name: foo bar` and `name: foo baz`. Then if you wanted `jira foo baz` to be called by default when you type `jira foo` you would set `default: true` for that custom command.
* `options: list` This is the list of possible option flags that the command will accept
* `args: list` This is the list of command arguments (like the ISSUE) that the command will accept.
* `aliases: string list`: This is a list of alternate names that the user can provide on the command line to run the same command. Typically used to shorten the command name or provide alternatives that users might expect.
* `script: string` [**required**] This is the script that will be executed as the action for this command. The value will be treated as a template and substitutions for options and arguments will be made before executing.
##### Options
These are possible keys under the command `options` property:
* `name: string` [**required**] Name of the option, so `name: foobar` will result in `--foobar` option.
* `help: string` The help message displayed in usage for the option.
* `type: string`: The type of the option, can be one of these values: `BOOL`, `COUNTER`, `ENUM`, `FLOAT32`, `FLOAT64`, `INT8`, `INT16`, `INT32`, `INT64`, `INT`, `STRING`, `STRINGMAP`, `UINT8`, `UINT16`, `UINT32`, `UINT64` and `UINT`. Most of these are primitive data types an should be self-explanatory. The default type is `STRING`. There are some special types:
* `COUNTER` will be an integer type that increments each time the option is used. So something like `--count --count` will results in `{{options.count}}` of `2`.
* `ENUM` type is used with the `enum` property. The raw type is a string and **must** be one of the values listed in the `enum` property.
* `STRINGMAP` is a `string => string` map with the format of `KEY=VALUE`. So `--override foo=bar --override bin=baz` will allow for `{{options.override.foo}}` to be `bar` and `{{options.override.bin}}` to be `baz`.
* `short: char` The single character option to be used so `short: c` will allow for `-c`.
* `required: bool` Indicate that this option must be provided on the command line. Conflicts with the `default` property.
* `default: any` Specify the default value for the option. Conflicts with the `required` property.
* `hidden: bool` Hide the option from the usage help message, but otherwise works fine. Sometimes useful for developer options that user should not play with.
* `repeat: bool` Indicate that this option can be repeated. Not applicable for `COUNTER` and `STRINGMAP` types. This will turn the option value into an array that you can iterate over. So `--day Monday --day Thursday` can be used like `{{range options.day}}Day: {{.}}{{end}}`
* `enum: string list` Used with the `type: ENUM` property, it is a list of strings values that represent the set of possible values the option accepts.
##### Arguments
These are possible keys under the command `args` property:
* `name: string` [**required**] Name of the option, so `name: ISSUE` will show in the usage as `jira <command> ISSUE`. This also represents the name of the argument to be used in the script template, so `{{args.ISSUE}}`.
* `help: string` The help message displayed in usage for the argument.
* `type: string`: The type of the argument, can be one of these values: `BOOL`, `COUNTER`, `ENUM`, `FLOAT32`, `FLOAT64`, `INT8`, `INT16`, `INT32`, `INT64`, `INT`, `STRING`, `STRINGMAP`, `UINT8`, `UINT16`, `UINT32`, `UINT64` and `UINT`. Most of these are primitive data types an should be self-explanatory. The default type is `STRING`. There are some special types:
* `COUNTER` will be an integer type that increments each the argument is provided So something like `jira <command> ISSUE-12 ISSUE-23` will results in `{{args.ISSUE}}` of `2`.
* `ENUM` type is used with the `enum` property. The raw type is a string and **must** be one of the values listed in the `enum` property.
* `STRINGMAP` is a `string => string` map with the format of `KEY=VALUE`. So `jira <command> foo=bar bin=baz` along with a `name: OVERRIDE` property will allow for `{{args.OVERRIDE.foo}}` to be `bar` and `{{args.OVERRIDE.bin}}` to be `baz`.
* `required: bool` Indicate that this argument must be provided on the command line. Conflicts with the `default` property.
* `default: any` Specify the default value for the argument. Conflicts with the `required` property.
* `repeat: bool` Indicate that this argument can be repeated. Not applicable for `COUNTER` and `STRINGMAP` types. This will turn the template value into an array that you can iterate over. So `jira <command> ISSUE-12 ISSUE-23` can be used like `{{range args.ISSUE}}Issue: {{.}}{{end}}`
* `enum: string list` Used with the `type: ENUM` property, it is a list of strings values that represent the set of possible values for the argument.
##### Script Template
The `script` property is a template that would produce `/bin/sh` compatible syntax after the template has been processed. There are 2 key template functions `{{args}}` and `{{options}}` that return the parsed arguments and option flags as a map.
To demonstrate how you might use args and options here is a `custom-test` command:
```yaml
custom-commands:
- name: custom-test
help: Testing the custom commands
options:
- name: abc
short: a
default: default
- name: day
type: ENUM
enum:
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
required: true
args:
- name: ARG
required: true
- name: MORE
repeat: true
script: |
echo COMMAND {{args.ARG}} --abc {{options.abc}} --day {{options.day}} {{range $more := args.MORE}}{{$more}} {{end}}
```
Then to run it:
```
$ jira custom-test
ERROR Invalid Usage: required flag --day not provided
$ jira custom-test --day Sunday
ERROR Invalid Usage: enum value must be one of Monday,Tuesday,Wednesday,Thursday,Friday, got 'Sunday'
$ jira custom-test --day Tuesday
ERROR Invalid Usage: required argument 'ARG' not provided
$ jira custom-test --day Tuesday arg1
COMMAND arg1 --abc default --day Tuesday
$ jira custom-test --day Tuesday arg1 more1 more2 more3
COMMAND arg1 --abc default --day Tuesday more1 more2 more3
$ jira custom-test --day Tuesday arg1 more1 more2 more3 --abc non-default
COMMAND arg1 --abc non-default --day Tuesday more1 more2 more3
$ jira custom-test --day Tuesday arg1 more1 more2 more3 -a short-non-default
COMMAND arg1 --abc short-non-default --day Tuesday more1 more2 more3
```
The script has access to all the environment variables that are in your current environment plus those that `jira` will set. `jira` sets environment variables for each config property it has parsed from `.jira.d/config.yml` or the command configs at `.jira.d/<command>.yml`. It might be useful to see all environment variables that `jira` is producing, so here is a simple custom command to list them:
```yaml
custom-commands:
- name: env
help: print the JIRA environment variables available to custom commands
script: |
env | grep JIRA
```
You could use the environment variables automatically, so if your `.jira.d/config.yml` looks something like this:
```yaml
project: PROJECT
custom-commands:
- name: print-project
help: print the name of the configured project
script: "echo $JIRA_PROJECT"
```
##### Examples
* `jira mine` for listing issues assigned to you
```yaml
custom-commands:
- name: mine
help: display issues assigned to me
script: |-
if [ -n "$JIRA_PROJECT" ]; then
# if `project: ...` configured just list the issues for current project
{{jira}} list --template table --query "resolution = unresolved and assignee=currentuser() and project = $JIRA_PROJECT ORDER BY priority asc, created"
else
# otherwise list issues for all project
{{jira}} list --template table --query "resolution = unresolved and assignee=currentuser() ORDER BY priority asc, created"
fi
```
* `jira sprint` for listing issues in your current sprint
```yaml
custom-commands:
- name: sprint
help: display issues for active sprint
script: |-
if [ -n "$JIRA_PROJECT" ]; then
# if `project: ...` configured just list the issues for current project
{{jira}} list --template table --query "sprint in openSprints() and type != epic and resolution = unresolved and project=$JIRA_PROJECT ORDER BY rank asc, created"
else
# otherwise list issues for all project
{{jira}} list --template table --query "sprint in openSprints() and type != epic and resolution = unresolved ORDER BY rank asc, created"
fi
```
### Editing
When you run command like `jira edit` it will open up your favorite editor with the templatized output so you can quickly edit. When the editor
closes **go-jira** will submit the completed form. The order which **go-jira** attempts to determine your prefered editor is:
closes **go-jira** will submit the completed form. The order which **go-jira** attempts to determine your preferred editor is:
* **editor** property in any config.yml file
* **JIRA_EDITOR** environment variable
@@ -167,59 +266,163 @@ When running a command like `jira edit` it will look through the current directo
if found it will use that file as the template, otherwise it will use the default **edit** template hard-coded into **go-jira**. You can export the default
hard-coded templates with `jira export-templates` which will write them to **~/.jira.d/templates/**.
## Usage
#### Writing/Editing Templates
First the basic templating functionality is defined by the Go language 'text/template' library. The library reference documentation can be found [here](https://golang.org/pkg/text/template/), and there is a good primer document [here](https://gohugo.io/templates/go-templates/). `go-jira` also provides a few extra helper functions to make it a bit easier to format the data, those functions are defined [here](https://github.com/go-jira/jira/blob/master/jiracli/templates.go#L64).
Knowing what data and fields are available to any given template is not obvious. The easiest approach to determine what is available is to use the `debug` template on any given operation. For example to find out what is available to the "view" templates, you can use:
```
jira view GOJIRA-321 -t debug
```
This will print out the data in JSON format that is available to the template. You can do this for any other operation, like "list":
```
jira list -t debug
```
### Authentication
#### Atlassian Cloud
For Atlassian Cloud hosted Jira [API Tokens are now required](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/). You will automatically be prompted for an API Token if your jira endpoint ends in `.atlassian.net`.
##### Quickstart API Token and Keychain
1. Edit your config or execute the snippit (make sure to replace `<SUBDOMAIN>` and `<EMAIL>`)
```
export SUBDOMAIN="https://<SUBDOMAIN>.atlassian.net"
export EMAIL="<EMAIL>"
mkdir -p ~/.jira.d
printf "endpoint: $SUBDOMAIN\nuser: $EMAIL\npassword-source: keyring" > ~/.jira.d/config.yml
```
2. Create a new API Token at [id.atlassian.com](https://id.atlassian.com/manage-profile/security)
3. Execute `jira session` and enter your API Token. `jira` will add your session to the keyring.
#### Private Jira Service
If you are using a private Jira service, you can force `jira` to use an api-token by setting the `authentication-method: api-token` property in your `$HOME/.jira.d/config.yml` file. The API Token needs to be presented to the Jira service on every request, so it is recommended to store this API Token security within your OS's keyring, or using the `pass`/`gopass` service as documented below so that it can be programmatically accessed via `jira` and not prompt you every time. For a less-secure option you can also provide the API token via a `JIRA_API_TOKEN` environment variable. If you are unable to use an api-token for an Atlassian Cloud hosted Jira then you can still force `jira` to use the old session based authentication (until it the hosted system stops accepting it) by setting `authentication-method: session`.
The API Token authentication requires both the token and the email of the user. The email mut be set in the `user:` in your config.yml. Failure to provide the `user` will result in a 401 error.
If your Jira service still allows you to use the Session based authentication method then `jira` will prompt for a password automatically when get a response header from the Jira service that indicates you do not have an active session (ie the `X-Ausername` header is set to `anonymous`). Then after authentication we cache the `cloud.session.token` cookie returned by the service [session login api](https://docs.atlassian.com/jira/REST/cloud/#auth/1/session-login) and reuse that on subsequent requests. Typically this cookie will be valid for several hours (depending on the service configuration). To automatically securely store your password for easy reuse by jira You can enable a `password-source` via `.jira.d/config.yml` with possible values of `keyring`, `pass` or `gopass`.
Depending on how your private Jira service is configured, API tokens may require the "[Bearer][]" authentication scheme instead of the traditional "[Basic][]" [authentication scheme][scheme]. In this case, set the `authentication-method: bearer-token` property in your `$HOME/.jira.d/config.yml` file.
[scheme]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes
[Bearer]: https://datatracker.ietf.org/doc/html/rfc6750
[Basic]: https://tools.ietf.org/html/rfc7617
| **API token [scheme][]** | `authentication-method` | **Example HTTP request header** |
|:------------------------:|-------------------------|-------------------------------------------------|
| [Basic][] | `api-token` | `Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQK` |
| [Bearer][] | `bearer-token` | `Authorization: Bearer MY_TOKEN` |
#### User vs Login
The Jira service has sometimes differing opinions about how a user is identified. In other words the ID you login with might not be ID that the jira system recognized you as. This matters when trying to identify a user via various Jira REST APIs (like issue assignment). This is especially relevant when trying to authenticate with an API Token where the authentication user is usually an email address, but within the Jira system the user is identified by a user name. To accommodate this `jira` now supports two different properties in the config file. So when authentication using the API Tokens you will likely want something like this in your `$HOME/.jira.d/config.yml` file:
```yaml
user: person
login: person@example.com
```
You can also override these values on the command line with `jira --user person --login person@example.com`. The `login` value will be used only for authentication purposes, the `user` value will be used when a user name is required for any Jira service API calls.
#### `keyring` password source
On OSX and Linux there are a few keyring providers that `go-jira` can use (via this [golang module](https://github.com/tmc/keyring)). To integrate `go-jira` with a supported keyring just add this configuration to `$HOME/.jira.d/config.yml`:
```yaml
password-source: keyring
```
After setting this and issuing a `jira login`, your credentials will be stored in your platform's backend (e.g. Keychain for Mac OS X) automatically. Subsequent operations, like a `jira ls`, should automatically login.
#### `pass` password source
An alternative to the keyring password source is the `pass` tool (documentation [here](https://www.passwordstore.org/)). This uses gpg to encrypt/decrypt passwords on demand and by using `gpg-agent` you can cache the gpg credentials for a period of time so you will not be prompted repeatedly for decrypting the passwords. The advantage over the keyring integration is that `pass` can be used on more platforms than OSX and Linux, although it does require more setup. To use `pass` for password storage and retrieval via `go-jira` just add this configuration to `$HOME/.jira.d/config.yml`:
```yaml
password-source: pass
password-name: jira.example.com/myuser
```
This assumes you have already setup `pass` correctly on your system. Specifically you will need to have created a gpg key like this:
```
Usage:
jira [-v ...] [-u USER] [-e URI] [-t FILE] (ls|list) ( [-q JQL] | [-p PROJECT] [-c COMPONENT] [-a ASSIGNEE] [-i ISSUETYPE] [-w WATCHER] [-r REPORTER]) [-f FIELDS]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] view ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] edit ISSUE [--noedit] [-m COMMENT] [-o KEY=VAL]...
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] create [--noedit] [-p PROJECT] [-i ISSUETYPE] [-o KEY=VAL]...
jira [-v ...] [-u USER] [-e URI] [-b] DUPLICATE dups ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] BLOCKER blocks ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] watch ISSUE [-w WATCHER]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] (trans|transition) TRANSITION ISSUE [-m COMMENT] [-o KEY=VAL] [--noedit]
jira [-v ...] [-u USER] [-e URI] [-b] ack ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] close ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] resolve ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] reopen ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] start ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] stop ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] comment ISSUE [-m COMMENT]
jira [-v ...] [-u USER] [-e URI] [-b] take ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] (assign|give) ISSUE ASSIGNEE
jira [-v ...] [-u USER] [-e URI] [-t FILE] fields
jira [-v ...] [-u USER] [-e URI] [-t FILE] issuelinktypes
jira [-v ...] [-u USER] [-e URI] [-b][-t FILE] transmeta ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] editmeta ISSUE
jira [-v ...] [-u USER] [-e URI] [-t FILE] issuetypes [-p PROJECT]
jira [-v ...] [-u USER] [-e URI] [-t FILE] createmeta [-p PROJECT] [-i ISSUETYPE]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] transitions ISSUE
jira [-v ...] export-templates [-d DIR] [-t template]
jira [-v ...] [-u USER] [-e URI] (b|browse) ISSUE
jira [-v ...] [-u USER] [-e URI] [-t FILE] login
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] ISSUE
General Options:
-e --endpoint=URI URI to use for jira
-h --help Show this usage
-t --template=FILE Template file to use for output/editing
-u --user=USER Username to use for authenticaion (default: cbennett)
-v --verbose Increase output logging
--version Show this version
Command Options:
-a --assignee=USER Username assigned the issue
-b --browse Open your browser to the Jira issue
-c --component=COMPONENT Component to Search for
-d --directory=DIR Directory to export templates to (default: /Users/cbennett/.jira.d/templates)
-f --queryfields=FIELDS Fields that are used in "list" template: (default: summary,created,priority,status,reporter,assignee)
-i --issuetype=ISSUETYPE Jira Issue Type (default: Bug)
-m --comment=COMMENT Comment message for transition
-o --override=KEY:VAL Set custom key/value pairs
-p --project=PROJECT Project to Search for
-q --query=JQL Jira Query Language expression for the search
-r --reporter=USER Reporter to search for
-w --watcher=USER Watcher to add to issue (default: cbennett)
or Watcher to search for
$ gpg --gen-key
```
Then you will need the GPG Key ID you want associated with `pass`. First list the available keys:
```
$ gpg --list-keys
/home/gojira/.gnupg/pubring.gpg
-------------------------------------------------
pub 2048R/A307D709 2016-12-18
uid Go Jira <gojira@example.com>
sub 2048R/F9A047B8 2016-12-18
```
Then initialize the `pass` tool to use the correct key:
```
$ pass init "Go Jira <gojira@example.com>"
```
Now insert your password with the name you configured.
```
$ pass insert jira.example.com/myuser
```
You probably want to setup gpg-agent so that you don't have to type in your gpg passphrase all the time. You can get `gpg-agent` to automatically start by adding something like this to your `$HOME/.bashrc`
```bash
if [ -f $HOME/.gpg-agent-info ]; then
. $HOME/.gpg-agent-info
export GPG_AGENT_INFO
fi
if [ ! -f $HOME/.gpg-agent.conf ]; then
cat <<EOM >$HOME/.gpg-agent.conf
default-cache-ttl 604800
max-cache-ttl 604800
default-cache-ttl-ssh 604800
max-cache-ttl-ssh 604800
EOM
fi
if [ -n "${GPG_AGENT_INFO}" ]; then
nc -U "${GPG_AGENT_INFO%%:*}" >/dev/null </dev/null
if [ ! -S "${GPG_AGENT_INFO%%:*}" -o $? != 0 ]; then
# set passphrase cache so I only have to type my passphrase once a day
eval $(gpg-agent --options $HOME/.gpg-agent.conf --daemon --write-env-file $HOME/.gpg-agent-info --use-standard-socket --log-file $HOME/tmp/gpg-agent.log --verbose)
fi
fi
export GPG_TTY=$(tty)
```
#### `gopass` password source
There is also the possibility to use [gopass](https://www.gopass.pw/) as a password source. `gopass` (like `pass`) uses gpg to encrypt/decrypt passwords. To use `gopass` for password storagte and retrieval via `go-jira` just add this configuration to `$HOME/.jira.d/config.yml`:
```yaml
password-source: gopass
password-name: jira.example.com/myuser
```
For this to work, you need a working `gopass` installation.
To configure your `gpg-agent` to cache your gpg passphrase take a look at the `pass` section of the readme.
#### `stdin` password source
When `password-source` is set to `stdin`, the `jira login` command will read from stdin until EOF, and the bytes read will be the used as the password. This is useful if you have some other programmatic method for fetching passwords. For example, if `password-generator` creates a one-time password and prints it to stdout, you could use it like this.
```bash
$ ./password-generator | jira login --endpoint=https://my.jira.endpoint.com --user=USERNAME
```
#### Switch path used for password source
For `gopass` and `pass` it is possible to specify the full path for the `password-source` tool used for retrieval of the password. This can be accomplised
by setting the `password-source-path` option in the configuration file.
E.g.
```yaml
password-source: gopass
password-name: jira.example.com/myuser
password-source-path: /path/to/my-special-gopass
```
This will cause go-jira to use the `gopass` style cli interaction with the `my-special-gopass` binary.
If you ommit the `password-source-path` option, either `gopass` (for `gopass`) or `pass` (for `pass`)
will be used.
+1
View File
@@ -0,0 +1 @@
!src/
+236
View File
@@ -0,0 +1,236 @@
# Options for GnuPG
# Copyright 1998, 1999, 2000, 2001, 2002, 2003,
# 2010 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Unless you specify which option file to use (with the command line
# option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf
# by default.
#
# An options file can contain any long options which are available in
# GnuPG. If the first non white space character of a line is a '#',
# this line is ignored. Empty lines are also ignored.
#
# See the man page for a list of options.
# Uncomment the following option to get rid of the copyright notice
#no-greeting
# If you have more than 1 secret key in your keyring, you may want to
# uncomment the following option and set your preferred keyid.
#default-key 621CC013
# If you do not pass a recipient to gpg, it will ask for one. Using
# this option you can encrypt to a default key. Key validation will
# not be done in this case. The second form uses the default key as
# default recipient.
#default-recipient some-user-id
#default-recipient-self
# Use --encrypt-to to add the specified key as a recipient to all
# messages. This is useful, for example, when sending mail through a
# mail client that does not automatically encrypt mail to your key.
# In the example, this option allows you to read your local copy of
# encrypted mail that you've sent to others.
#encrypt-to some-key-id
# By default GnuPG creates version 4 signatures for data files as
# specified by OpenPGP. Some earlier (PGP 6, PGP 7) versions of PGP
# require the older version 3 signatures. Setting this option forces
# GnuPG to create version 3 signatures.
#force-v3-sigs
# Because some mailers change lines starting with "From " to ">From "
# it is good to handle such lines in a special way when creating
# cleartext signatures; all other PGP versions do it this way too.
#no-escape-from-lines
# If you do not use the Latin-1 (ISO-8859-1) charset, you should tell
# GnuPG which is the native character set. Please check the man page
# for supported character sets. This character set is only used for
# metadata and not for the actual message which does not undergo any
# translation. Note that future version of GnuPG will change to UTF-8
# as default character set. In most cases this option is not required
# as GnuPG is able to figure out the correct charset at runtime.
#charset utf-8
# Group names may be defined like this:
# group mynames = paige 0x12345678 joe patti
#
# Any time "mynames" is a recipient (-r or --recipient), it will be
# expanded to the names "paige", "joe", and "patti", and the key ID
# "0x12345678". Note there is only one level of expansion - you
# cannot make an group that points to another group. Note also that
# if there are spaces in the recipient name, this will appear as two
# recipients. In these cases it is better to use the key ID.
#group mynames = paige 0x12345678 joe patti
# Lock the file only once for the lifetime of a process. If you do
# not define this, the lock will be obtained and released every time
# it is needed, which is usually preferable.
#lock-once
# GnuPG can send and receive keys to and from a keyserver. These
# servers can be HKP, email, or LDAP (if GnuPG is built with LDAP
# support).
#
# Example HKP keyserver:
# hkp://keys.gnupg.net
# hkp://subkeys.pgp.net
#
# Example email keyserver:
# mailto:pgp-public-keys@keys.pgp.net
#
# Example LDAP keyservers:
# ldap://keyserver.pgp.com
#
# Regular URL syntax applies, and you can set an alternate port
# through the usual method:
# hkp://keyserver.example.net:22742
#
# Most users just set the name and type of their preferred keyserver.
# Note that most servers (with the notable exception of
# ldap://keyserver.pgp.com) synchronize changes with each other. Note
# also that a single server name may actually point to multiple
# servers via DNS round-robin. hkp://keys.gnupg.net is an example of
# such a "server", which spreads the load over a number of physical
# servers. To see the IP address of the server actually used, you may use
# the "--keyserver-options debug".
keyserver hkp://keys.gnupg.net
#keyserver mailto:pgp-public-keys@keys.nl.pgp.net
#keyserver ldap://keyserver.pgp.com
# Common options for keyserver functions:
#
# include-disabled : when searching, include keys marked as "disabled"
# on the keyserver (not all keyservers support this).
#
# no-include-revoked : when searching, do not include keys marked as
# "revoked" on the keyserver.
#
# verbose : show more information as the keys are fetched.
# Can be used more than once to increase the amount
# of information shown.
#
# use-temp-files : use temporary files instead of a pipe to talk to the
# keyserver. Some platforms (Win32 for one) always
# have this on.
#
# keep-temp-files : do not delete temporary files after using them
# (really only useful for debugging)
#
# http-proxy="proxy" : set the proxy to use for HTTP and HKP keyservers.
# This overrides the "http_proxy" environment variable,
# if any.
#
# auto-key-retrieve : automatically fetch keys as needed from the keyserver
# when verifying signatures or when importing keys that
# have been revoked by a revocation key that is not
# present on the keyring.
#
# no-include-attributes : do not include attribute IDs (aka "photo IDs")
# when sending keys to the keyserver.
#keyserver-options auto-key-retrieve
# Display photo user IDs in key listings
# list-options show-photos
# Display photo user IDs when a signature from a key with a photo is
# verified
# verify-options show-photos
# Use this program to display photo user IDs
#
# %i is expanded to a temporary file that contains the photo.
# %I is the same as %i, but the file isn't deleted afterwards by GnuPG.
# %k is expanded to the key ID of the key.
# %K is expanded to the long OpenPGP key ID of the key.
# %t is expanded to the extension of the image (e.g. "jpg").
# %T is expanded to the MIME type of the image (e.g. "image/jpeg").
# %f is expanded to the fingerprint of the key.
# %% is %, of course.
#
# If %i or %I are not present, then the photo is supplied to the
# viewer on standard input. If your platform supports it, standard
# input is the best way to do this as it avoids the time and effort in
# generating and then cleaning up a secure temp file.
#
# If no photo-viewer is provided, GnuPG will look for xloadimage, eog,
# or display (ImageMagick). On Mac OS X and Windows, the default is
# to use your regular JPEG image viewer.
#
# Some other viewers:
# photo-viewer "qiv %i"
# photo-viewer "ee %i"
#
# This one saves a copy of the photo ID in your home directory:
# photo-viewer "cat > ~/photoid-for-key-%k.%t"
#
# Use your MIME handler to view photos:
# photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"
# Passphrase agent
#
# We support the old experimental passphrase agent protocol as well as
# the new Assuan based one (currently available in the "newpg" package
# at ftp.gnupg.org/gcrypt/alpha/aegypten/). To make use of the agent,
# you have to run an agent as daemon and use the option
#
# use-agent
#
# which tries to use the agent but will fallback to the regular mode
# if there is a problem connecting to the agent. The normal way to
# locate the agent is by looking at the environment variable
# GPG_AGENT_INFO which should have been set during gpg-agent startup.
# In certain situations the use of this variable is not possible, thus
# the option
#
# --gpg-agent-info=<path>:<pid>:1
#
# may be used to override it.
# Automatic key location
#
# GnuPG can automatically locate and retrieve keys as needed using the
# auto-key-locate option. This happens when encrypting to an email
# address (in the "user@example.com" form), and there are no
# user@example.com keys on the local keyring. This option takes the
# following arguments, in the order they are to be tried:
#
# cert = locate a key using DNS CERT, as specified in RFC-4398.
# GnuPG can handle both the PGP (key) and IPGP (URL + fingerprint)
# CERT methods.
#
# pka = locate a key using DNS PKA.
#
# ldap = locate a key using the PGP Universal method of checking
# "ldap://keys.(thedomain)". For example, encrypting to
# user@example.com will check ldap://keys.example.com.
#
# keyserver = locate a key using whatever keyserver is defined using
# the keyserver option.
#
# You may also list arbitrary keyservers here by URL.
#
# Try CERT, then PKA, then LDAP, then hkp://subkeys.net:
#auto-key-locate cert pka ldap hkp://subkeys.pgp.net
Binary file not shown.
Binary file not shown.
Binary file not shown.
+49
View File
@@ -0,0 +1,49 @@
config:
stop: true
password-source: pass
endpoint: https://go-jira.atlassian.net
user: gojira
login: gojira@corybennett.org
project: BASIC
queries:
todo: >-
resolution = unresolved {{if .project}}AND project = '{{.project}}'{{end}} AND status = 'To Do'
custom-commands:
- name: env
help: print the JIRA environment variables available to custom commands
script: |-
env | sort | grep JIRA
- name: print-project
help: print the name of the configured project
script: "echo $JIRA_PROJECT"
- name: jira-path
help: print the path the jira command that is running this alias
script: |-
echo {{jira}}
- name: mine
help: display issues assigned to me
script: |-
if [ -n "$JIRA_PROJECT" ]; then
# if `project: ...` configured just list the issues for current project
{{jira}} list --template table --query "resolution = unresolved and assignee=currentuser() and project = $JIRA_PROJECT ORDER BY priority asc, created"
else
# otherwise list issues for all project
{{jira}} list --template table --query "resolution = unresolved and assignee=currentuser() ORDER BY priority asc, created"
fi
- name: argtest
help: testing passing args
script: |-
echo {{args.ARG}}
args:
- name: ARG
help: string to echo for testing
- name: opttest
help: testing passing option flags
script: |-
echo {{options.OPT}}
options:
- name: OPT
help: string to echo for testing
+1
View File
@@ -0,0 +1 @@
template: list
+1
View File
@@ -0,0 +1 @@
Go Jira <gojira@example.com>
+1
View File
@@ -0,0 +1 @@
 (ΡαΆω GΈώ20,ΧΎ„ι―’«$Ggu©y1_a-ΟI'ΥΈοΘ}Ν£4 ¨s@,]?P­ξs>uθ¤QpΓxΛΠΡA|x]"Ύf„ς—λΫ£B2Εν ytΌΡ±c…¥ο β8L ΙvgΗΚi] ΙKΥzu0yKΩ.“ §ΣBΑw| ƒ†_K'zθ΅Ύ“c¦ύυάά…ύ)?ΔoT #G8PΧΙπΩ=υP-,Ί}¥άώΝ X:,ΊfB'=WG²I±¨­  0BΈ£ξJΞ3Η εϋοΛΞσ;;;)Iι_UMfα•τ’}·’,―CΒhπΟμ£ο®μ\‰kκtΞ&ωµNύΌΐ½άjξ™ά
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
 (Ñá¢ù G¸ü ©oCº™*šâj0OÊ! =ldÿ§ô~2%p7•>´·kbñ#d›‹'¥d|_à{±ºa¶ŠÔο=mÂm½ð°Lí&‹À',^‰ý$¡¨!HÞ>]Ð4WïôêÔi+q=†N 2¿1´K;_% ~Ø ™¶£Õ‡ØÄ~\¶' : Ï[*:ï´ËFÃáSÌooApö¦*dËËH¬ôz‘È-vÝÞ#¼5†¡Ü[…« Ü„zê,e ¸˜È¤H„e#"=¾$y5kÐ+$Ë Ô¸šÇϨ~Õç’÷¾Ë3×Ïçj®¹3O£|WéÝÿîA#TI)ö± «âU }ô¹Ò;M3³ÞŒžëÁ9.ª}iT΂Š Ëì0S s…Jp…ìå’*½çѶPob‘¼™(*ò
Binary file not shown.
Executable
+61
View File
@@ -0,0 +1,61 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira --user admin"
. env.sh
SKIP test -n "$JIRACLOUD" # using Jira Cloud at go-jira.atlassian.net
PLAN 15
# clean out any old containers
docker rm -f go-jira-test
RUNS docker build . -t go-jira-test
mkdir -p $(pwd)/.maven-cache
# start newt jira service, cache the users m2 directory to make startup faster
RUNS docker run --detach -v $(pwd)/.maven-cache:/root/.m2/repository --name go-jira-test --publish 8080:8080 go-jira-test:latest
# wait for docker service to get started
RUNS sleep 5
echo "# Waiting for jira service to be listening on port 8080"
docker exec -i go-jira-test tail -f screenlog.0 | grep -m 1 'jira started successfully' | sed 's/^/# /'
# wait for healthchecks to pass, curl will retry 900 times over 15 min waiting
RUNS curl -q -L --retry 900 --retry-delay 1 -f -s "http://localhost:8080/rest/api/2/serverInfo?doHealthCheck=1"
# login to jira as admin user
RUNS $jira login
# create gojira user
RUNS $jira req -M POST /rest/api/2/user '{"name":"gojira","password":"gojira123","emailAddress":"gojira@example.com","displayName":"GoJira"}'
# create mothra user (need secondary user for voting)
RUNS $jira req -M POST /rest/api/2/user '{"name":"mothra","password":"mothra123","emailAddress":"mothra@example.com","displayName":"Mothra"}'
# create SCRUM softwareproject
RUNS $jira req -M POST /rest/api/2/project '{"key":"SCRUM","name":"Scrum","projectTypeKey":"software","projectTemplateKey":"com.pyxis.greenhopper.jira:gh-scrum-template","lead":"gojira"}'
# create KANBAN software project
RUNS $jira req -M POST /rest/api/2/project '{"key":"KANBAN","name":"Kanban","projectTypeKey":"software","projectTemplateKey":"com.pyxis.greenhopper.jira:gh-kanban-template","lead":"gojira"}'
# create BAISC software project
RUNS $jira req -M POST /rest/api/2/project '{"key":"BASIC","name":"Basic","projectTypeKey":"software","projectTemplateKey":"com.pyxis.greenhopper.jira:basic-software-development-template","lead":"gojira"}'
# create PROJECT business project
RUNS $jira req -M POST /rest/api/2/project '{"key":"PROJECT","name":"Project","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-project-management","lead":"gojira"}'
# create PROCESS business project
RUNS $jira req -M POST /rest/api/2/project '{"key":"PROCESS","name":"Process","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-process-management","lead":"gojira"}'
# create TASK business project
RUNS $jira req -M POST /rest/api/2/project '{"key":"TASK","name":"Task","projectTypeKey":"business","projectTemplateKey":"com.atlassian.jira-core-project-templates:jira-core-task-management","lead":"gojira"}'
RUNS $jira logout
# export new templates so we are always using whatever is latest
# and not whatever is in the test-runners homedir
RUNS $jira export-templates -d .jira.d/templates
Executable
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira=../jira
. env.sh
SKIP test -n "$JIRACLOUD" # using Jira Cloud at go-jira.atlassian.net
PLAN 7
###############################################################################
## Verify logout works, we expect when we call the session api
## that we will get a 401 and prompt user for password
################################################################################
RUNS $jira logout
NRUNS $jira req /rest/auth/1/session </dev/null
ODIFF <<EOF
Jira Password [gojira]:
EOF
###############################################################################
## Verify login works (password read from stdin) and verify that the
## sesion api no longer prompts
###############################################################################
echo "gojira123" | RUNS $jira login
RUNS $jira req /rest/auth/1/session </dev/null
GREP '"name": "gojira"'
GREP "\"self\": \"$ENDPOINT/rest/api/latest/user?username=gojira\""
Executable
+581
View File
@@ -0,0 +1,581 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 98
# reset login
RUNS $jira logout
RUNS $jira login
# cleanup from previous failed test executions
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## List all issues, should be just the one we created
###############################################################################
RUNS $jira ls --project BASIC
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## List issues using a named query
###############################################################################
RUNS $jira ls --project BASIC -n todo
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## List all issues, using the table template
###############################################################################
RUNS $jira ls --project BASIC --template table
DIFF <<EOF
+------------+---------+------+----------+--------+----------+----------+----------+
| Issue | Summary | Type | Priority | Status | Age | Reporter | Assignee |
+------------+---------+------+----------+--------+----------+----------+----------+
| $issue | summary | Bug | Medium | To Do | a minute | GoJira | GoJira |
+------------+---------+------+----------+--------+----------+----------+----------+
EOF
###############################################################################
## Edit an issue
###############################################################################
RUNS $jira edit $issue -m "edit comment" --override priority=High --noedit
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Edit multiple issues with query
###############################################################################
RUNS $jira edit -m "bulk edit comment" --override priority=High --noedit --query "resolution = unresolved AND project = 'BASIC' AND status = 'To Do'"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
priority: High
votes: 0
description: |
description
comments:
- | # GoJira, a minute ago
edit comment
- | # GoJira, a minute ago
bulk edit comment
EOF
###############################################################################
## Try to close the issue, bug Basic projects do not allow that state
###############################################################################
NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition "close" from "To Do", Available: To Do, In Progress, In Review, Done
EOF
###############################################################################
## put the issue into Done state, resolving it.
###############################################################################
RUNS $jira done $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify there are no unresolved issues
###############################################################################
RUNS $jira ls --project BASIC
DIFF <<EOF
EOF
###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira create --project BASIC -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
EOF
###############################################################################
## Mark issue as duplicate, expect both issues to be updated and when viewing
## the main issue there should be a "depends" line showing the dup'd issue, and
## that issue should be resolved
###############################################################################
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################
RUNS $jira ls --project BASIC
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Setup for testing blocking issues
###############################################################################
RUNS $jira create --project BASIC -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set blocker and verify it shows up when viewing the main issue
###############################################################################
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Both issues are unresolved now
###############################################################################
RUNS $jira ls --project BASIC
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
EOF
###############################################################################
# reset login for mothra for voting
###############################################################################
jira="$jira --user mothra --login mothra@corybennett.org"
RUNS $jira logout
RUNS $jira login
###############################################################################
## vote for main issue, verify it shows when viewing the issue
###############################################################################
RUNS $jira vote $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 1
description: |
description
EOF
###############################################################################
## downvote the main issue, verify the vote count goes back to 0
###############################################################################
RUNS $jira vote $issue --down
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## set mothra user as watcher to issue and verify from REST api
###############################################################################
RUNS $jira watch $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# FIXME we probably need a watchers command to wrap this?
RUNS sh -c "$jira req /rest/api/2/issue/$issue/watchers | jq -r .watchers[].displayName | sort"
DIFF <<EOF
GoJira
Mothra
EOF
###############################################################################
## set issue to In Progress state
###############################################################################
RUNS $jira trans "In Progress" $blocker --noedit
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## set it back to "To Do"
###############################################################################
RUNS $jira todo $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set issue to "In Review" state
###############################################################################
RUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it back to "To Do"
###############################################################################
RUNS $jira todo $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "In Progress"
###############################################################################
RUNS $jira prog $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "Done"
###############################################################################
RUNS $jira done $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Verify issue is now in Done state (the "blocker" issue is now Done)
###############################################################################
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Verify we can add a comment
###############################################################################
RUNS $jira comment $issue --noedit -m "Yo, Comment"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
comments:
- | # Mothra, a minute ago
Yo, Comment
EOF
###############################################################################
## Verify we can add labels to an issue
###############################################################################
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: another-label, test-label
description: |
blocks
EOF
###############################################################################
## Verify we can remove a label
###############################################################################
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: test-label
description: |
blocks
EOF
###############################################################################
## Verify we can replace the labels with a new set
###############################################################################
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify that "mothra" user can take the issue (reassign to self)
###############################################################################
RUNS $jira take $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: BASIC
issuetype: Bug
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify we can give the issue back go "gojira" user
###############################################################################
RUNS $jira give $blocker gojira
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## List 102 closed issues, should be more than 100 (max page size), verify pagination
###############################################################################
RUNS $jira ls -q "project = 'BASIC' AND status = 'Done'" --limit 102
IS $(wc -l <$OSHT_STDOUT) -eq 102
###############################################################################
## List 1 issue, verify we dont get full page
###############################################################################
RUNS $jira ls -q "project = 'BASIC' AND status = 'Done'" --limit 1
IS $(wc -l <$OSHT_STDOUT) -eq 1
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 6
# reset login
RUNS $jira logout
RUNS $jira login
# cleanup from previous failed test executions
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# just get the number
shortIssue=${issue#BASIC-}
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $shortIssue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: BASIC
issuetype: Bug
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
+44
View File
@@ -0,0 +1,44 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 8
# reset login
RUNS $jira logout
RUNS $jira login
# cleanup from previous failed test executions
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Add a worklog to an issue
###############################################################################
RUNS $jira worklog add $issue --comment "work is hard" --time-spent "1h 12m" -S "2017-01-29T09:17:00.000-0500" --noedit
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify worklog got added to issue
###############################################################################
RUNS $jira worklog $issue
DIFF <<EOF
- # GoJira, a minute ago
comment: work is hard
started: 2017-01-29T06:17:00.000-0800
timeSpent: 1h 12m
EOF
+80
View File
@@ -0,0 +1,80 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 16
# reset login
RUNS $jira logout
RUNS $jira login
# cleanup from previous failed test executions
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Testing the example custom commands, print-project
###############################################################################
RUNS $jira print-project
DIFF <<EOF
BASIC
EOF
###############################################################################
## Testing the example custom commands, jira-path
###############################################################################
RUNS $jira jira-path
DIFF <<EOF
../jira
EOF
###############################################################################
## Testing the example custom commands, env
###############################################################################
RUNS $jira env
GREP ^JIRA_PROJECT=BASIC
###############################################################################
## Testing the example custom commands, argtest
###############################################################################
RUNS $jira argtest TEST
DIFF <<EOF
TEST
EOF
###############################################################################
## Testing the example custom commands, opttest
###############################################################################
RUNS $jira opttest --OPT TEST
DIFF <<EOF
TEST
EOF
###############################################################################
## Use the "mine" alias to list issues assigned to self
###############################################################################
RUNS $jira mine
DIFF <<EOF
+------------+---------+------+----------+--------+----------+----------+----------+
| Issue | Summary | Type | Priority | Status | Age | Reporter | Assignee |
+------------+---------+------+----------+--------+----------+----------+----------+
| $issue | summary | Bug | Medium | To Do | a minute | GoJira | GoJira |
+------------+---------+------+----------+--------+----------+----------+----------+
EOF
+121
View File
@@ -0,0 +1,121 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 22
# reset login
RUNS $jira logout
RUNS $jira login
# cleanup from previous failed test executions
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
###############################################################################
## Create an epic
###############################################################################
RUNS $jira epic create --project BASIC -o summary="Totally Epic" -o description=description --epic-name "Basic Epic" --noedit --saveFile issue.props
epic=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $epic $ENDPOINT/browse/$epic
EOF
###############################################################################
## Create issues we can assign to epic
###############################################################################
RUNS $jira create --project BASIC -o summary="summary" -o description=description --noedit --saveFile issue.props
issue1=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue1 $ENDPOINT/browse/$issue1
EOF
RUNS $jira create --project BASIC -o summary="summary" -o description=description --noedit --saveFile issue.props
issue2=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue2 $ENDPOINT/browse/$issue2
EOF
###############################################################################
## List the issues for the epic
###############################################################################
RUNS $jira epic list $epic
DIFF<<EOF
+-------+---------+------+----------+--------+-----+----------+----------+
| Issue | Summary | Type | Priority | Status | Age | Reporter | Assignee |
+-------+---------+------+----------+--------+-----+----------+----------+
+-------+---------+------+----------+--------+-----+----------+----------+
EOF
###############################################################################
## Add issues to an epic
###############################################################################
RUNS $jira epic add $epic $issue1 $issue2
DIFF<<EOF
OK $epic $ENDPOINT/browse/$epic
OK $issue1 $ENDPOINT/browse/$issue1
OK $issue2 $ENDPOINT/browse/$issue2
EOF
###############################################################################
## List the issues for the epic
###############################################################################
RUNS $jira epic list $epic
DIFF<<EOF
+------------+---------+------+----------+--------+----------+----------+----------+
| Issue | Summary | Type | Priority | Status | Age | Reporter | Assignee |
+------------+---------+------+----------+--------+----------+----------+----------+
| $issue1 | summary | Bug | Medium | To Do | a minute | GoJira | GoJira |
| $issue2 | summary | Bug | Medium | To Do | a minute | GoJira | GoJira |
+------------+---------+------+----------+--------+----------+----------+----------+
EOF
###############################################################################
## Remove an issue from an Epic
###############################################################################
RUNS $jira epic remove $issue1
DIFF<<EOF
OK $issue1 $ENDPOINT/browse/$issue1
EOF
###############################################################################
## List the issues for the epic
###############################################################################
RUNS $jira epic list $epic
DIFF<<EOF
+------------+---------+------+----------+--------+----------+----------+----------+
| Issue | Summary | Type | Priority | Status | Age | Reporter | Assignee |
+------------+---------+------+----------+--------+----------+----------+----------+
| $issue2 | summary | Bug | Medium | To Do | a minute | GoJira | GoJira |
+------------+---------+------+----------+--------+----------+----------+----------+
EOF
###############################################################################
## Remove last issue from an Epic
###############################################################################
RUNS $jira epic remove $issue2
DIFF<<EOF
OK $issue2 $ENDPOINT/browse/$issue2
EOF
###############################################################################
## List the issues for the epic
###############################################################################
RUNS $jira epic list $epic
DIFF<<EOF
+-------+---------+------+----------+--------+-----+----------+----------+
| Issue | Summary | Type | Priority | Status | Age | Reporter | Assignee |
+-------+---------+------+----------+--------+-----+----------+----------+
+-------+---------+------+----------+--------+-----+----------+----------+
EOF
+189
View File
@@ -0,0 +1,189 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 43
# reset login
RUNS $jira logout
RUNS $jira login
# cleanup from previous failed test executions
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project BASIC -o summary="Attach To Me" -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Attach via stdin
###############################################################################
RUNS $jira attach create $issue --filename README.md --saveFile attach.props < ./README.md
attach1=$(awk '/^id:/{print $2}' attach.props)
DIFF <<EOF
OK $attach1 $ENDPOINT/secure/attachment/$attach1/README.md
EOF
###############################################################################
## Attach binary file
###############################################################################
RUNS dd of=garbage.bin if=/dev/urandom count=1k bs=1k
RUNS $jira attach create $issue garbage.bin --saveFile attach.props
attach2=$(awk '/^id:/{print $2}' attach.props)
DIFF <<EOF
OK $attach2 $ENDPOINT/secure/attachment/$attach2/garbage.bin
EOF
###############################################################################
## Attach binary file with different name
###############################################################################
RUNS $jira attach create $issue garbage.bin --filename foobar.bin --saveFile attach.props
attach3=$(awk '/^id:/{print $2}' attach.props)
DIFF <<EOF
OK $attach3 $ENDPOINT/secure/attachment/$attach3/foobar.bin
EOF
###############################################################################
## List attachments
###############################################################################
RUNS $jira attach list $issue
DIFF <<EOF
+-------+-------------+---------+--------+----------+
| id | filename | bytes | user | created |
+-------+-------------+---------+--------+----------+
| $attach1 | README.md | 1239 | GoJira | a minute |
| $attach2 | garbage.bin | 1048576 | GoJira | a minute |
| $attach3 | foobar.bin | 1048576 | GoJira | a minute |
+-------+-------------+---------+--------+----------+
EOF
###############################################################################
## Fetch text attachment
###############################################################################
RUNS $jira attach get $attach1 -o attach1.txt
DIFF <<EOF
OK Wrote attach1.txt
EOF
# verify no diffs
RUNS diff -q README.md attach1.txt
###############################################################################
## Fetch text attachment to stdout
###############################################################################
RUNS sh -c "$jira attach get $attach1 -o- > attach1.txt"
# verify no diffs
RUNS diff -q README.md attach1.txt
###############################################################################
## Fetch text attachment as same name
###############################################################################
RUNS $jira attach get $attach1
DIFF <<EOF
OK Wrote README.md
EOF
# verify no diffs
RUNS git diff README.md
###############################################################################
## Fetch binary attachment
###############################################################################
RUNS $jira attach get $attach2 --output binary.out
DIFF <<EOF
OK Wrote binary.out
EOF
# verify no diffs
RUNS diff -q garbage.bin binary.out
###############################################################################
## Fetch binary attachment to stdout
###############################################################################
RUNS sh -c "$jira attach get $attach2 -o- > binary.out"
# verify no diffs
RUNS diff -q garbage.bin binary.out
###############################################################################
## Fetch binary attachment
###############################################################################
RUNS $jira attach get $attach3
DIFF <<EOF
OK Wrote foobar.bin
EOF
# verify no diffs
RUNS diff -q garbage.bin foobar.bin
###############################################################################
## Fetch binary attachment to stdout
###############################################################################
RUNS sh -c "$jira attach get $attach3 --output=- > binary.out"
# verify no diffs
RUNS diff -q garbage.bin binary.out
###############################################################################
## Delete attachment
###############################################################################
RUNS $jira attach remove $attach1
DIFF <<EOF
OK Deleted Attachment $attach1
EOF
RUNS $jira attach list $issue
DIFF <<EOF
+-------+-------------+---------+--------+----------+
| id | filename | bytes | user | created |
+-------+-------------+---------+--------+----------+
| $attach2 | garbage.bin | 1048576 | GoJira | a minute |
| $attach3 | foobar.bin | 1048576 | GoJira | a minute |
+-------+-------------+---------+--------+----------+
EOF
###############################################################################
## Delete attachment
###############################################################################
RUNS $jira attach rm $attach2
DIFF <<EOF
OK Deleted Attachment $attach2
EOF
RUNS $jira attach list $issue
DIFF <<EOF
+-------+------------+---------+--------+----------+
| id | filename | bytes | user | created |
+-------+------------+---------+--------+----------+
| $attach3 | foobar.bin | 1048576 | GoJira | a minute |
+-------+------------+---------+--------+----------+
EOF
###############################################################################
## Delete last
###############################################################################
RUNS $jira attach rm $attach3
DIFF <<EOF
OK Deleted Attachment $attach3
EOF
RUNS $jira attach list $issue
DIFF <<EOF
+----+----------+-------+------+---------+
| id | filename | bytes | user | created |
+----+----------+-------+------+---------+
+----+----------+-------+------+---------+
EOF
Executable
+509
View File
@@ -0,0 +1,509 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 84
# cleanup from previous failed test executions
($jira ls --project SCRUM | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
# reset login
RUNS $jira logout
echo "gojira123" | RUNS $jira login
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project SCRUM -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## List all issues, should be just the one we created
###############################################################################
RUNS $jira ls --project SCRUM
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Try to close the issue, bug Basic projects do not allow that state
###############################################################################
NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition "close" from "To Do", Available: To Do, In Progress, Done
EOF
###############################################################################
## put the issue into Done state, resolving it.
###############################################################################
RUNS $jira done $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify there are no unresolved issues
###############################################################################
RUNS $jira ls --project SCRUM
DIFF <<EOF
EOF
###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################
RUNS $jira create --project SCRUM -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira create --project SCRUM -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
EOF
###############################################################################
## Mark issue as duplicate, expect both issues to be updated and when viewing
## the main issue there should be a "depends" line showing the dup'd issue, and
## that issue should be resolved
###############################################################################
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################
RUNS $jira ls --project SCRUM
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Setup for testing blocking issues
###############################################################################
RUNS $jira create --project SCRUM -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set blocker and verify it shows up when viewing the main issue
###############################################################################
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Both issues are unresolved now
###############################################################################
RUNS $jira ls --project SCRUM
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
EOF
###############################################################################
# reset login for mothra for voting
###############################################################################
jira="$jira --user mothra --login mothra@corybennett.org"
RUNS $jira logout
echo "mothra123" | RUNS $jira login
###############################################################################
## vote for main issue, verify it shows when viewing the issue
###############################################################################
RUNS $jira vote $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 1
description: |
description
EOF
###############################################################################
## downvote the main issue, verify the vote count goes back to 0
###############################################################################
RUNS $jira vote $issue --down
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## set mothra user as watcher to issue and verify from REST api
###############################################################################
RUNS $jira watch $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# FIXME we probably need a watchers command to wrap this?
RUNS sh -c "$jira req /rest/api/2/issue/$issue/watchers | jq -r .watchers[].displayName | sort"
DIFF <<EOF
GoJira
Mothra
EOF
###############################################################################
## set issue to In Progress state
###############################################################################
RUNS $jira trans "In Progress" $blocker --noedit
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## set it back to "To Do"
###############################################################################
RUNS $jira todo $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set issue to "In Review" state, which is an invalid state for SCRUM
###############################################################################
NRUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "review" from "To Do", Available: To Do, In Progress, Done
EOF
###############################################################################
## Set it back to "To Do"
###############################################################################
RUNS $jira todo $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "In Progress"
###############################################################################
RUNS $jira prog $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "Done"
###############################################################################
RUNS $jira done $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Verify issue is now in Done state (the "blocker" issue is now Done)
###############################################################################
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Verify we can add a comment
###############################################################################
RUNS $jira comment $issue --noedit -m "Yo, Comment"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
comments:
- | # Mothra, a minute ago
Yo, Comment
EOF
###############################################################################
## Verify we can add labels to an issue
###############################################################################
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: another-label, test-label
description: |
blocks
EOF
###############################################################################
## Verify we can remove a label
###############################################################################
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: test-label
description: |
blocks
EOF
###############################################################################
## Verify we can replace the labels with a new set
###############################################################################
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify that "mothra" user can take the issue (reassign to self)
###############################################################################
RUNS $jira take $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: SCRUM
issuetype: Bug
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify we can give the issue back go "gojira" user
###############################################################################
RUNS $jira give $blocker gojira
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: SCRUM
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
Executable
+518
View File
@@ -0,0 +1,518 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 86
# cleanup from previous failed test executions
($jira ls --project KANBAN | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
# reset login
RUNS $jira logout
echo "gojira123" | RUNS $jira login
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project KANBAN -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## List all issues, should be just the one we created
###############################################################################
RUNS $jira ls --project KANBAN
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Try to close the issue, bug Basic projects do not allow that state
###############################################################################
NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition "close" from "Backlog", Available: Backlog, Selected for Development, In Progress, Done
EOF
###############################################################################
## put the issue into Done state, resolving it.
###############################################################################
RUNS $jira done $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify there are no unresolved issues
###############################################################################
RUNS $jira ls --project KANBAN
DIFF <<EOF
EOF
###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################
RUNS $jira create --project KANBAN -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira create --project KANBAN -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
EOF
###############################################################################
## Mark issue as duplicate, expect both issues to be updated and when viewing
## the main issue there should be a "depends" line showing the dup'd issue, and
## that issue should be resolved
###############################################################################
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################
RUNS $jira ls --project KANBAN
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Setup for testing blocking issues
###############################################################################
RUNS $jira create --project KANBAN -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set blocker and verify it shows up when viewing the main issue
###############################################################################
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Backlog]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Both issues are unresolved now
###############################################################################
RUNS $jira ls --project KANBAN
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
EOF
###############################################################################
# reset login for mothra for voting
###############################################################################
jira="$jira --user mothra --login mothra@corybennett.org"
RUNS $jira logout
echo "mothra123" | RUNS $jira login
###############################################################################
## vote for main issue, verify it shows when viewing the issue
###############################################################################
RUNS $jira vote $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Backlog]
depends: $dup[Done]
priority: Medium
votes: 1
description: |
description
EOF
###############################################################################
## downvote the main issue, verify the vote count goes back to 0
###############################################################################
RUNS $jira vote $issue --down
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Backlog]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## set mothra user as watcher to issue and verify from REST api
###############################################################################
RUNS $jira watch $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# FIXME we probably need a watchers command to wrap this?
RUNS sh -c "$jira req /rest/api/2/issue/$issue/watchers | jq -r .watchers[].displayName | sort"
DIFF <<EOF
GoJira
Mothra
EOF
###############################################################################
## set issue to In Progress state
###############################################################################
RUNS $jira trans "In Progress" $blocker --noedit
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## set it to "To Do", which is not a valid state for KANBAN issues
###############################################################################
NRUNS $jira todo $blocker
DIFF <<EOF
ERROR Invalid Transition "To Do" from "In Progress", Available: Backlog, Selected for Development, In Progress, Done
EOF
###############################################################################
## set issue back to backlog state
###############################################################################
RUNS $jira backlog $blocker --noedit
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set issue to "In Review" state, which is an invalid state for KANBAN
###############################################################################
NRUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "review" from "Backlog", Available: Backlog, Selected for Development, In Progress, Done
EOF
###############################################################################
## Set it back to "Backlog"
###############################################################################
RUNS $jira backlog $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "In Progress"
###############################################################################
RUNS $jira prog $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "Done"
###############################################################################
RUNS $jira done $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Verify issue is now in Done state (the "blocker" issue is now Done)
###############################################################################
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Verify we can add a comment
###############################################################################
RUNS $jira comment $issue --noedit -m "Yo, Comment"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Backlog
summary: summary
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
comments:
- | # Mothra, a minute ago
Yo, Comment
EOF
###############################################################################
## Verify we can add labels to an issue
###############################################################################
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Backlog]
priority: Medium
votes: 0
labels: another-label, test-label
description: |
blocks
EOF
###############################################################################
## Verify we can remove a label
###############################################################################
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Backlog]
priority: Medium
votes: 0
labels: test-label
description: |
blocks
EOF
###############################################################################
## Verify we can replace the labels with a new set
###############################################################################
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Backlog]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify that "mothra" user can take the issue (reassign to self)
###############################################################################
RUNS $jira take $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: KANBAN
issuetype: Bug
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[Backlog]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify we can give the issue back go "gojira" user
###############################################################################
RUNS $jira give $blocker gojira
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: KANBAN
issuetype: Bug
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Backlog]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
+521
View File
@@ -0,0 +1,521 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 84
# cleanup from previous failed test executions
($jira ls --project PROJECT | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
# reset login
RUNS $jira logout
echo "gojira123" | RUNS $jira login
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project PROJECT -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## List all issues, should be just the one we created
###############################################################################
RUNS $jira ls --project PROJECT
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Try to close the issue, bug Basic projects do not allow that state
###############################################################################
NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition "close" from "To Do", Available: Start Progress, Done
EOF
###############################################################################
## put the issue into Done state, resolving it.
###############################################################################
RUNS $jira done $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify there are no unresolved issues
###############################################################################
RUNS $jira ls --project PROJECT
DIFF <<EOF
EOF
###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################
RUNS $jira create --project PROJECT -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira create --project PROJECT -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
EOF
###############################################################################
## Mark issue as duplicate, expect both issues to be updated and when viewing
## the main issue there should be a "depends" line showing the dup'd issue, and
## that issue should be resolved
###############################################################################
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################
RUNS $jira ls --project PROJECT
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Setup for testing blocking issues
###############################################################################
RUNS $jira create --project PROJECT -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set blocker and verify it shows up when viewing the main issue
###############################################################################
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Both issues are unresolved now
###############################################################################
RUNS $jira ls --project PROJECT
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
EOF
###############################################################################
# reset login for mothra for voting
###############################################################################
jira="$jira --user mothra --login mothra@corybennett.org"
RUNS $jira logout
echo "mothra123" | RUNS $jira login
###############################################################################
## vote for main issue, verify it shows when viewing the issue
###############################################################################
RUNS $jira vote $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 1
description: |
description
EOF
###############################################################################
## downvote the main issue, verify the vote count goes back to 0
###############################################################################
RUNS $jira vote $issue --down
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## set mothra user as watcher to issue and verify from REST api
###############################################################################
RUNS $jira watch $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# FIXME we probably need a watchers command to wrap this?
RUNS sh -c "$jira req /rest/api/2/issue/$issue/watchers | jq -r .watchers[].displayName | sort"
DIFF <<EOF
GoJira
Mothra
EOF
###############################################################################
## set issue to In Progress state, which is an invalid state for PROJECT
###############################################################################
NRUNS $jira trans "In Progress" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "In Progress" from "To Do", Available: Start Progress, Done
EOF
###############################################################################
## Set issue to "In Review" state, which is an invalid state for PROJECT
###############################################################################
NRUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "review" from "To Do", Available: Start Progress, Done
EOF
###############################################################################
## Set it to "Start Progress" and verify that assignee is set to mothra
###############################################################################
RUNS $jira start $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: In Progress
summary: blocks
project: PROJECT
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
description: |
blocks
EOF
###############################################################################
## Set it back to "Stop Progress"
###############################################################################
RUNS $jira stop $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "Done"
###############################################################################
RUNS $jira done $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Verify issue is now in Done state (the "blocker" issue is now Done)
###############################################################################
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Verify we can add a comment
###############################################################################
RUNS $jira comment $issue --noedit -m "Yo, Comment"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
comments:
- | # Mothra, a minute ago
Yo, Comment
EOF
###############################################################################
## Verify we can add labels to an issue
###############################################################################
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: PROJECT
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: another-label, test-label
description: |
blocks
EOF
###############################################################################
## Verify we can remove a label
###############################################################################
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: PROJECT
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: test-label
description: |
blocks
EOF
###############################################################################
## Verify we can replace the labels with a new set
###############################################################################
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: PROJECT
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify we can give the issue back go "gojira" user
###############################################################################
RUNS $jira give $blocker gojira
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: PROJECT
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify that "mothra" user can take the issue (reassign to self)
###############################################################################
RUNS $jira take $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: PROJECT
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
+516
View File
@@ -0,0 +1,516 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 84
# cleanup from previous failed test executions
($jira ls --project PROCESS | awk -F: '{print $1}' | while read issue; do ../jira start $issue; done) | sed 's/^/# CLEANUP: /g'
($jira ls --project PROCESS | awk -F: '{print $1}' | while read issue; do ../jira stop $issue; done) | sed 's/^/# CLEANUP: /g'
# for any issues still remaining, they are stuck in "Under Review" status
($jira ls --project PROCESS | awk -F: '{print $1}' | while read issue; do ../jira transition --noedit -m "approve" "Approve" $issue; done) | sed 's/^/# CLEANUP: /g'
($jira ls --project PROCESS | awk -F: '{print $1}' | while read issue; do ../jira transition --noedit -m "done" "Done" $issue; done) | sed 's/^/# CLEANUP: /g'
# reset login
RUNS $jira logout
echo "gojira123" | RUNS $jira login
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project PROCESS -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## List all issues, should be just the one we created
###############################################################################
RUNS $jira ls --project PROCESS
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Try to close the issue, but PROCESS projects do not allow that state
###############################################################################
NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition "close" from "Open", Available: Start Progress
EOF
###############################################################################
## put the issue into Start Progress state, then Stop Progress state
## which will resolve the issue
###############################################################################
RUNS $jira start $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira stop $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify there are no unresolved issues
###############################################################################
RUNS $jira ls --project PROCESS
DIFF <<EOF
EOF
###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################
RUNS $jira create --project PROCESS -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira create --project PROCESS -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
EOF
###############################################################################
## Mark issue as duplicate, expect both issues to be updated and when viewing
## the main issue there should be a "depends" line showing the dup'd issue, and
## that issue should be resolved. For PROCESSS projects it has to go through
## 2 steps to resolve, one is "Start Progress" then resolved with "Stop
## Progress", so we see 3 updates in total
###############################################################################
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $dup[Cancelled]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################
RUNS $jira ls --project PROCESS
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Setup for testing blocking issues
###############################################################################
RUNS $jira create --project PROCESS -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set blocker and verify it shows up when viewing the main issue
###############################################################################
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Open]
depends: $dup[Cancelled]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Both issues are unresolved now
###############################################################################
RUNS $jira ls --project PROCESS
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
EOF
###############################################################################
# reset login for mothra for voting
###############################################################################
jira="$jira --user mothra --login mothra@corybennett.org"
RUNS $jira logout
echo "mothra123" | RUNS $jira login
###############################################################################
## vote for main issue, verify it shows when viewing the issue
###############################################################################
RUNS $jira vote $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Open]
depends: $dup[Cancelled]
priority: Medium
votes: 1
description: |
description
EOF
###############################################################################
## downvote the main issue, verify the vote count goes back to 0
###############################################################################
RUNS $jira vote $issue --down
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Open]
depends: $dup[Cancelled]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## set mothra user as watcher to issue and verify from REST api
###############################################################################
RUNS $jira watch $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# FIXME we probably need a watchers command to wrap this?
RUNS sh -c "$jira req /rest/api/2/issue/$issue/watchers | jq -r .watchers[].displayName | sort"
DIFF <<EOF
GoJira
Mothra
EOF
###############################################################################
## set issue to In Progress state, which is an invalid state for PROCESS
###############################################################################
NRUNS $jira trans "In Progress" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "In Progress" from "Open", Available: Start Progress
EOF
###############################################################################
## Set issue to "In Review" state, which is an invalid state for PROCESS
###############################################################################
NRUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "review" from "Open", Available: Start Progress
EOF
###############################################################################
## Set it to "Start Progress"
###############################################################################
RUNS $jira start $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it back to "Stop Progress"
###############################################################################
RUNS $jira stop $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set it to "Done"
###############################################################################
RUNS $jira reopen $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Verify issue is now in Done state (the "blocker" issue is now Done)
###############################################################################
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Open]
depends: $dup[Cancelled]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Verify we can add a comment
###############################################################################
RUNS $jira comment $issue --noedit -m "Yo, Comment"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: Open
summary: summary
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Open]
depends: $dup[Cancelled]
priority: Medium
votes: 0
description: |
description
comments:
- | # Mothra, a minute ago
Yo, Comment
EOF
###############################################################################
## Verify we can add labels to an issue
###############################################################################
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Open
summary: blocks
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Open]
priority: Medium
votes: 0
labels: another-label, test-label
description: |
blocks
EOF
###############################################################################
## Verify we can remove a label
###############################################################################
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Open
summary: blocks
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Open]
priority: Medium
votes: 0
labels: test-label
description: |
blocks
EOF
###############################################################################
## Verify we can replace the labels with a new set
###############################################################################
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Open
summary: blocks
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Open]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify that "mothra" user can take the issue (reassign to self)
###############################################################################
RUNS $jira take $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Open
summary: blocks
project: PROCESS
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[Open]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify we can give the issue back go "gojira" user
###############################################################################
RUNS $jira give $blocker gojira
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Open
summary: blocks
project: PROCESS
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[Open]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
Executable
+505
View File
@@ -0,0 +1,505 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira"
. env.sh
PLAN 82
# cleanup from previous failed test executions
($jira ls --project TASK | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
# reset login
RUNS $jira logout
echo "gojira123" | RUNS $jira login
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create --project TASK -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## View the issue we just created
###############################################################################
RUNS $jira view $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## List all issues, should be just the one we created
###############################################################################
RUNS $jira ls --project TASK
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Try to close the issue, but TASK projects do not allow that state
###############################################################################
NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition "close" from "To Do", Available: Done
EOF
###############################################################################
## put the issue into Done state, which will resolve the issue
###############################################################################
RUNS $jira done $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
###############################################################################
## Verify there are no unresolved issues
###############################################################################
RUNS $jira ls --project TASK
DIFF <<EOF
EOF
###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################
RUNS $jira create --project TASK -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira create --project TASK -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
EOF
###############################################################################
## Mark issue as duplicate, expect both issues to be updated and when viewing
## the main issue there should be a "depends" line showing the dup'd issue, and
## that issue should be resolved. For TASKS projects it has to go through
## 2 steps to resolve, one is "Start Progress" then resolved with "Stop
## Progress", so we see 3 updates in total
###############################################################################
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################
RUNS $jira ls --project TASK
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
###############################################################################
## Setup for testing blocking issues
###############################################################################
RUNS $jira create --project TASK -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Set blocker and verify it shows up when viewing the main issue
###############################################################################
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Both issues are unresolved now
###############################################################################
RUNS $jira ls --project TASK
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
EOF
###############################################################################
# reset login for mothra for voting
###############################################################################
jira="$jira --user mothra --login mothra@corybennett.org"
RUNS $jira logout
echo "mothra123" | RUNS $jira login
###############################################################################
## vote for main issue, verify it shows when viewing the issue
###############################################################################
RUNS $jira vote $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 1
description: |
description
EOF
###############################################################################
## downvote the main issue, verify the vote count goes back to 0
###############################################################################
RUNS $jira vote $issue --down
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[To Do]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## set mothra user as watcher to issue and verify from REST api
###############################################################################
RUNS $jira watch $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
# FIXME we probably need a watchers command to wrap this?
RUNS sh -c "$jira req /rest/api/2/issue/$issue/watchers | jq -r .watchers[].displayName | sort"
DIFF <<EOF
GoJira
Mothra
EOF
###############################################################################
## set issue to In Progress state, which is an invalid state for TASK
###############################################################################
NRUNS $jira trans "In Progress" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "In Progress" from "To Do", Available: Done
EOF
###############################################################################
## Set issue to "In Review" state, which is an invalid state for TASK
###############################################################################
NRUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition "review" from "To Do", Available: Done
EOF
###############################################################################
## Set it to "Start Progress", which is an invalid state for TASK
###############################################################################
NRUNS $jira start $blocker
DIFF <<EOF
ERROR Invalid Transition "start" from "To Do", Available: Done
EOF
###############################################################################
## Set it back to "Stop Progress", which is an invalid state for TASK
###############################################################################
NRUNS $jira stop $blocker
DIFF <<EOF
ERROR Invalid Transition "stop" from "To Do", Available: Done
EOF
###############################################################################
## Set it to "Done"
###############################################################################
RUNS $jira done $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
###############################################################################
## Verify issue is now in Done state (the "blocker" issue is now Done)
###############################################################################
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
EOF
###############################################################################
## Verify we can add a comment
###############################################################################
RUNS $jira comment $issue --noedit -m "Yo, Comment"
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
RUNS $jira $issue
DIFF <<EOF
issue: $issue
created: a minute ago
status: To Do
summary: summary
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers: $blocker[Done]
depends: $dup[Done]
priority: Medium
votes: 0
description: |
description
comments:
- | # Mothra, a minute ago
Yo, Comment
EOF
###############################################################################
## Verify we can add labels to an issue
###############################################################################
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: another-label, test-label
description: |
blocks
EOF
###############################################################################
## Verify we can remove a label
###############################################################################
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: test-label
description: |
blocks
EOF
###############################################################################
## Verify we can replace the labels with a new set
###############################################################################
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify that "mothra" user can take the issue (reassign to self)
###############################################################################
RUNS $jira take $blocker
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: TASK
issuetype: Task
assignee: Mothra
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
###############################################################################
## Verify we can give the issue back go "gojira" user
###############################################################################
RUNS $jira give $blocker gojira
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
RUNS $jira $blocker
DIFF <<EOF
issue: $blocker
created: a minute ago
status: Done
summary: blocks
project: TASK
issuetype: Task
assignee: GoJira
reporter: GoJira
blockers:
depends: $issue[To Do]
priority: Medium
votes: 0
labels: better-label, more-label
description: |
blocks
EOF
+20
View File
@@ -0,0 +1,20 @@
FROM alpine:latest
RUN apk --update add openjdk8-jre curl screen && \
curl -s -L https://marketplace.atlassian.com/download/plugins/atlassian-plugin-sdk-tgz | tar xzf - && \
ln -s /atlassian* /atlassian
ENV PATH=/bin:/usr/bin:/atlassian/bin
# Copy in the serivce and also the root .m2 settings to force cache everything.
# We also copy in /root/.java settings to prevent the dumb spam prompt from
# the atlas-run command:
# Would you like to subscribe to the Atlassian developer mailing list? (Y/y/N/n) Y: :
COPY dockerroot /
WORKDIR /jiratestservice
EXPOSE 8080
# we wrap the command with screen so that the dumb atlas-run has a tty to watch. Without screen
# there is no tty so atlas-run will immediately read an EOF (aka CTRL-D) and interpret that to
# mean we want the service to begin the "graceful shutdown" and exit
CMD ["screen", "-DmL", "atlas-run", "--http-port", "8080", "--context-path", "ROOT", "--server", "localhost"]
+37
View File
@@ -0,0 +1,37 @@
## Tests
The test are written using the `osht` bash testing framework. Please read the [documentation](https://github.com/coryb/osht/blob/master/README.md) for `osht`.
## Running Test:
From the top level of the project you can run:
```
# this creates a local "jira" binary
make
# this runs the integration tests in the "_t" directory
prove
```
### Running individual tests
To run a specific test you can run it directly like:
```
./100basic.t
```
There is a useful `-v` option to make the test more verbose and an `-a` option to casue the test to abort after the first failure.
The tests all require the jira service to be running from the docker container, so you will have to manually run the setup script:
```
./000setup.t
```
After than you can run the other tests over and over. The jira service is just a test instance started for local development. It comes with
a temporary license (I think it is 8 hours) so you will have to run the `./000setup.t` script at least once daily.
## API Documentation:
https://docs.atlassian.com/jira/REST/cloud/
https://docs.atlassian.com/jira-software/REST/cloud
## projectTempalteKey missing documentation
https://answers.atlassian.com/questions/36176301/jira-api-7.1.0-create-project
+6
View File
@@ -0,0 +1,6 @@
To avoid future confusion, we recommend that you include a license with your plugin.
This file is simply a reminder.
For a template license you can have a look at: http://www.opensource.org/licenses/
Atlassian releases most of its modules under the Apache2 license: http://opensource.org/licenses/Apache-2.0
+13
View File
@@ -0,0 +1,13 @@
You have successfully created an Atlassian Plugin!
Here are the SDK commands you'll use immediately:
* atlas-run -- installs this plugin into the product and starts it on localhost
* atlas-debug -- same as atlas-run, but allows a debugger to attach at port 5005
* atlas-cli -- after atlas-run or atlas-debug, opens a Maven command line window:
- 'pi' reinstalls the plugin into the running product instance
* atlas-help -- prints description for all commands in the SDK
Full documentation is always available at:
https://developer.atlassian.com/display/DOCS/Introduction+to+the+Atlassian+Plugin+SDK
+185
View File
@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.netflixskunkworks</groupId>
<artifactId>jiratestservice</artifactId>
<version>1.0</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>jiratestservice</name>
<description>This is the com.netflixskunkworks:jiratestservice plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<applications>
<application>
<applicationKey>jira-software</applicationKey>
<version>${jira.version}</version>
</application>
</applications>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>
com.netflixskunkworks.api,
</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>7.2.0</jira.version>
<amps.version>6.3.15</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
</properties>
</project>
@@ -0,0 +1,7 @@
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
</plugin-info>
</atlassian-plugin>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0">
<entry key="sdk-email-subscribe" value="true"/>
</map>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<map MAP_XML_VERSION="1.0">
<entry key="last_update_check" value="2016-08-29"/>
<entry key="sdk-pom-update-check-6.2.6-cbc3c672c37f65828d50132ed303cf7a" value="true"/>
</map>
+77
View File
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<!-- Default profile containing Atlassian servers -->
<profile>
<id>defaultProfile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>atlassian-public</id>
<url>https://maven.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
<repository>
<id>atlassian-plugin-sdk</id>
<url>file://${env.ATLAS_HOME}/repository</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://maven.atlassian.com/repository/public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>atlassian-plugin-sdk</id>
<url>file://${env.ATLAS_HOME}/repository</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
</settings>
+7
View File
@@ -0,0 +1,7 @@
export COLUMNS=149
export JIRA_LOG_FORMAT="%{level:-5s} %{message}"
export ENDPOINT="https://go-jira.atlassian.net"
export GNUPGHOME=$(pwd)/.gnupg
export PASSWORD_STORE_DIR=$(pwd)/.password-store
export JIRACLOUD=1
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
#dist/github.com/go-jira/jira-darwin-amd64 dist/github.com/go-jira/jira-linux-amd64 dist/github.com/go-jira/jira-windows-amd64.exe
#dist/github.com/go-jira/jira-linux-386 dist/github.com/go-jira/jira-windows-386.exe
EXIT_CODE=0
function error() {
echo $1
EXIT_CODE=1
}
DIST_DIR="dist/github.com/go-jira"
out=`file ${DIST_DIR}/jira-darwin-amd64 2>&1`
if ! [[ "$out" =~ "Mach-O 64-bit" ]]; then
error "darwin/amd64 build not as expected: $out"
fi
out=`file ${DIST_DIR}/jira-linux-amd64 2>&1`
if ! [[ "$out" =~ "ELF 64-bit LSB executable, x86-64" ]]; then
error "linux/amd64 build not as expected: $out"
fi
out=`file ${DIST_DIR}/jira-linux-386 2>&1`
if ! [[ "$out" =~ "ELF 32-bit LSB executable, Intel 80386" ]]; then
error "linux/i386 build not as expected: $out"
fi
out=`file ${DIST_DIR}/jira-windows-amd64.exe 2>&1`
if ! [[ "$out" =~ "PE32+ executable (console) x86-64" ]]; then
error "windows/amd64 build not as expected: $out"
fi
out=`file ${DIST_DIR}/jira-windows-386.exe 2>&1`
if ! [[ "$out" =~ "PE32 executable (console) Intel 80386" ]]; then
error "windows/i386 build not as expected: $out"
fi
exit $EXIT_CODE
+46
View File
@@ -0,0 +1,46 @@
package jira
import (
"encoding/json"
"github.com/go-jira/jira/jiradata"
)
// https://docs.atlassian.com/jira/REST/cloud/#api/2/attachment-getAttachment
func (j *Jira) GetAttachment(id string) (*jiradata.Attachment, error) {
return GetAttachment(j.UA, j.Endpoint, id)
}
func GetAttachment(ua HttpClient, endpoint string, id string) (*jiradata.Attachment, error) {
uri := URLJoin(endpoint, "rest/api/2/attachment", id)
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.Attachment{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/attachment-removeAttachment
func (j *Jira) RemoveAttachment(id string) error {
return RemoveAttachment(j.UA, j.Endpoint, id)
}
func RemoveAttachment(ua HttpClient, endpoint string, id string) error {
uri := URLJoin(endpoint, "rest/api/2/attachment", id)
resp, err := ua.Delete(uri)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
+54
View File
@@ -0,0 +1,54 @@
package main
import (
"os"
"path/filepath"
"reflect"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiracmd"
"gopkg.in/coryb/yaml.v2"
"gopkg.in/op/go-logging.v1"
)
type oreoLogger struct {
logger *logging.Logger
}
var log = logging.MustGetLogger("jira")
func (ol *oreoLogger) Printf(format string, args ...interface{}) {
ol.logger.Debugf(format, args...)
}
func main() {
defer jiracli.HandleExit()
jiracli.InitLogging()
configDir := ".jira.d"
yaml.UseMapType(reflect.TypeOf(map[string]interface{}{}))
defer yaml.RestoreMapType()
fig := figtree.NewFigTree(
figtree.WithHome(jiracli.Homedir()),
figtree.WithEnvPrefix("JIRA"),
figtree.WithConfigDir(configDir),
)
if err := os.MkdirAll(filepath.Join(jiracli.Homedir(), configDir), 0755); err != nil {
log.Errorf("%s", err)
panic(jiracli.Exit{Code: 1})
}
o := oreo.New().WithCookieFile(filepath.Join(jiracli.Homedir(), configDir, "cookies.js")).WithLogger(&oreoLogger{log})
jiracmd.RegisterAllCommands()
app := jiracli.CommandLine(fig, o)
jiracli.ParseCommandLine(app, os.Args[1:])
}
+37
View File
@@ -0,0 +1,37 @@
package jira
import (
"bytes"
"encoding/json"
"github.com/go-jira/jira/jiradata"
)
type ComponentProvider interface {
ProvideComponent() *jiradata.Component
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/component-createComponent
func (j *Jira) CreateComponent(cp ComponentProvider) (*jiradata.Component, error) {
return CreateComponent(j.UA, j.Endpoint, cp)
}
func CreateComponent(ua HttpClient, endpoint string, cp ComponentProvider) (*jiradata.Component, error) {
req := cp.ProvideComponent()
encoded, err := json.Marshal(req)
if err != nil {
return nil, err
}
uri := URLJoin(endpoint, "rest/api/2/component")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 201 {
results := &jiradata.Component{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
+113
View File
@@ -0,0 +1,113 @@
package jira
import (
"bytes"
"encoding/json"
"fmt"
"net/url"
"strings"
"github.com/coryb/oreo"
"github.com/go-jira/jira/jiradata"
)
// https://docs.atlassian.com/jira-software/REST/latest/#agile/1.0/epic-getIssuesForEpic
func (j *Jira) EpicSearch(epic string, sp SearchProvider) (*jiradata.SearchResults, error) {
return EpicSearch(j.UA, j.Endpoint, epic, sp)
}
func EpicSearch(ua HttpClient, endpoint string, epic string, sp SearchProvider) (*jiradata.SearchResults, error) {
req := sp.ProvideSearchRequest()
// encoded, err := json.Marshal(req)
// if err != nil {
// return nil, err
// }
uri, err := url.Parse(URLJoin(endpoint, "rest/agile/1.0/epic", epic, "issue"))
if err != nil {
return nil, err
}
params := url.Values{}
if len(req.Fields) > 0 {
params.Add("fields", strings.Join(req.Fields, ","))
}
if req.JQL != "" {
params.Add("jql", req.JQL)
}
if req.MaxResults != 0 {
params.Add("maxResults", fmt.Sprintf("%d", req.MaxResults))
}
if req.StartAt != 0 {
params.Add("startAt", fmt.Sprintf("%d", req.StartAt))
}
if req.ValidateQuery != "" {
params.Add("validateQuery", req.ValidateQuery)
}
uri.RawQuery = params.Encode()
resp, err := ua.Do(oreo.RequestBuilder(uri).WithHeader("Accept", "application/json").Build())
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.SearchResults{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
type EpicIssuesProvider interface {
ProvideEpicIssues() *jiradata.EpicIssues
}
// https://docs.atlassian.com/jira-software/REST/latest/#agile/1.0/epic-moveIssuesToEpic
func (j *Jira) EpicAddIssues(epic string, eip EpicIssuesProvider) error {
return EpicAddIssues(j.UA, j.Endpoint, epic, eip)
}
func EpicAddIssues(ua HttpClient, endpoint string, epic string, eip EpicIssuesProvider) error {
req := eip.ProvideEpicIssues()
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/agile/1.0/epic", epic, "issue")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira-software/REST/latest/#agile/1.0/epic-removeIssuesFromEpic
func (j *Jira) EpicRemoveIssues(eip EpicIssuesProvider) error {
return EpicRemoveIssues(j.UA, j.Endpoint, eip)
}
func EpicRemoveIssues(ua HttpClient, endpoint string, eip EpicIssuesProvider) error {
req := eip.ProvideEpicIssues()
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/agile/1.0/epic/none/issue")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
+21
View File
@@ -0,0 +1,21 @@
package jira
import (
"encoding/json"
"net/http"
"github.com/go-jira/jira/jiradata"
)
func responseError(resp *http.Response) error {
results := &jiradata.ErrorCollection{}
if err := json.NewDecoder(resp.Body).Decode(results); err != nil {
results.Status = resp.StatusCode
results.ErrorMessages = append(results.ErrorMessages, err.Error())
}
if len(results.ErrorMessages) == 0 && len(results.Errors) == 0 {
results.Status = resp.StatusCode
results.ErrorMessages = append(results.ErrorMessages, resp.Status)
}
return results
}
+26
View File
@@ -0,0 +1,26 @@
package jira
import (
"encoding/json"
"github.com/go-jira/jira/jiradata"
)
// https://docs.atlassian.com/jira/REST/cloud/#api/2/field-getFields
func (j *Jira) GetFields() ([]jiradata.Field, error) {
return GetFields(j.UA, j.Endpoint)
}
func GetFields(ua HttpClient, endpoint string) ([]jiradata.Field, error) {
uri := URLJoin(endpoint, "rest/api/2/field")
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := []jiradata.Field{}
return results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}
+50
View File
@@ -0,0 +1,50 @@
module github.com/go-jira/jira
go 1.12
require (
github.com/Masterminds/goutils v1.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.21.0+incompatible
github.com/Netflix/go-expect v0.0.0-20180928190340-9d1f4485533b // indirect
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/coryb/figtree v1.0.1-0.20190907170512-58176d03ef0d
github.com/coryb/kingpeon v0.0.0-20180107011214-9a669f143f2e
github.com/coryb/oreo v0.0.0-20180804211640-3e1b88fc08f1
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/fatih/camelcase v1.0.0 // indirect
github.com/google/go-cmp v0.5.2
github.com/google/uuid v1.1.1 // indirect
github.com/guelfey/go.dbus v0.0.0-20131113121618-f6a3a2366cc3 // indirect
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c // indirect
github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.7 // indirect
github.com/jinzhu/copier v0.0.0-20180308034124-7e38e58719c3
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/pty v1.1.4 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/mitchellh/go-wordwrap v1.0.1
github.com/olekukonko/tablewriter v0.0.3
github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15
github.com/pkg/errors v0.8.0
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
github.com/theckman/go-flock v0.4.0 // indirect
github.com/tidwall/gjson v0.0.0-20180711011033-ba784d767ac7
github.com/tidwall/match v1.0.0 // indirect
github.com/tmc/keyring v0.0.0-20171121202319-839169085ae1
golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb
golang.org/x/net v0.0.0-20171102191033-01c190206fbd
golang.org/x/sys v0.0.0-20180727230415-bd9dbc187b6e // indirect
gopkg.in/AlecAivazis/survey.v1 v1.6.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/coryb/yaml.v2 v2.0.0-20180616071044-0e40e46f7153
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473
gopkg.in/yaml.v2 v2.2.2 // indirect
)
+96
View File
@@ -0,0 +1,96 @@
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v2.21.0+incompatible h1:nPETddHHEG1ucL7H5t5T95IuWaDe5qB9ImEaztiXgRc=
github.com/Masterminds/sprig v2.21.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/Netflix/go-expect v0.0.0-20180928190340-9d1f4485533b h1:sSQK05nvxs4UkgCJaxihteu+r+6ela3dNMm7NVmsS3c=
github.com/Netflix/go-expect v0.0.0-20180928190340-9d1f4485533b/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/coryb/figtree v1.0.1-0.20190907170512-58176d03ef0d h1:99xxg8FYj+5TYg88DxA4xL8ODuI6OvuSu35WQOVPDPg=
github.com/coryb/figtree v1.0.1-0.20190907170512-58176d03ef0d/go.mod h1:uAkZUEGm6dROpxfy+8vXLs7JrLCI4O+gQyKAuISxI/g=
github.com/coryb/kingpeon v0.0.0-20180107011214-9a669f143f2e h1:tGmk9Tuyz7fKuBq/d3nFJvVWRvc48MEBKQC4uYV3wb0=
github.com/coryb/kingpeon v0.0.0-20180107011214-9a669f143f2e/go.mod h1:gBc0uEH6swbOMoR7VkVuW7w5fGvZu/KHeSgxBR4Ta7Q=
github.com/coryb/oreo v0.0.0-20180804211640-3e1b88fc08f1 h1:Hh0qSvmvoAGL8VxvEoUv9UuUf9XlKcQtSxAMTz1kqfE=
github.com/coryb/oreo v0.0.0-20180804211640-3e1b88fc08f1/go.mod h1:l/wuS2rM8ostk0aApWje8tsZNWJPOc2TVr85B0n3e6M=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/guelfey/go.dbus v0.0.0-20131113121618-f6a3a2366cc3 h1:fngCxKbvZdctIsWj2hYijhAt4iK0JXSSA78B36xP0yI=
github.com/guelfey/go.dbus v0.0.0-20131113121618-f6a3a2366cc3/go.mod h1:0CNX5Cvi77WEH8llpfZ/ieuqyceb1cnO5//b5zzsnF8=
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c h1:kp3AxgXgDOmIJFR7bIwqFhwJ2qWar8tEQSE5XXhCfVk=
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jinzhu/copier v0.0.0-20180308034124-7e38e58719c3 h1:sHsPfNMAG70QAvKbddQ0uScZCHQoZsT5NykGRCeeeIs=
github.com/jinzhu/copier v0.0.0-20180308034124-7e38e58719c3/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.4 h1:5Myjjh3JY/NaAi4IsUbHADytDyl1VE1Y9PXDlL+P/VQ=
github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-runewidth v0.0.6 h1:V2iyH+aX9C5fsYCpK60U8BYIvmhqxuOL3JZcqc1NB7k=
github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
github.com/olekukonko/tablewriter v0.0.3 h1:i0LBnzgiChAWHJYTQAZJDOgf8MNxAVYZJ2m63SIDimI=
github.com/olekukonko/tablewriter v0.0.3/go.mod h1:YZeBtGzYYEsCHp2LST/u/0NDwGkRoBtmn1cIWCJiS6M=
github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15 h1:mrI+6Ae64Wjt+uahGe5we/sPS1sXjvfT3YjtawAVgps=
github.com/pkg/browser v0.0.0-20170505125900-c90ca0c84f15/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/theckman/go-flock v0.4.0 h1:bcqNkS4RTQBGWybG7IBimUMxnLz53Qes1+D4QaOhzJc=
github.com/theckman/go-flock v0.4.0/go.mod h1:kjuth3y9VJ2aNlkNEO99G/8lp9fMIKaGyBmh84IBheM=
github.com/tidwall/gjson v0.0.0-20180711011033-ba784d767ac7 h1:PW7TzL8BOpYMcUYSv4qWDoH1Y5iRzVABteynvfF7pwE=
github.com/tidwall/gjson v0.0.0-20180711011033-ba784d767ac7/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA=
github.com/tidwall/match v1.0.0 h1:Ym1EcFkp+UQ4ptxfWlW+iMdq5cPH5nEuGzdf/Pb7VmI=
github.com/tidwall/match v1.0.0/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
github.com/tmc/keyring v0.0.0-20171121202319-839169085ae1 h1:+gXfyhy0t28Guz+vFztBg45yIquB2bNtiFvbItzJtUc=
github.com/tmc/keyring v0.0.0-20171121202319-839169085ae1/go.mod h1:gsa3jftQ3xia55nzIN4lXLYzDcWdxjojdKoz+N0St2Y=
golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb h1:Ah9YqXLj6fEgeKqcmBuLCbAsrF3ScD7dJ/bYM0C6tXI=
golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20171102191033-01c190206fbd h1:CLQSRrSDQMOMkogMxky7XOkERftMegAnxjT2re4E66M=
golang.org/x/net v0.0.0-20171102191033-01c190206fbd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20180727230415-bd9dbc187b6e h1:3dQ4fR8k5KugjVKO0oqSd1odxuk2yaE2CIfxWP2WarQ=
golang.org/x/sys v0.0.0-20180727230415-bd9dbc187b6e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/AlecAivazis/survey.v1 v1.6.1 h1:HyWkjKGBpzhNxrpaKRLDqoa4L1f4cMVBNU4bnVmU8Mw=
gopkg.in/AlecAivazis/survey.v1 v1.6.1/go.mod h1:2Ehl7OqkBl3Xb8VmC4oFW2bItAhnUfzIjrOzwRxCrOU=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/coryb/yaml.v2 v2.0.0-20180616071044-0e40e46f7153 h1:3KfEubBNUdXqlEXuMz13dXy4cYK2AvuPhp8fKTYuPdU=
gopkg.in/coryb/yaml.v2 v2.0.0-20180616071044-0e40e46f7153/go.mod h1:Vth2iKfSejHZ3p6akgWO0iSjuuiu6mNCEgzcYUCnumw=
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE=
gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+14
View File
@@ -0,0 +1,14 @@
package jira
import (
"io"
"net/http"
)
type HttpClient interface {
Delete(url string) (*http.Response, error)
Do(*http.Request) (*http.Response, error)
GetJSON(url string) (*http.Response, error)
Post(url, bodyType string, body io.Reader) (*http.Response, error)
Put(url, bodyType string, body io.Reader) (*http.Response, error)
}
+648
View File
@@ -0,0 +1,648 @@
package jira
import (
"bytes"
"encoding/json"
"fmt"
"io"
"mime/multipart"
"net/url"
"strings"
"github.com/coryb/oreo"
"github.com/go-jira/jira/jiradata"
)
type IssueQueryProvider interface {
ProvideIssueQueryString() string
}
type IssueOptions struct {
Fields []string `json:"fields,omitempty" yaml:"fields,omitempty"`
Expand []string `json:"expand,omitempty" yaml:"expand,omitempty"`
Properties []string `json:"properties,omitempty" yaml:"properties,omitempty"`
FieldsByKeys bool `json:"fieldsByKeys,omitempty" yaml:"fieldsByKeys,omitempty"`
UpdateHistory bool `json:"updateHistory,omitempty" yaml:"updateHistory,omitempty"`
}
func (o *IssueOptions) ProvideIssueQueryString() string {
params := []string{}
if len(o.Fields) > 0 {
params = append(params, "fields="+strings.Join(o.Fields, ","))
}
if len(o.Expand) > 0 {
params = append(params, "expand="+strings.Join(o.Expand, ","))
}
if len(o.Properties) > 0 {
params = append(params, "properties="+strings.Join(o.Properties, ","))
}
if o.FieldsByKeys {
params = append(params, "fieldsByKeys=true")
}
if o.UpdateHistory {
params = append(params, "updateHistory=true")
}
if len(params) > 0 {
return "?" + strings.Join(params, "&")
}
return ""
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getIssue
func (j *Jira) GetIssue(issue string, iqg IssueQueryProvider) (*jiradata.Issue, error) {
return GetIssue(j.UA, j.Endpoint, issue, iqg)
}
func GetIssue(ua HttpClient, endpoint string, issue string, iqg IssueQueryProvider) (*jiradata.Issue, error) {
query := ""
if iqg != nil {
query = iqg.ProvideIssueQueryString()
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue)
uri += query
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.Issue{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
func (j *Jira) GetIssueWorklog(issue string) (*jiradata.Worklogs, error) {
return GetIssueWorklog(j.UA, j.Endpoint, issue)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/worklog-getIssueWorklog
func GetIssueWorklog(ua HttpClient, endpoint string, issue string) (*jiradata.Worklogs, error) {
startAt := 0
total := 1
maxResults := 100
worklogs := jiradata.Worklogs{}
for startAt < total {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "worklog")
uri += fmt.Sprintf("?startAt=%d&maxResults=%d", startAt, maxResults)
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.WorklogWithPagination{}
err := json.NewDecoder(resp.Body).Decode(results)
if err != nil {
return nil, err
}
startAt = startAt + maxResults
total = results.Total
worklogs = append(worklogs, results.Worklogs...)
} else {
return nil, responseError(resp)
}
}
return &worklogs, nil
}
func (j *Jira) GetIssueComment(issue string) (*jiradata.Comments, error) {
return GetIssueComment(j.UA, j.Endpoint, issue)
}
// https://docs.atlassian.com/software/jira/docs/api/REST/7.12.0/#api/2/issue-getComments
func GetIssueComment(ua HttpClient, endpoint string, issue string) (*jiradata.Comments, error) {
startAt := 0
total := 1
maxResults := 100
comments := jiradata.Comments{}
for startAt < total {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "comment")
uri += fmt.Sprintf("?startAt=%d&maxResults=%d", startAt, maxResults)
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.CommentsWithPagination{}
err := json.NewDecoder(resp.Body).Decode(results)
if err != nil {
return nil, err
}
startAt = startAt + maxResults
total = results.Total
comments = append(comments, results.Comments...)
} else {
return nil, responseError(resp)
}
}
return &comments, nil
}
type WorklogProvider interface {
ProvideWorklog() *jiradata.Worklog
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/worklog-addWorklog
func (j *Jira) AddIssueWorklog(issue string, wp WorklogProvider) (*jiradata.Worklog, error) {
return AddIssueWorklog(j.UA, j.Endpoint, issue, wp)
}
func AddIssueWorklog(ua HttpClient, endpoint string, issue string, wp WorklogProvider) (*jiradata.Worklog, error) {
req := wp.ProvideWorklog()
encoded, err := json.Marshal(req)
if err != nil {
return nil, err
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "worklog")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 201 {
results := &jiradata.Worklog{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getEditIssueMeta
func (j *Jira) GetIssueEditMeta(issue string) (*jiradata.EditMeta, error) {
return GetIssueEditMeta(j.UA, j.Endpoint, issue)
}
func GetIssueEditMeta(ua HttpClient, endpoint string, issue string) (*jiradata.EditMeta, error) {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "editmeta")
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.EditMeta{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
type IssueUpdateProvider interface {
ProvideIssueUpdate() *jiradata.IssueUpdate
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-editIssue
func (j *Jira) EditIssue(issue string, iup IssueUpdateProvider) error {
return EditIssue(j.UA, j.Endpoint, issue, iup)
}
func EditIssue(ua HttpClient, endpoint string, issue string, iup IssueUpdateProvider) error {
req := iup.ProvideIssueUpdate()
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue)
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-createIssue
func (j *Jira) CreateIssue(iup IssueUpdateProvider) (*jiradata.IssueCreateResponse, error) {
return CreateIssue(j.UA, j.Endpoint, iup)
}
func CreateIssue(ua HttpClient, endpoint string, iup IssueUpdateProvider) (*jiradata.IssueCreateResponse, error) {
req := iup.ProvideIssueUpdate()
encoded, err := json.Marshal(req)
if err != nil {
return nil, err
}
uri := URLJoin(endpoint, "rest/api/2/issue")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 201 {
results := &jiradata.IssueCreateResponse{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getCreateIssueMeta
func (j *Jira) GetIssueCreateMetaProject(projectKey string) (*jiradata.CreateMetaProject, error) {
return GetIssueCreateMetaProject(j.UA, j.Endpoint, projectKey)
}
func GetIssueCreateMetaProject(ua HttpClient, endpoint string, projectKey string) (*jiradata.CreateMetaProject, error) {
uri := URLJoin(endpoint, "rest/api/2/issue/createmeta")
uri += fmt.Sprintf("?projectKeys=%s&expand=projects.issuetypes.fields", projectKey)
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.CreateMeta{}
err = json.NewDecoder(resp.Body).Decode(results)
if err != nil {
return nil, err
}
for _, project := range results.Projects {
if project.Key == projectKey {
return project, nil
}
}
return nil, fmt.Errorf("project %s not found", projectKey)
}
return nil, responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getCreateIssueMeta
func (j *Jira) GetIssueCreateMetaIssueType(projectKey, issueTypeName string) (*jiradata.IssueType, error) {
return GetIssueCreateMetaIssueType(j.UA, j.Endpoint, projectKey, issueTypeName)
}
func GetIssueCreateMetaIssueType(ua HttpClient, endpoint string, projectKey, issueTypeName string) (*jiradata.IssueType, error) {
uri := URLJoin(endpoint, "rest/api/2/issue/createmeta")
uri += fmt.Sprintf("?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", projectKey, url.QueryEscape(issueTypeName))
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, responseError(resp)
}
results := &jiradata.CreateMeta{}
if err := json.NewDecoder(resp.Body).Decode(results); err != nil {
return nil, err
}
for _, project := range results.Projects {
if project.Key != projectKey {
continue
}
for _, issueType := range project.IssueTypes {
if issueType.Name == issueTypeName {
return issueType, nil
}
}
}
return nil, fmt.Errorf("project %s and IssueType %s not found", projectKey, issueTypeName)
}
type LinkIssueProvider interface {
ProvideLinkIssueRequest() *jiradata.LinkIssueRequest
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issueLink-linkIssues
func (j *Jira) LinkIssues(lip LinkIssueProvider) error {
return LinkIssues(j.UA, j.Endpoint, lip)
}
func LinkIssues(ua HttpClient, endpoint string, lip LinkIssueProvider) error {
req := lip.ProvideLinkIssueRequest()
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/api/2/issueLink")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 201 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getTransitions
func (j *Jira) GetIssueTransitions(issue string) (*jiradata.TransitionsMeta, error) {
return GetIssueTransitions(j.UA, j.Endpoint, issue)
}
func GetIssueTransitions(ua HttpClient, endpoint string, issue string) (*jiradata.TransitionsMeta, error) {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "transitions")
uri += "?expand=transitions.fields"
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := &jiradata.TransitionsMeta{}
return results, json.NewDecoder(resp.Body).Decode(results)
}
return nil, responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-doTransition
func (j *Jira) TransitionIssue(issue string, iup IssueUpdateProvider) error {
return TransitionIssue(j.UA, j.Endpoint, issue, iup)
}
func TransitionIssue(ua HttpClient, endpoint string, issue string, iup IssueUpdateProvider) error {
req := iup.ProvideIssueUpdate()
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "transitions")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issueLinkType-getIssueLinkTypes
func (j *Jira) GetIssueLinkTypes() (*jiradata.IssueLinkTypes, error) {
return GetIssueLinkTypes(j.UA, j.Endpoint)
}
func GetIssueLinkTypes(ua HttpClient, endpoint string) (*jiradata.IssueLinkTypes, error) {
uri := URLJoin(endpoint, "rest/api/2/issueLinkType")
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := struct {
IssueLinkTypes jiradata.IssueLinkTypes
}{
IssueLinkTypes: jiradata.IssueLinkTypes{},
}
return &results.IssueLinkTypes, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-addVote
func (j *Jira) IssueAddVote(issue string) error {
return IssueAddVote(j.UA, j.Endpoint, issue)
}
func IssueAddVote(ua HttpClient, endpoint string, issue string) error {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "votes")
resp, err := ua.Post(uri, "application/json", strings.NewReader("{}"))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-removeVote
func (j *Jira) IssueRemoveVote(issue string) error {
return IssueRemoveVote(j.UA, j.Endpoint, issue)
}
func IssueRemoveVote(ua HttpClient, endpoint string, issue string) error {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "votes")
resp, err := ua.Delete(uri)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
type RankRequestProvider interface {
ProvideRankRequest() *jiradata.RankRequest
}
// https://docs.atlassian.com/jira-software/REST/cloud/#agile/1.0/issue-rankIssues
func (j *Jira) RankIssues(rrp RankRequestProvider) error {
return RankIssues(j.UA, j.Endpoint, rrp)
}
func RankIssues(ua HttpClient, endpoint string, rrp RankRequestProvider) error {
req := rrp.ProvideRankRequest()
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/agile/1.0/issue/rank")
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-addWatcher
func (j *Jira) IssueAddWatcher(issue, user string) error {
return IssueAddWatcher(j.UA, j.Endpoint, issue, user)
}
func IssueAddWatcher(ua HttpClient, endpoint string, issue, user string) error {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "watchers")
resp, err := ua.Post(uri, "application/json", strings.NewReader(fmt.Sprintf("%q", user)))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-addWatcher
func (j *Jira) IssueRemoveWatcher(issue, user string) error {
return IssueRemoveWatcher(j.UA, j.Endpoint, issue, user)
}
func IssueRemoveWatcher(ua HttpClient, endpoint string, issue, user string) error {
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "watchers")
uri += fmt.Sprintf("?accountId=%s", user)
resp, err := ua.Delete(uri)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
type CommentProvider interface {
ProvideComment() *jiradata.Comment
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/comment-addComment
func (j *Jira) IssueAddComment(issue string, cp CommentProvider) (*jiradata.Comment, error) {
return IssueAddComment(j.UA, j.Endpoint, issue, cp)
}
func IssueAddComment(ua HttpClient, endpoint string, issue string, cp CommentProvider) (*jiradata.Comment, error) {
req := cp.ProvideComment()
encoded, err := json.Marshal(req)
if err != nil {
return nil, err
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "comment")
resp, err := ua.Post(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 201 {
results := jiradata.Comment{}
return &results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}
type UserProvider interface {
ProvideUser() *jiradata.User
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-assign
func (j *Jira) IssueAssign(issue, name string) error {
return IssueAssign(j.UA, j.Endpoint, issue, name)
}
func IssueAssign(ua HttpClient, endpoint string, issue, name string) error {
// this is special, not using the jiradata.User structure
// because we need to be able to send `null` as the name param
// when we want to un-assign the issue
req := struct {
Name *string `json:"name"`
}{&name}
if name == "" {
req.Name = nil
}
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "assignee")
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
func IssueAssignAccountID(ua HttpClient, endpoint string, issue, acctId string) error {
// this is special, not using the jiradata.User structure
// because we need to be able to send `null` as the name param
// when we want to un-assign the issue
req := struct {
AccountID *string `json:"accountId"`
}{&acctId}
if acctId == "" {
req.AccountID = nil
}
encoded, err := json.Marshal(req)
if err != nil {
return err
}
uri := URLJoin(endpoint, "rest/api/2/issue", issue, "assignee")
resp, err := ua.Put(uri, "application/json", bytes.NewBuffer(encoded))
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 204 {
return nil
}
return responseError(resp)
}
// https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/attachments-addAttachment
func (j *Jira) IssueAttachFile(issue, filename string, contents io.Reader) (*jiradata.ListOfAttachment, error) {
return IssueAttachFile(j.UA, j.Endpoint, issue, filename, contents)
}
func IssueAttachFile(ua HttpClient, endpoint string, issue, filename string, contents io.Reader) (*jiradata.ListOfAttachment, error) {
var buf bytes.Buffer
w := multipart.NewWriter(&buf)
formFile, err := w.CreateFormFile("file", filename)
if err != nil {
return nil, err
}
_, err = io.Copy(formFile, contents)
if err != nil {
return nil, err
}
uri, err := url.Parse(URLJoin(endpoint, "rest/api/2/issue", issue, "attachments"))
if err != nil {
return nil, err
}
req := oreo.RequestBuilder(uri).WithMethod("POST").WithHeader(
"X-Atlassian-Token", "no-check",
).WithHeader(
"Accept", "application/json",
).WithContentType(w.FormDataContentType()).WithBody(&buf).Build()
w.Close()
resp, err := ua.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := jiradata.ListOfAttachment{}
return &results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}
+20
View File
@@ -0,0 +1,20 @@
package jira
import (
"github.com/coryb/oreo"
)
// replace by ldflags
var VERSION = "development"
type Jira struct {
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
UA HttpClient `json:"-" yaml:"-"`
}
func NewJira(endpoint string) *Jira {
return &Jira{
Endpoint: endpoint,
UA: oreo.New(),
}
}
-329
View File
@@ -1,329 +0,0 @@
package cli
import (
"bytes"
"encoding/json"
"fmt"
"github.com/kballard/go-shellquote"
"github.com/op/go-logging"
"gopkg.in/yaml.v2"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
"os"
"os/exec"
"runtime"
"strings"
"time"
)
var log = logging.MustGetLogger("jira.cli")
type Cli struct {
endpoint *url.URL
opts map[string]string
cookieFile string
ua *http.Client
}
func New(opts map[string]string) *Cli {
homedir := os.Getenv("HOME")
cookieJar, _ := cookiejar.New(nil)
endpoint, _ := opts["endpoint"]
url, _ := url.Parse(strings.TrimRight(endpoint, "/"))
if project, ok := opts["project"]; ok {
opts["project"] = strings.ToUpper(project)
}
cli := &Cli{
endpoint: url,
opts: opts,
cookieFile: fmt.Sprintf("%s/.jira.d/cookies.js", homedir),
ua: &http.Client{Jar: cookieJar},
}
cli.ua.Jar.SetCookies(url, cli.loadCookies())
return cli
}
func (c *Cli) saveCookies(cookies []*http.Cookie) {
// expiry in one week from now
expiry := time.Now().Add(24 * 7 * time.Hour)
for _, cookie := range cookies {
cookie.Expires = expiry
}
if currentCookies := c.loadCookies(); currentCookies != nil {
currentCookiesByName := make(map[string]*http.Cookie)
for _, cookie := range currentCookies {
currentCookiesByName[cookie.Name] = cookie
}
for _, cookie := range cookies {
currentCookiesByName[cookie.Name] = cookie
}
mergedCookies := make([]*http.Cookie, 0, len(currentCookiesByName))
for _, v := range currentCookiesByName {
mergedCookies = append(mergedCookies, v)
}
jsonWrite(c.cookieFile, mergedCookies)
} else {
jsonWrite(c.cookieFile, cookies)
}
}
func (c *Cli) loadCookies() []*http.Cookie {
bytes, err := ioutil.ReadFile(c.cookieFile)
if err != nil && os.IsNotExist(err) {
// dont load cookies if the file does not exist
return nil
}
if err != nil {
log.Error("Failed to open %s: %s", c.cookieFile, err)
os.Exit(1)
}
cookies := make([]*http.Cookie, 0)
err = json.Unmarshal(bytes, &cookies)
if err != nil {
log.Error("Failed to parse json from file %s: %s", c.cookieFile, err)
}
log.Debug("Loading Cookies: %s", cookies)
return cookies
}
func (c *Cli) post(uri string, content string) (*http.Response, error) {
return c.makeRequestWithContent("POST", uri, content)
}
func (c *Cli) put(uri string, content string) (*http.Response, error) {
return c.makeRequestWithContent("PUT", uri, content)
}
func (c *Cli) makeRequestWithContent(method string, uri string, content string) (*http.Response, error) {
buffer := bytes.NewBufferString(content)
req, _ := http.NewRequest(method, uri, buffer)
log.Info("%s %s", req.Method, req.URL.String())
if log.IsEnabledFor(logging.DEBUG) {
logBuffer := bytes.NewBuffer(make([]byte, 0, len(content)))
req.Write(logBuffer)
log.Debug("%s", logBuffer)
// need to recreate the buffer since the offset is now at the end
// need to be able to rewind the buffer offset, dont know how yet
req, _ = http.NewRequest(method, uri, bytes.NewBufferString(content))
}
if resp, err := c.makeRequest(req); err != nil {
return nil, err
} else {
if resp.StatusCode == 401 {
if err := c.CmdLogin(); err != nil {
return nil, err
}
req, _ = http.NewRequest(method, uri, bytes.NewBufferString(content))
return c.makeRequest(req)
}
return resp, err
}
}
func (c *Cli) get(uri string) (*http.Response, error) {
req, _ := http.NewRequest("GET", uri, nil)
log.Info("%s %s", req.Method, req.URL.String())
if log.IsEnabledFor(logging.DEBUG) {
logBuffer := bytes.NewBuffer(make([]byte, 0))
req.Write(logBuffer)
log.Debug("%s", logBuffer)
}
if resp, err := c.makeRequest(req); err != nil {
return nil, err
} else {
if resp.StatusCode == 401 {
if err := c.CmdLogin(); err != nil {
return nil, err
}
return c.makeRequest(req)
}
return resp, err
}
}
func (c *Cli) makeRequest(req *http.Request) (resp *http.Response, err error) {
req.Header.Set("Content-Type", "application/json")
if resp, err = c.ua.Do(req); err != nil {
log.Error("Failed to %s %s: %s", req.Method, req.URL.String(), err)
return nil, err
} else {
if resp.StatusCode < 200 || resp.StatusCode >= 300 && resp.StatusCode != 401 {
log.Error("response status: %s", resp.Status)
}
runtime.SetFinalizer(resp, func(r *http.Response) {
r.Body.Close()
})
if _, ok := resp.Header["Set-Cookie"]; ok {
c.saveCookies(resp.Cookies())
}
}
return resp, nil
}
func (c *Cli) getTemplate(name string) string {
if override, ok := c.opts["template"]; ok {
if _, err := os.Stat(override); err == nil {
return readFile(override)
} else {
if file, err := FindClosestParentPath(fmt.Sprintf(".jira.d/templates/%s", override)); err == nil {
return readFile(file)
}
if dflt, ok := all_templates[override]; ok {
return dflt
}
}
}
if file, err := FindClosestParentPath(fmt.Sprintf(".jira.d/templates/%s", name)); err != nil {
// create-bug etc are special, if we dont find it in the path
// then just return a generic create template
if strings.HasPrefix(name, "create-") {
if file, err := FindClosestParentPath(".jira.d/templates/create"); err != nil {
return all_templates["create"]
} else {
return readFile(file)
}
}
return all_templates[name]
} else {
return readFile(file)
}
}
func (c *Cli) editTemplate(template string, tmpFilePrefix string, templateData map[string]interface{}, templateProcessor func(string) error) error {
tmpdir := fmt.Sprintf("%s/.jira.d/tmp", os.Getenv("HOME"))
if err := mkdir(tmpdir); err != nil {
return err
}
fh, err := ioutil.TempFile(tmpdir, tmpFilePrefix)
if err != nil {
log.Error("Failed to make temp file in %s: %s", tmpdir, err)
return err
}
defer fh.Close()
tmpFileName := fmt.Sprintf("%s.yml", fh.Name())
if err := os.Rename(fh.Name(), tmpFileName); err != nil {
log.Error("Failed to rename %s to %s: %s", fh.Name(), fmt.Sprintf("%s.yml", fh.Name()), err)
return err
}
err = runTemplate(template, templateData, fh)
if err != nil {
return err
}
fh.Close()
editor, ok := c.opts["editor"]
if !ok {
editor = os.Getenv("JIRA_EDITOR")
if editor == "" {
editor = os.Getenv("EDITOR")
if editor == "" {
editor = "vim"
}
}
}
editing := true
if val, ok := c.opts["edit"]; ok && val == "false" {
editing = false
}
for true {
if editing {
shell, _ := shellquote.Split(editor)
shell = append(shell, tmpFileName)
log.Debug("Running: %#v", shell)
cmd := exec.Command(shell[0], shell[1:]...)
cmd.Stdout, cmd.Stderr, cmd.Stdin = os.Stdout, os.Stderr, os.Stdin
if err := cmd.Run(); err != nil {
log.Error("Failed to edit template with %s: %s", editor, err)
if promptYN("edit again?", true) {
continue
}
return err
}
}
edited := make(map[string]interface{})
if fh, err := ioutil.ReadFile(tmpFileName); err != nil {
log.Error("Failed to read tmpfile %s: %s", tmpFileName, err)
if editing && promptYN("edit again?", true) {
continue
}
return err
} else {
if err := yaml.Unmarshal(fh, &edited); err != nil {
log.Error("Failed to parse YAML: %s", err)
if editing && promptYN("edit again?", true) {
continue
}
return err
}
}
if fixed, err := yamlFixup(edited); err != nil {
return err
} else {
edited = fixed.(map[string]interface{})
}
if _, ok := templateData["meta"]; ok {
mf := templateData["meta"].(map[string]interface{})["fields"]
if f, ok := edited["fields"].(map[string]interface{}); ok {
for k := range f {
if _, ok := mf.(map[string]interface{})[k]; !ok {
err := fmt.Errorf("Field %s is not editable", k)
log.Error("%s", err)
if editing && promptYN("edit again?", true) {
continue
}
return err
}
}
}
}
json, err := jsonEncode(edited)
if err != nil {
return err
}
if err := templateProcessor(json); err != nil {
log.Error("%s", err)
if editing && promptYN("edit again?", true) {
continue
}
}
return nil
}
return nil
}
func (c *Cli) Browse(issue string) error {
if val, ok := c.opts["browse"]; ok && val == "true" {
if runtime.GOOS == "darwin" {
return exec.Command("open", fmt.Sprintf("%s/browse/%s", c.endpoint, issue)).Run()
} else if runtime.GOOS == "linux" {
return exec.Command("xdg-open", fmt.Sprintf("%s/browse/%s", c.endpoint, issue)).Run()
}
}
return nil
}
-590
View File
@@ -1,590 +0,0 @@
package cli
import (
"bytes"
"code.google.com/p/gopass"
"fmt"
"net/http"
"os"
"strings"
// "github.com/kr/pretty"
)
func (c *Cli) CmdLogin() error {
uri := fmt.Sprintf("%s/rest/auth/1/session", c.endpoint)
for true {
req, _ := http.NewRequest("GET", uri, nil)
user, _ := c.opts["user"]
prompt := fmt.Sprintf("Enter Password for %s: ", user)
passwd, _ := gopass.GetPass(prompt)
req.SetBasicAuth(user, passwd)
if resp, err := c.makeRequest(req); err != nil {
return err
} else {
if resp.StatusCode == 403 {
// probably got this, need to redirect the user to login manually
// X-Authentication-Denied-Reason: CAPTCHA_CHALLENGE; login-url=https://jira/login.jsp
if reason := resp.Header.Get("X-Authentication-Denied-Reason"); reason != "" {
err := fmt.Errorf("Authenticaion Failed: %s", reason)
log.Error("%s", err)
return err
}
err := fmt.Errorf("Authentication Failed: Unknown Reason")
log.Error("%s", err)
return err
} else if resp.StatusCode == 200 {
// https://confluence.atlassian.com/display/JIRA043/JIRA+REST+API+%28Alpha%29+Tutorial#JIRARESTAPI%28Alpha%29Tutorial-CAPTCHAs
// probably bad password, try again
if reason := resp.Header.Get("X-Seraph-Loginreason"); reason == "AUTHENTICATION_DENIED" {
log.Warning("Authentication Failed: %s", reason)
continue
}
} else {
log.Warning("Login failed")
continue
}
}
return nil
}
return nil
}
func (c *Cli) CmdFields() error {
log.Debug("fields called")
uri := fmt.Sprintf("%s/rest/api/2/field", c.endpoint)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("fields"), data, nil)
}
func (c *Cli) CmdList() error {
log.Debug("list called")
var query string
var ok bool
// project = BAKERY and status not in (Resolved, Closed)
if query, ok = c.opts["query"]; !ok {
qbuff := bytes.NewBufferString("resolution = unresolved")
if project, ok := c.opts["project"]; !ok {
err := fmt.Errorf("Missing required arguments, either 'query' or 'project' are required")
log.Error("%s", err)
return err
} else {
qbuff.WriteString(fmt.Sprintf(" AND project = '%s'", project))
}
if component, ok := c.opts["component"]; ok {
qbuff.WriteString(fmt.Sprintf(" AND component = '%s'", component))
}
if assignee, ok := c.opts["assignee"]; ok {
qbuff.WriteString(fmt.Sprintf(" AND assignee = '%s'", assignee))
}
if issuetype, ok := c.opts["issuetype"]; ok {
qbuff.WriteString(fmt.Sprintf(" AND issuetype = '%s'", issuetype))
}
if watcher, ok := c.opts["watcher"]; ok {
qbuff.WriteString(fmt.Sprintf(" AND watcher = '%s'", watcher))
}
if reporter, ok := c.opts["reporter"]; ok {
qbuff.WriteString(fmt.Sprintf(" AND reporter = '%s'", reporter))
}
query = qbuff.String()
}
fields := make([]string, 0)
if qf, ok := c.opts["queryfields"]; ok {
fields = strings.Split(qf, ",")
} else {
fields = append(fields, "summary")
}
json, err := jsonEncode(map[string]interface{}{
"jql": query,
"startAt": "0",
"maxResults": "500",
"fields": fields,
})
if err != nil {
return err
}
uri := fmt.Sprintf("%s/rest/api/2/search", c.endpoint)
data, err := responseToJson(c.post(uri, json))
if err != nil {
return err
}
return runTemplate(c.getTemplate("list"), data, nil)
}
func (c *Cli) CmdView(issue string) error {
log.Debug("view called")
c.Browse(issue)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s", c.endpoint, issue)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("view"), data, nil)
}
func (c *Cli) CmdEdit(issue string) error {
log.Debug("edit called")
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/editmeta", c.endpoint, issue)
editmeta, err := responseToJson(c.get(uri))
if err != nil {
return err
}
uri = fmt.Sprintf("%s/rest/api/2/issue/%s", c.endpoint, issue)
var issueData map[string]interface{}
if data, err := responseToJson(c.get(uri)); err != nil {
return err
} else {
issueData = data.(map[string]interface{})
}
issueData["meta"] = editmeta.(map[string]interface{})
issueData["overrides"] = c.opts
return c.editTemplate(
c.getTemplate("edit"),
fmt.Sprintf("%s-edit-", issue),
issueData,
func(json string) error {
resp, err := c.put(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 204 {
c.Browse(issueData["key"].(string))
fmt.Printf("OK %s %s/browse/%s\n", issueData["key"], c.endpoint, issueData["key"])
return nil
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From PUT")
log.Error("%s:\n%s", err, logBuffer)
return err
}
},
)
}
func (c *Cli) CmdEditMeta(issue string) error {
log.Debug("editMeta called")
c.Browse(issue)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/editmeta", c.endpoint, issue)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("editmeta"), data, nil)
}
func (c *Cli) CmdTransitionMeta(issue string) error {
log.Debug("tranisionMeta called")
c.Browse(issue)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions?expand=transitions.fields", c.endpoint, issue)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("transmeta"), data, nil)
}
func (c *Cli) CmdIssueTypes(project string) error {
log.Debug("issueTypes called")
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s", c.endpoint, project)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("issuetypes"), data, nil)
}
func (c *Cli) CmdCreateMeta(project string, issuetype string) error {
log.Debug("createMeta called")
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", c.endpoint, project, issuetype)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
if val, ok := data.(map[string]interface{})["projects"]; ok {
if len(val.([]interface{})) == 0 {
err = fmt.Errorf("Project '%s' or issuetype '%s' unknown. Unable to createmeta.", project, issuetype)
log.Error("%s", err)
return err
}
if val, ok = val.([]interface{})[0].(map[string]interface{})["issuetypes"]; ok {
data = val.([]interface{})[0]
}
}
return runTemplate(c.getTemplate("createmeta"), data, nil)
}
func (c *Cli) CmdTransitions(issue string) error {
log.Debug("Transitions called")
c.Browse(issue)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions", c.endpoint, issue)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("transitions"), data, nil)
}
func (c *Cli) CmdCreate(project string, issuetype string) error {
log.Debug("create called")
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", c.endpoint, project, issuetype)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
issueData := make(map[string]interface{})
issueData["overrides"] = c.opts
issueData["overrides"].(map[string]string)["issuetype"] = issuetype
if val, ok := data.(map[string]interface{})["projects"]; ok {
if len(val.([]interface{})) == 0 {
err = fmt.Errorf("Project '%s' or issuetype '%s' unknown. Unable to create issue.", project, issuetype)
log.Error("%s", err)
return err
}
if val, ok = val.([]interface{})[0].(map[string]interface{})["issuetypes"]; ok {
issueData["meta"] = val.([]interface{})[0]
}
}
sanitizedType := strings.ToLower(strings.Replace(issuetype, " ", "", -1))
return c.editTemplate(
c.getTemplate(fmt.Sprintf("create-%s", sanitizedType)),
fmt.Sprintf("create-%s-", sanitizedType),
issueData,
func(json string) error {
log.Debug("JSON: %s", json)
uri := fmt.Sprintf("%s/rest/api/2/issue", c.endpoint)
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 201 {
// response: {"id":"410836","key":"PROJ-238","self":"https://jira/rest/api/2/issue/410836"}
if json, err := responseToJson(resp, nil); err != nil {
return err
} else {
key := json.(map[string]interface{})["key"]
c.Browse(key.(string))
fmt.Printf("OK %s %s/browse/%s\n", key, c.endpoint, key)
}
return nil
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Error("%s:\n%s", err, logBuffer)
return err
}
},
)
return nil
}
func (c *Cli) CmdIssueLinkTypes() error {
log.Debug("Transitions called")
uri := fmt.Sprintf("%s/rest/api/2/issueLinkType", c.endpoint)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
return runTemplate(c.getTemplate("issuelinktypes"), data, nil)
}
func (c *Cli) CmdBlocks(blocker string, issue string) error {
log.Debug("blocks called")
json, err := jsonEncode(map[string]interface{}{
"type": map[string]string{
"name": "Depends", // TODO This is probably not constant across Jira installs
},
"inwardIssue": map[string]string{
"key": issue,
},
"outwardIssue": map[string]string{
"key": blocker,
},
})
if err != nil {
return err
}
uri := fmt.Sprintf("%s/rest/api/2/issueLink", c.endpoint)
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 201 {
c.Browse(issue)
fmt.Printf("OK %s %s/browse/%s\n", issue, c.endpoint, issue)
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Error("%s:\n%s", err, logBuffer)
return err
}
return nil
}
func (c *Cli) CmdDups(duplicate string, issue string) error {
log.Debug("dups called")
json, err := jsonEncode(map[string]interface{}{
"type": map[string]string{
"name": "Duplicate", // TODO This is probably not constant across Jira installs
},
"inwardIssue": map[string]string{
"key": duplicate,
},
"outwardIssue": map[string]string{
"key": issue,
},
})
if err != nil {
return err
}
uri := fmt.Sprintf("%s/rest/api/2/issueLink", c.endpoint)
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 201 {
c.Browse(issue)
fmt.Printf("OK %s %s/browse/%s\n", issue, c.endpoint, issue)
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Error("%s:\n%s", err, logBuffer)
return err
}
return nil
}
func (c *Cli) CmdWatch(issue string, watcher string) error {
log.Debug("watch called")
json, err := jsonEncode(watcher)
if err != nil {
return err
}
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/watchers", c.endpoint, issue)
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 204 {
c.Browse(issue)
fmt.Printf("OK %s %s/browse/%s\n", issue, c.endpoint, issue)
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Error("%s:\n%s", err, logBuffer)
return err
}
return nil
}
func (c *Cli) CmdTransition(issue string, trans string) error {
log.Debug("transition called")
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/transitions?expand=transitions.fields", c.endpoint, issue)
data, err := responseToJson(c.get(uri))
if err != nil {
return err
}
transitions := data.(map[string]interface{})["transitions"].([]interface{})
var transId, transName string
var transMeta map[string]interface{}
found := make([]string, 0, len(transitions))
for _, transition := range transitions {
name := transition.(map[string]interface{})["name"].(string)
id := transition.(map[string]interface{})["id"].(string)
found = append(found, name)
if strings.Contains(strings.ToLower(name), trans) {
transName = name
transId = id
transMeta = transition.(map[string]interface{})
}
}
if transId == "" {
err := fmt.Errorf("Invalid Transition '%s', Available: %s", trans, strings.Join(found, ", "))
log.Error("%s", err)
return err
}
handlePost := func(json string) error {
log.Debug("POST: %s", json)
// os.Exit(0)
uri = fmt.Sprintf("%s/rest/api/2/issue/%s/transitions", c.endpoint, issue)
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 204 {
c.Browse(issue)
fmt.Printf("OK %s %s/browse/%s\n", issue, c.endpoint, issue)
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Error("%s:\n%s", err, logBuffer)
return err
}
return nil
}
uri = fmt.Sprintf("%s/rest/api/2/issue/%s", c.endpoint, issue)
var issueData map[string]interface{}
if data, err := responseToJson(c.get(uri)); err != nil {
return err
} else {
issueData = data.(map[string]interface{})
}
issueData["meta"] = transMeta
issueData["overrides"] = c.opts
issueData["transition"] = map[string]interface{}{
"name": transName,
"id": transId,
}
return c.editTemplate(
c.getTemplate("transition"),
fmt.Sprintf("%s-trans-%s-", issue, trans),
issueData,
handlePost,
)
}
func (c *Cli) CmdComment(issue string) error {
log.Debug("comment called")
handlePost := func(json string) error {
log.Debug("JSON: %s", json)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/comment", c.endpoint, issue)
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 201 {
c.Browse(issue)
fmt.Printf("OK %s %s/browse/%s\n", issue, c.endpoint, issue)
return nil
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Error("%s:\n%s", err, logBuffer)
return err
}
}
if comment, ok := c.opts["comment"]; ok && comment != "" {
json, err := jsonEncode(map[string]interface{}{
"body": comment,
})
if err != nil {
return err
}
return handlePost(json)
} else {
return c.editTemplate(
c.getTemplate("comment"),
fmt.Sprintf("%s-create-", issue),
map[string]interface{}{},
handlePost,
)
}
return nil
}
func (c *Cli) CmdAssign(issue string, user string) error {
log.Debug("assign called")
json, err := jsonEncode(map[string]interface{}{
"name": user,
})
if err != nil {
return err
}
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/assignee", c.endpoint, issue)
resp, err := c.put(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 204 {
c.Browse(issue)
fmt.Printf("OK %s %s/browse/%s\n", issue, c.endpoint, issue)
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From PUT")
log.Error("%s:\n%s", err, logBuffer)
return err
}
return nil
}
func (c *Cli) CmdExportTemplates() error {
dir := c.opts["directory"]
if err := mkdir(dir); err != nil {
return err
}
for name, template := range all_templates {
if wanted, ok := c.opts["template"]; ok && wanted != name {
continue
}
templateFile := fmt.Sprintf("%s/%s", dir, name)
if _, err := os.Stat(templateFile); err == nil {
log.Warning("Skipping %s, already exists", templateFile)
continue
}
if fh, err := os.OpenFile(templateFile, os.O_WRONLY|os.O_CREATE, 0644); err != nil {
log.Error("Failed to open %s for writing: %s", templateFile, err)
return err
} else {
defer fh.Close()
log.Notice("Creating %s", templateFile)
fh.Write([]byte(template))
}
}
return nil
}
-141
View File
@@ -1,141 +0,0 @@
package cli
var all_templates = map[string]string{
"debug": default_debug_template,
"fields": default_debug_template,
"editmeta": default_debug_template,
"transmeta": default_debug_template,
"createmeta": default_debug_template,
"issuelinktypes": default_debug_template,
"list": default_list_template,
"table": default_table_template,
"view": default_view_template,
"edit": default_edit_template,
"transitions": default_transitions_template,
"issuetypes": default_issuetypes_template,
"create": default_create_template,
"comment": default_comment_template,
"transition": default_transition_template,
}
const default_debug_template = "{{ . | toJson}}\n"
const default_list_template = "{{ range .issues }}{{ .key | append \":\" | printf \"%-12s\"}} {{ .fields.summary }}\n{{ end }}"
const default_table_template = `+{{ "-" | rep 16 }}+{{ "-" | rep 57 }}+{{ "-" | rep 14 }}+{{ "-" | rep 14 }}+{{ "-" | rep 12 }}+{{ "-" | rep 14 }}+{{ "-" | rep 14 }}+
| {{ "Issue" | printf "%-14s" }} | {{ "Summary" | printf "%-55s" }} | {{ "Priority" | printf "%-12s" }} | {{ "Status" | printf "%-12s" }} | {{ "Age" | printf "%-10s" }} | {{ "Reporter" | printf "%-12s" }} | {{ "Assignee" | printf "%-12s" }} |
+{{ "-" | rep 16 }}+{{ "-" | rep 57 }}+{{ "-" | rep 14 }}+{{ "-" | rep 14 }}+{{ "-" | rep 12 }}+{{ "-" | rep 14 }}+{{ "-" | rep 14 }}+
{{ range .issues }}| {{ .key | printf "%-14s"}} | {{ .fields.summary | abbrev 55 | printf "%-55s" }} | {{.fields.priority.name | printf "%-12s" }} | {{.fields.status.name | printf "%-12s" }} | {{.fields.created | age | printf "%-10s" }} | {{if .fields.reporter}}{{ .fields.reporter.name | printf "%-12s"}}{{else}}<unassigned>{{end}} | {{if .fields.assignee }}{{.fields.assignee.name | printf "%-12s" }}{{else}}<unassigned>{{end}} |
{{ end }}+{{ "-" | rep 16 }}+{{ "-" | rep 57 }}+{{ "-" | rep 14 }}+{{ "-" | rep 14 }}+{{ "-" | rep 12 }}+{{ "-" | rep 14 }}+{{ "-" | rep 14 }}+
`
const default_view_template = `issue: {{ .key }}
created: {{ .fields.created }}
status: {{ .fields.status.name }}
summary: {{ .fields.summary }}
project: {{ .fields.project.key }}
components: {{ range .fields.components }}{{ .name }} {{end}}
issuetype: {{ .fields.issuetype.name }}
assignee: {{ if .fields.assignee }}{{ .fields.assignee.name }}{{end}}
reporter: {{ if .fields.reporter }}{{ .fields.reporter.name }}{{end}}
watchers: {{ range .fields.customfield_10110 }}{{ .name }} {{end}}
blockers: {{ range .fields.issuelinks }}{{if .outwardIssue}}{{ .outwardIssue.key }}[{{.outwardIssue.fields.status.name}}]{{end}}{{end}}
epends: {{ range .fields.issuelinks }}{{if .inwardIssue}}{{ .inwardIssue.key }}[{{.inwardIssue.fields.status.name}}]{{end}}{{end}}
priority: {{ .fields.priority.name }}
description: |
{{ or .fields.description "" | indent 2 }}
comments:
{{ range .fields.comment.comments }} - | # {{.author.name}} at {{.created}}
{{ or .body "" | indent 4}}
{{end}}
`
const default_edit_template = `update:
comment:
- add:
body: |
{{ or .overrides.comment "" | indent 10 }}
fields:
summary: {{ or .overrides.summary .fields.summary }}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{if .overrides.components }}{{ range (split "," .overrides.components)}}
- name: {{.}}{{end}}{{else}}{{ range .fields.components }}
- name: {{ .name }}{{end}}{{end}}
assignee:
name: {{ if .overrides.assignee }}{{.overrides.assignee}}{{else}}{{if .fields.assignee }}{{ .fields.assignee.name }}{{end}}{{end}}
reporter:
name: {{ if .overrides.reporter }}{{ .overrides.reporter }}{{else if .fields.reporter}}{{ .fields.reporter.name }}{{end}}
# watchers
customfield_10110: {{ range .fields.customfield_10110 }}
- name: {{ .name }}{{end}}{{if .overrides.watcher}}
- name: {{ .overrides.watcher}}{{end}}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority .fields.priority.name }}
description: |
{{ or .overrides.description (or .fields.description "") | indent 4 }}
`
const default_transitions_template = `{{ range .transitions }}{{.id }}: {{.name}}
{{end}}`
const default_issuetypes_template = `{{ range .projects }}{{ range .issuetypes }}{{color "+bh"}}{{.name | append ":" | printf "%-13s" }}{{color "reset"}} {{.description}}
{{end}}{{end}}`
const default_create_template = `fields:
project:
key: {{ .overrides.project }}
issuetype:
name: {{ .overrides.issuetype }}
summary: {{ or .overrides.summary "" }}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority "unassigned" }}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{ range split "," (or .overrides.components "")}}
- name: {{ . }}{{end}}
description: |
{{ or .overrides.description "" | indent 4 }}
assignee:
name: {{ or .overrides.assignee "" }}
reporter:
name: {{ or .overrides.reporter .overrides.user }}
# watchers
customfield_10110: {{ range split "," (or .overrides.watchers "")}}
- name: {{.}}{{end}}
- name:
`
const default_comment_template = `body: |
{{ or .overrides.comment "" | indent 2 }}
`
const default_transition_template = `update:
comment:
- add:
body: |
{{ or .overrides.comment "" | indent 10 }}
fields:{{if .meta.fields.assignee}}
assignee:
name: {{if .overrides.assignee}}{{.overrides.assignee}}{{else}}{{if .fields.assignee}}{{.fields.assignee.name}}{{end}}{{end}}{{end}}{{if .meta.fields.components}}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{if .overrides.components }}{{ range (split "," .overrides.components)}}
- name: {{.}}{{end}}{{else}}{{ range .fields.components }}
- name: {{ .name }}{{end}}{{end}}{{end}}{{if .meta.fields.description}}
description: {{or .overrides.description .fields.description }}{{end}}{{if .meta.fields.fixVersions}}{{if .meta.fields.fixVersions.allowedValues}}
fixVersions: # Values: {{ range .meta.fields.fixVersions.allowedValues }}{{.name}}, {{end}}{{if .overrides.fixVersions}}{{ range (split "," .overrides.fixVersions)}}
- name: {{.}}{{end}}{{else}}{{range .fields.fixVersions}}
- name: {{.}}{{end}}{{end}}{{end}}{{end}}{{if .meta.fields.issuetype}}
issuetype: # Values: {{ range .meta.fields.issuetype.allowedValues }}{{.name}}, {{end}}
name: {{if .overrides.issuetype}}{{.overrides.issuetype}}{{else}}{{if .fields.issuetype}}{{.fields.issuetype.name}}{{end}}{{end}}{{end}}{{if .meta.fields.labels}}
labels: {{range .fields.labels}}
- {{.}}{{end}}{{if .overrides.labels}}{{range (split "," .overrides.labels)}}
- {{.}}{{end}}{{end}}{{end}}{{if .meta.fields.priority}}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority "unassigned" }}{{end}}{{if .meta.fields.reporter}}
reporter:
name: {{if .overrides.reporter}}{{.overrides.reporter}}{{else}}{{if .fields.reporter}}{{.fields.reporter.name}}{{end}}{{end}}{{end}}{{if .meta.fields.resolution}}
resolution: # Values: {{ range .meta.fields.resolution.allowedValues }}{{.name}}, {{end}}
name: {{if .overrides.resolution}}{{.overrides.resolution}}{{else if .fields.resolution}}{{.fields.resolution.name}}{{else}}Fixed{{end}}{{end}}{{if .meta.fields.summary}}
summary: {{or .overrides.summary .fields.summary}}{{end}}{{if .meta.fields.versions.allowedValues}}
versions: # Values: {{ range .meta.fields.versions.allowedValues }}{{.name}}, {{end}}{{if .overrides.versions}}{{ range (split "," .overrides.versions)}}
- name: {{.}}{{end}}{{else}}{{range .fields.versions}}
- name: {{.}}{{end}}{{end}}{{end}}
transition:
id: {{ .transition.id }}
name: {{ .transition.name }}
`
-292
View File
@@ -1,292 +0,0 @@
package cli
import (
"bufio"
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/mgutz/ansi"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
"text/template"
"time"
)
func FindParentPaths(fileName string) []string {
cwd, _ := os.Getwd()
paths := make([]string, 0)
// special case if homedir is not in current path then check there anyway
homedir := os.Getenv("HOME")
if !strings.HasPrefix(cwd, homedir) {
file := fmt.Sprintf("%s/%s", homedir, fileName)
if _, err := os.Stat(file); err == nil {
paths = append(paths, file)
}
}
var dir string
for _, part := range strings.Split(cwd, string(os.PathSeparator)) {
if dir == "/" {
dir = fmt.Sprintf("/%s", part)
} else {
dir = fmt.Sprintf("%s/%s", dir, part)
}
file := fmt.Sprintf("%s/%s", dir, fileName)
if _, err := os.Stat(file); err == nil {
paths = append(paths, file)
}
}
return paths
}
func FindClosestParentPath(fileName string) (string, error) {
paths := FindParentPaths(fileName)
if len(paths) > 0 {
return paths[len(paths)-1], nil
}
return "", errors.New(fmt.Sprintf("%s not found in parent directory hierarchy", fileName))
}
func readFile(file string) string {
var bytes []byte
var err error
if bytes, err = ioutil.ReadFile(file); err != nil {
log.Error("Failed to read file %s: %s", file, err)
os.Exit(1)
}
return string(bytes)
}
func fuzzyAge(start string) (string, error) {
if t, err := time.Parse("2006-01-02T15:04:05.000-0700", start); err != nil {
return "", err
} else {
delta := time.Now().Sub(t)
if delta.Minutes() < 2 {
return "a minute", nil
} else if dm := delta.Minutes(); dm < 45 {
return fmt.Sprintf("%d minutes", int(dm)), nil
} else if dm := delta.Minutes(); dm < 90 {
return "an hour", nil
} else if dh := delta.Hours(); dh < 24 {
return fmt.Sprintf("%d hours", int(dh)), nil
} else if dh := delta.Hours(); dh < 48 {
return "a day", nil
} else {
return fmt.Sprintf("%d days", int(delta.Hours()/24)), nil
}
}
return "unknown", nil
}
func runTemplate(templateContent string, data interface{}, out io.Writer) error {
if out == nil {
out = os.Stdout
}
funcs := map[string]interface{}{
"toJson": func(content interface{}) (string, error) {
if bytes, err := json.MarshalIndent(content, "", " "); err != nil {
return "", err
} else {
return string(bytes), nil
}
},
"append": func(more string, content interface{}) (string, error) {
switch value := content.(type) {
case string:
return string(append([]byte(content.(string)), []byte(more)...)), nil
case []byte:
return string(append(content.([]byte), []byte(more)...)), nil
default:
return "", errors.New(fmt.Sprintf("Unknown type: %s", value))
}
},
"indent": func(spaces int, content string) string {
indent := make([]byte, spaces+1, spaces+1)
indent[0] = '\n'
for i := 1; i < spaces+1; i += 1 {
indent[i] = ' '
}
return strings.Replace(content, "\n", string(indent), -1)
},
"color": func(color string) string {
return ansi.ColorCode(color)
},
"split": func(sep string, content string) []string {
return strings.Split(content, sep)
},
"abbrev": func(max int, content string) string {
if len(content) > max {
var buffer bytes.Buffer
buffer.WriteString(content[:max-3])
buffer.WriteString("...")
return buffer.String()
}
return content
},
"rep": func(count int, content string) string {
var buffer bytes.Buffer
for i := 0; i < count; i += 1 {
buffer.WriteString(content)
}
return buffer.String()
},
"age": func(content string) (string, error) {
return fuzzyAge(content)
},
}
if tmpl, err := template.New("template").Funcs(funcs).Parse(templateContent); err != nil {
log.Error("Failed to parse template: %s", err)
return err
} else {
if err := tmpl.Execute(out, data); err != nil {
log.Error("Failed to execute template: %s", err)
return err
}
}
return nil
}
func responseToJson(resp *http.Response, err error) (interface{}, error) {
if err != nil {
return nil, err
}
data := jsonDecode(resp.Body)
if resp.StatusCode == 400 {
if val, ok := data.(map[string]interface{})["errorMessages"]; ok {
for _, errMsg := range val.([]interface{}) {
log.Error("%s", errMsg)
}
}
}
return data, nil
}
func jsonDecode(io io.Reader) interface{} {
content, err := ioutil.ReadAll(io)
var data interface{}
err = json.Unmarshal(content, &data)
if err != nil {
log.Error("JSON Parse Error: %s from %s", err, content)
}
return data
}
func jsonEncode(data interface{}) (string, error) {
buffer := bytes.NewBuffer(make([]byte, 0))
enc := json.NewEncoder(buffer)
err := enc.Encode(data)
if err != nil {
log.Error("Failed to encode data %s: %s", data, err)
return "", err
}
return buffer.String(), nil
}
func jsonWrite(file string, data interface{}) {
fh, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
defer fh.Close()
if err != nil {
log.Error("Failed to open %s: %s", file, err)
os.Exit(1)
}
enc := json.NewEncoder(fh)
enc.Encode(data)
}
func promptYN(prompt string, yes bool) bool {
reader := bufio.NewReader(os.Stdin)
if !yes {
prompt = fmt.Sprintf("%s [y/N]: ", prompt)
} else {
prompt = fmt.Sprintf("%s [Y/n]: ", prompt)
}
fmt.Printf("%s", prompt)
text, _ := reader.ReadString('\n')
ans := strings.ToLower(strings.TrimRight(text, "\n"))
if ans == "" {
return yes
}
if strings.HasPrefix(ans, "y") {
return true
}
return false
}
func yamlFixup(data interface{}) (interface{}, error) {
switch d := data.(type) {
case map[interface{}]interface{}:
// need to copy this map into a string map so json can encode it
copy := make(map[string]interface{})
for key, val := range d {
switch k := key.(type) {
case string:
if fixed, err := yamlFixup(val); err != nil {
return nil, err
} else if fixed != nil {
copy[k] = fixed
}
default:
err := fmt.Errorf("YAML: key %s is type '%T', require 'string'", key, k)
log.Error("%s", err)
return nil, err
}
}
return copy, nil
case map[string]interface{}:
for k, v := range d {
if fixed, err := yamlFixup(v); err != nil {
return nil, err
} else if fixed != nil {
d[k] = fixed
}
}
return d, nil
case []interface{}:
for i, val := range d {
if fixed, err := yamlFixup(val); err != nil {
return nil, err
} else if fixed != nil {
d[i] = fixed
}
}
return data, nil
case string:
if d == "" {
return nil, nil
}
return d, nil
default:
return d, nil
}
}
func mkdir(dir string) error {
if stat, err := os.Stat(dir); err != nil && !os.IsNotExist(err) {
log.Error("Failed to stat %s: %s", dir, err)
return err
} else if err == nil && !stat.IsDir() {
err := fmt.Errorf("%s exists and is not a directory!", dir)
log.Error("%s", err)
return err
} else {
// dir does not exist, so try to create it
if err := os.MkdirAll(dir, 0755); err != nil {
log.Error("Failed to mkdir -p %s: %s", dir, err)
return err
}
}
return nil
}
-365
View File
@@ -1,365 +0,0 @@
package main
import (
"bytes"
"fmt"
"github.com/Netflix-Skunkworks/go-jira/jira/cli"
"github.com/docopt/docopt-go"
"github.com/op/go-logging"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"os/exec"
"strings"
)
var log = logging.MustGetLogger("jira")
var format = "%{color}%{time:2006-01-02T15:04:05.000Z07:00} %{level:-5s} [%{shortfile}]%{color:reset} %{message}"
func main() {
user := os.Getenv("USER")
home := os.Getenv("HOME")
usage := fmt.Sprintf(`
Usage:
jira [-v ...] [-u USER] [-e URI] [-t FILE] (ls|list) ( [-q JQL] | [-p PROJECT] [-c COMPONENT] [-a ASSIGNEE] [-i ISSUETYPE] [-w WATCHER] [-r REPORTER]) [-f FIELDS]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] view ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] edit ISSUE [--noedit] [-m COMMENT] [-o KEY=VAL]...
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] create [--noedit] [-p PROJECT] [-i ISSUETYPE] [-o KEY=VAL]...
jira [-v ...] [-u USER] [-e URI] [-b] DUPLICATE dups ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] BLOCKER blocks ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] watch ISSUE [-w WATCHER]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] (trans|transition) TRANSITION ISSUE [-m COMMENT] [-o KEY=VAL] [--noedit]
jira [-v ...] [-u USER] [-e URI] [-b] ack ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] close ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] resolve ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] reopen ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] start ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] stop ISSUE [-m COMMENT] [-o KEY=VAL] [--edit]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] comment ISSUE [-m COMMENT]
jira [-v ...] [-u USER] [-e URI] [-b] take ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] (assign|give) ISSUE ASSIGNEE
jira [-v ...] [-u USER] [-e URI] [-t FILE] fields
jira [-v ...] [-u USER] [-e URI] [-t FILE] issuelinktypes
jira [-v ...] [-u USER] [-e URI] [-b][-t FILE] transmeta ISSUE
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] editmeta ISSUE
jira [-v ...] [-u USER] [-e URI] [-t FILE] issuetypes [-p PROJECT]
jira [-v ...] [-u USER] [-e URI] [-t FILE] createmeta [-p PROJECT] [-i ISSUETYPE]
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] transitions ISSUE
jira [-v ...] export-templates [-d DIR] [-t template]
jira [-v ...] [-u USER] [-e URI] (b|browse) ISSUE
jira [-v ...] [-u USER] [-e URI] [-t FILE] login
jira [-v ...] [-u USER] [-e URI] [-b] [-t FILE] ISSUE
General Options:
-e --endpoint=URI URI to use for jira
-h --help Show this usage
-t --template=FILE Template file to use for output/editing
-u --user=USER Username to use for authenticaion (default: %s)
-v --verbose Increase output logging
--version Show this version
Command Options:
-a --assignee=USER Username assigned the issue
-b --browse Open your browser to the Jira issue
-c --component=COMPONENT Component to Search for
-d --directory=DIR Directory to export templates to (default: %s)
-f --queryfields=FIELDS Fields that are used in "list" template: (default: summary,created,priority,status,reporter,assignee)
-i --issuetype=ISSUETYPE Jira Issue Type (default: Bug)
-m --comment=COMMENT Comment message for transition
-o --override=KEY:VAL Set custom key/value pairs
-p --project=PROJECT Project to Search for
-q --query=JQL Jira Query Language expression for the search
-r --reporter=USER Reporter to search for
-w --watcher=USER Watcher to add to issue (default: %s)
or Watcher to search for
`, user, fmt.Sprintf("%s/.jira.d/templates", home), user)
args, err := docopt.Parse(usage, nil, true, "0.0.5", false, false)
if err != nil {
log.Error("Failed to parse options: %s", err)
os.Exit(1)
}
logBackend := logging.NewLogBackend(os.Stderr, "", 0)
logging.SetBackend(
logging.NewBackendFormatter(
logBackend,
logging.MustStringFormatter(format),
),
)
logging.SetLevel(logging.NOTICE, "")
if verbose, ok := args["--verbose"]; ok {
if verbose.(int) > 1 {
logging.SetLevel(logging.DEBUG, "")
} else if verbose.(int) > 0 {
logging.SetLevel(logging.INFO, "")
}
}
log.Info("Args: %v", args)
populateEnv(args)
opts := make(map[string]string)
loadConfigs(opts)
// strip the "--" off the command line options
// and populate the opts that we pass to the cli ctor
for key, val := range args {
if val != nil && strings.HasPrefix(key, "--") {
opt := key[2:]
if opt == "override" {
for _, v := range val.([]string) {
if strings.Contains(v, "=") {
kv := strings.SplitN(v, "=", 2)
opts[kv[0]] = kv[1]
} else {
log.Error("Malformed override, expected KEY=VALUE, got %s", v)
os.Exit(1)
}
}
} else {
switch v := val.(type) {
case string:
opts[opt] = v
case int:
opts[opt] = fmt.Sprintf("%d", v)
case bool:
opts[opt] = fmt.Sprintf("%t", v)
}
}
}
}
// cant use proper [default:x] syntax in docopt
// because only want to default if the option is not
// already specified in some .jira.d/config.yml file
if _, ok := opts["user"]; !ok {
opts["user"] = user
}
if _, ok := opts["queryfields"]; !ok {
opts["queryfields"] = "summary,created,priority,status,reporter,assignee"
}
if _, ok := opts["directory"]; !ok {
opts["directory"] = fmt.Sprintf("%s/.jira.d/templates", home)
}
if _, ok := opts["endpoint"]; !ok {
log.Error("endpoint option required. Either use --endpoint or set a enpoint option in your ~/.jira.d/config.yml file")
os.Exit(1)
}
c := cli.New(opts)
log.Debug("opts: %s", opts)
validCommand := func(cmd string) bool {
if val, ok := args[cmd]; ok && val.(bool) {
return true
}
return false
}
validOpt := func(opt string, dflt interface{}) interface{} {
if val, ok := opts[opt]; ok {
return val
}
if dflt == nil {
log.Error("Missing required option --%s or \"%s\" property override in the config file", opt, opt)
os.Exit(1)
}
return dflt
}
setEditing := func(dflt bool) {
if dflt {
if val, ok := opts["noedit"]; ok && val == "true" {
opts["edit"] = "false"
} else {
opts["edit"] = "true"
}
} else {
if val, ok := opts["edit"]; ok && val == "true" {
opts["edit"] = "true"
} else {
opts["edit"] = "false"
}
}
}
if validCommand("login") {
err = c.CmdLogin()
} else if validCommand("fields") {
err = c.CmdFields()
} else if validCommand("ls") || validCommand("list") {
err = c.CmdList()
} else if validCommand("edit") {
setEditing(true)
err = c.CmdEdit(args["ISSUE"].(string))
} else if validCommand("editmeta") {
err = c.CmdEditMeta(args["ISSUE"].(string))
} else if validCommand("transmeta") {
err = c.CmdTransitionMeta(args["ISSUE"].(string))
} else if validCommand("issuelinktypes") {
err = c.CmdIssueLinkTypes()
} else if validCommand("issuetypes") {
err = c.CmdIssueTypes(validOpt("project", nil).(string))
} else if validCommand("createmeta") {
err = c.CmdCreateMeta(
validOpt("project", nil).(string),
validOpt("issuetype", "Bug").(string),
)
} else if validCommand("create") {
setEditing(true)
err = c.CmdCreate(
validOpt("project", nil).(string),
validOpt("issuetype", "Bug").(string),
)
} else if validCommand("transitions") {
err = c.CmdTransitions(args["ISSUE"].(string))
} else if validCommand("blocks") {
err = c.CmdBlocks(
args["BLOCKER"].(string),
args["ISSUE"].(string),
)
} else if validCommand("dups") {
err = c.CmdDups(
args["DUPLICATE"].(string),
args["ISSUE"].(string),
)
} else if validCommand("watch") {
err = c.CmdWatch(
args["ISSUE"].(string),
validOpt("watcher", user).(string),
)
} else if validCommand("trans") || validCommand("transition") {
setEditing(true)
err = c.CmdTransition(
args["ISSUE"].(string),
args["TRANSITION"].(string),
)
} else if validCommand("close") {
setEditing(false)
err = c.CmdTransition(args["ISSUE"].(string), "close")
} else if validCommand("ack") {
setEditing(false)
err = c.CmdTransition(args["ISSUE"].(string), "acknowledge")
} else if validCommand("reopen") {
setEditing(false)
err = c.CmdTransition(args["ISSUE"].(string), "reopen")
} else if validCommand("resolve") {
setEditing(false)
err = c.CmdTransition(args["ISSUE"].(string), "resolve")
} else if validCommand("start") {
setEditing(false)
err = c.CmdTransition(args["ISSUE"].(string), "start")
} else if validCommand("stop") {
setEditing(false)
err = c.CmdTransition(args["ISSUE"].(string), "stop")
} else if validCommand("comment") {
setEditing(true)
err = c.CmdComment(args["ISSUE"].(string))
} else if validCommand("take") {
err = c.CmdAssign(args["ISSUE"].(string), user)
} else if validCommand("browse") || validCommand("b") {
opts["browse"] = "true"
err = c.Browse(args["ISSUE"].(string))
} else if validCommand("export-templates") {
err = c.CmdExportTemplates()
} else if validCommand("assign") || validCommand("give") {
err = c.CmdAssign(
args["ISSUE"].(string),
args["ASSIGNEE"].(string),
)
} else if val, ok := args["ISSUE"]; ok {
err = c.CmdView(val.(string))
}
if err != nil {
os.Exit(1)
}
os.Exit(0)
}
func parseYaml(file string, opts map[string]string) {
if fh, err := ioutil.ReadFile(file); err == nil {
log.Debug("Found Config file: %s", file)
yaml.Unmarshal(fh, &opts)
}
}
func populateEnv(args map[string]interface{}) {
for key, val := range args {
if val != nil && strings.HasPrefix(key, "--") {
if key == "--override" {
for _, v := range val.([]string) {
if strings.Contains(v, "=") {
kv := strings.SplitN(v, "=", 2)
envName := fmt.Sprintf("JIRA_%s", strings.ToUpper(kv[0]))
os.Setenv(envName, kv[1])
} else {
log.Error("Malformed override, expected KEY=VALUE, got %s", v)
os.Exit(1)
}
}
} else {
envName := fmt.Sprintf("JIRA_%s", strings.ToUpper(key[2:]))
switch v := val.(type) {
case []string:
os.Setenv(envName, strings.Join(v, ","))
case string:
os.Setenv(envName, v)
case bool:
if v {
os.Setenv(envName, "1")
} else {
os.Setenv(envName, "0")
}
}
}
} else if val != nil {
// lower case strings are operations
if strings.ToLower(key) == key {
if key == "ls" && val.(bool) {
os.Setenv("JIRA_OPERATION", "list")
} else if key == "b" && val.(bool) {
os.Setenv("JIRA_OPERATION", "browse")
} else if key == "trans" && val.(bool) {
os.Setenv("JIRA_OPERATION", "transition")
} else if key == "give" && val.(bool) {
os.Setenv("JIRA_OPERATION", "assign")
} else if val.(bool) {
os.Setenv("JIRA_OPERATION", key)
}
} else {
os.Setenv(fmt.Sprintf("JIRA_%s", key), val.(string))
}
}
}
}
func loadConfigs(opts map[string]string) {
paths := cli.FindParentPaths(".jira.d/config.yml")
// prepend
paths = append([]string{"/etc/jira-cli.yml"}, paths...)
for _, file := range paths {
if stat, err := os.Stat(file); err == nil {
// check to see if config file is exectuable
if stat.Mode()&0111 == 0 {
parseYaml(file, opts)
} else {
log.Debug("Found Executable Config file: %s", file)
// it is executable, so run it and try to parse the output
cmd := exec.Command(file)
stdout := bytes.NewBufferString("")
cmd.Stdout = stdout
cmd.Stderr = bytes.NewBufferString("")
if err := cmd.Run(); err != nil {
log.Error("%s is exectuable, but it failed to execute: %s\n%s", file, err, cmd.Stderr)
os.Exit(1)
}
yaml.Unmarshal(stdout.Bytes(), &opts)
}
}
}
}
+590
View File
@@ -0,0 +1,590 @@
package jiracli
import (
"bytes"
"crypto/tls"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"reflect"
"runtime/debug"
"strconv"
"strings"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/jinzhu/copier"
shellquote "github.com/kballard/go-shellquote"
"github.com/tidwall/gjson"
"gopkg.in/AlecAivazis/survey.v1"
kingpin "gopkg.in/alecthomas/kingpin.v2"
yaml "gopkg.in/coryb/yaml.v2"
logging "gopkg.in/op/go-logging.v1"
)
type Exit struct {
Code int
}
// HandleExit will unwind any panics and check to see if they are jiracli.Exit
// and exit accordingly.
//
// Example:
// func main() {
// defer jiracli.HandleExit()
// ...
// }
func HandleExit() {
if e := recover(); e != nil {
if exit, ok := e.(Exit); ok {
os.Exit(exit.Code)
} else {
fmt.Fprintf(os.Stderr, "%s\n%s", e, debug.Stack())
os.Exit(1)
}
}
}
const (
ServerDeploymentType = "server"
CloudDeploymentType = "cloud"
)
type GlobalOptions struct {
// AuthenticationMethod is the method we use to authenticate with the jira serivce.
// Possible values are "api-token", "bearer-token" or "session".
// The default is "api-token" when the service endpoint ends with "atlassian.net", otherwise it "session". Session authentication
// will promt for user password and use the /auth/1/session-login endpoint.
AuthenticationMethod figtree.StringOption `yaml:"authentication-method,omitempty" json:"authentication-method,omitempty"`
// Endpoint is the URL for the Jira service. Something like: https://go-jira.atlassian.net
Endpoint figtree.StringOption `yaml:"endpoint,omitempty" json:"endpoint,omitempty"`
// Insecure will allow you to connect to an https endpoint with a self-signed SSL certificate
Insecure figtree.BoolOption `yaml:"insecure,omitempty" json:"insecure,omitempty"`
// Login is the id used for authenticating with the Jira service. For "api-token" AuthenticationMethod this is usually a
// full email address, something like "user@example.com". For "session" AuthenticationMethod this will be something
// like "user", which by default will use the same value in the `User` field.
Login figtree.StringOption `yaml:"login,omitempty" json:"login,omitempty"`
// PasswordSource specificies the method that we fetch the password. Possible values are "keyring" or "pass".
// If this is unset we will just prompt the user. For "keyring" this will look in the OS keychain, if missing
// then prompt the user and store the password in the OS keychain. For "pass" this will look in the PasswordDirectory
// location using the `pass` tool, if missing prompt the user and store in the PasswordDirectory
PasswordSource figtree.StringOption `yaml:"password-source,omitempty" json:"password-source,omitempty"`
// PasswordSourcePath can be used to specify the path to the PasswordSource binary to use.
PasswordSourcePath figtree.StringOption `yaml:"password-source-path,omitempty" json:"password-source-path,omitempty"`
// Cached password to avoid invoking password source on each API request
cachedPassword string
// PasswordDirectory is only used for the "pass" PasswordSource. It is the location for the encrypted password
// files used by `pass`. Effectively this overrides the "PASSWORD_STORE_DIR" environment variable
PasswordDirectory figtree.StringOption `yaml:"password-directory,omitempty" json:"password-directory,omitempty"`
// PasswordName is the the name of the password key entry stored used with PasswordSource `pass`.
PasswordName figtree.StringOption `yaml:"password-name,omitempty" json:"password-name,omitempty"`
// Quiet will lower the defalt log level to suppress the standard output for commands
Quiet figtree.BoolOption `yaml:"quiet,omitempty" json:"quiet,omitempty"`
// SocksProxy is used to configure the http client to access the Endpoint via a socks proxy. The value
// should be a ip address and port string, something like "127.0.0.1:1080"
SocksProxy figtree.StringOption `yaml:"socksproxy,omitempty" json:"socksproxy,omitempty"`
// UnixProxy is use to configure the http client to access the Endpoint via a local unix domain socket used
// to proxy requests
UnixProxy figtree.StringOption `yaml:"unixproxy,omitempty" json:"unixproxy,omitempty"`
// User is use to represent the user on the Jira service. This can be different from the username used to
// authenticate with the service. For example when using AuthenticationMethod `api-token` the Login is
// typically an email address like `username@example.com` and the User property would be someting like
// `username` The User property is used on Jira service API calls that require a user to associate with
// an Issue (like assigning a Issue to yourself)
User figtree.StringOption `yaml:"user,omitempty" json:"user,omitempty"`
// JiraDeploymentType can be `cloud` or `server`, if not set it will be inferred from
// the /rest/api/2/serverInfo REST API.
JiraDeploymentType figtree.StringOption `yaml:"jira-deployment-type,omitempty" json:"jira-deployment-type,omitempty"`
}
type CommonOptions struct {
Browse figtree.BoolOption `yaml:"browse,omitempty" json:"browse,omitempty"`
Editor figtree.StringOption `yaml:"editor,omitempty" json:"editor,omitempty"`
File figtree.StringOption `yaml:"file,omitempty" json:"file,omitempty"`
GJsonQuery figtree.StringOption `yaml:"gjq,omitempty" json:"gjq,omitempty"`
SkipEditing figtree.BoolOption `yaml:"noedit,omitempty" json:"noedit,omitempty"`
Template figtree.StringOption `yaml:"template,omitempty" json:"template,omitempty"`
}
type CommandRegistryEntry struct {
Help string
UsageFunc func(*figtree.FigTree, *kingpin.CmdClause) error
ExecuteFunc func(*oreo.Client, *GlobalOptions) error
}
type CommandRegistry struct {
Command string
Aliases []string
Entry *CommandRegistryEntry
Default bool
}
// either kingpin.Application or kingpin.CmdClause fit this interface
type kingpinAppOrCommand interface {
Command(string, string) *kingpin.CmdClause
GetCommand(string) *kingpin.CmdClause
}
var globalCommandRegistry = []CommandRegistry{}
func RegisterCommand(regEntry CommandRegistry) {
globalCommandRegistry = append(globalCommandRegistry, regEntry)
}
func (o *GlobalOptions) AuthMethod() string {
if strings.Contains(o.Endpoint.Value, ".atlassian.net") && o.AuthenticationMethod.Source == "default" {
return "api-token"
}
return o.AuthenticationMethod.Value
}
func (o *GlobalOptions) AuthMethodIsToken() bool{
return o.AuthMethod() == "api-token" || o.AuthMethod() == "bearer-token";
}
func register(app *kingpin.Application, o *oreo.Client, fig *figtree.FigTree) {
globals := GlobalOptions{
User: figtree.NewStringOption(os.Getenv("USER")),
AuthenticationMethod: figtree.NewStringOption("session"),
}
app.Flag("endpoint", "Base URI to use for Jira").Short('e').SetValue(&globals.Endpoint)
app.Flag("insecure", "Disable TLS certificate verification").Short('k').SetValue(&globals.Insecure)
app.Flag("quiet", "Suppress output to console").Short('Q').SetValue(&globals.Quiet)
app.Flag("unixproxy", "Path for a unix-socket proxy").SetValue(&globals.UnixProxy)
app.Flag("socksproxy", "Address for a socks proxy").SetValue(&globals.SocksProxy)
app.Flag("user", "user name used within the Jira service").Short('u').SetValue(&globals.User)
app.Flag("login", "login name that corresponds to the user used for authentication").SetValue(&globals.Login)
o = o.WithPreCallback(func(req *http.Request) (*http.Request, error) {
if globals.AuthMethod() == "api-token" {
// need to set basic auth header with user@domain:api-token
token := globals.GetPass()
authHeader := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", globals.Login.Value, token))))
req.Header.Add("Authorization", authHeader)
} else if globals.AuthMethod() == "bearer-token" {
token := globals.GetPass()
authHeader := fmt.Sprintf("Bearer %s", token)
req.Header.Add("Authorization", authHeader)
}
return req, nil
})
o = o.WithPostCallback(func(req *http.Request, resp *http.Response) (*http.Response, error) {
if globals.AuthMethod() == "session" {
authUser := resp.Header.Get("X-Ausername")
if authUser == "" || authUser == "anonymous" {
// preserve the --quiet value, we need to temporarily disable it so
// the normal login output is surpressed
defer func(quiet bool) {
globals.Quiet.Value = quiet
}(globals.Quiet.Value)
globals.Quiet.Value = true
// we are not logged in, so force login now by running the "login" command
app.Parse([]string{"login"})
// rerun the original request
return o.Do(req)
}
} else if globals.AuthMethodIsToken() && resp.StatusCode == 401 {
globals.SetPass("")
return o.Do(req)
}
return resp, nil
})
for _, command := range globalCommandRegistry {
copy := command
commandFields := strings.Fields(copy.Command)
var appOrCmd kingpinAppOrCommand = app
if len(commandFields) > 1 {
for _, name := range commandFields[0 : len(commandFields)-1] {
tmp := appOrCmd.GetCommand(name)
if tmp == nil {
tmp = appOrCmd.Command(name, "")
}
appOrCmd = tmp
}
}
cmd := appOrCmd.Command(commandFields[len(commandFields)-1], copy.Entry.Help)
LoadConfigs(cmd, fig, &globals)
cmd.PreAction(func(_ *kingpin.ParseContext) error {
if globals.Insecure.Value {
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
}
o = o.WithTransport(transport)
}
if globals.UnixProxy.Value != "" {
o = o.WithTransport(unixProxy(globals.UnixProxy.Value))
} else if globals.SocksProxy.Value != "" {
o = o.WithTransport(socksProxy(globals.SocksProxy.Value))
}
if globals.AuthMethodIsToken() {
o = o.WithCookieFile("")
}
if globals.Login.Value == "" {
globals.Login = globals.User
}
return nil
})
for _, alias := range copy.Aliases {
cmd = cmd.Alias(alias)
}
if copy.Default {
cmd = cmd.Default()
}
if copy.Entry.UsageFunc != nil {
copy.Entry.UsageFunc(fig, cmd)
}
cmd.Action(func(_ *kingpin.ParseContext) error {
if logging.GetLevel("") > logging.DEBUG {
o = o.WithTrace(true)
}
return copy.Entry.ExecuteFunc(o, &globals)
})
}
}
func LoadConfigs(cmd *kingpin.CmdClause, fig *figtree.FigTree, opts interface{}) {
cmd.PreAction(func(_ *kingpin.ParseContext) error {
os.Setenv("JIRA_OPERATION", cmd.FullCommand())
// load command specific configs first
if err := fig.LoadAllConfigs(strings.Join(strings.Fields(cmd.FullCommand()), "_")+".yml", opts); err != nil {
return err
}
// then load generic configs if not already populated above
return fig.LoadAllConfigs("config.yml", opts)
})
}
func BrowseUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
cmd.Flag("browse", "Open issue(s) in browser after operation").Short('b').SetValue(&opts.Browse)
}
func EditorUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
cmd.Flag("editor", "Editor to use").SetValue(&opts.Editor)
}
func FileUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
cmd.Flag("file", "File to use").SetValue(&opts.File)
}
func TemplateUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
cmd.Flag("template", "Template to use for output").Short('t').SetValue(&opts.Template)
}
func GJsonQueryUsage(cmd *kingpin.CmdClause, opts *CommonOptions) {
cmd.Flag("gjq", "GJSON Query to filter output, see https://goo.gl/iaYwJ5").SetValue(&opts.GJsonQuery)
}
func (o *CommonOptions) PrintTemplate(data interface{}) error {
if o.GJsonQuery.Value != "" {
buf := bytes.NewBufferString("")
RunTemplate("json", data, buf)
results := gjson.GetBytes(buf.Bytes(), o.GJsonQuery.Value)
_, err := os.Stdout.Write([]byte(results.String()))
os.Stdout.Write([]byte{'\n'})
return err
}
return RunTemplate(o.Template.Value, data, nil)
}
func (o *CommonOptions) editFile(fileName string) (changes bool, err error) {
var editor string
for _, ed := range []string{o.Editor.Value, os.Getenv("JIRA_EDITOR"), os.Getenv("EDITOR"), "vim"} {
if ed != "" {
editor = ed
break
}
}
if o.SkipEditing.Value {
return false, nil
}
tmpFileNameOrig := fmt.Sprintf("%s.orig", fileName)
if err := copyFile(fileName, tmpFileNameOrig); err != nil {
return false, err
}
defer func() {
os.Remove(tmpFileNameOrig)
}()
shell, _ := shellquote.Split(editor)
shell = append(shell, fileName)
log.Debugf("Running: %#v", shell)
cmd := exec.Command(shell[0], shell[1:]...)
cmd.Stdout, cmd.Stderr, cmd.Stdin = os.Stdout, os.Stderr, os.Stdin
if err := cmd.Run(); err != nil {
return false, err
}
// now we just need to diff the files to see if there are any changes
f1, err := os.Open(tmpFileNameOrig)
if err != nil {
return false, err
}
f2, err := os.Open(fileName)
if err != nil {
return false, err
}
stat1, err := f1.Stat()
if err != nil {
return false, err
}
stat2, err := f2.Stat()
if err != nil {
return false, err
}
// different sizes, so must have changes
if stat1.Size() != stat2.Size() {
return true, nil
}
p1, p2 := make([]byte, 1024), make([]byte, 1024)
var n1, n2 int
// loop though 1024 bytes at a time comparing the buffers for changes
for err != io.EOF {
n1, _ = f1.Read(p1)
n2, err = f2.Read(p2)
if n1 != n2 {
return true, nil
}
if !bytes.Equal(p1[:n1], p2[:n2]) {
return true, nil
}
}
return false, nil
}
var EditLoopAbort = fmt.Errorf("edit Loop aborted by request")
func EditLoop(opts *CommonOptions, input interface{}, output interface{}, submit func() error) error {
tmpFile, err := tmpTemplate(opts.Template.Value, input)
if err != nil {
return err
}
confirm := func(dflt bool, msg string) (answer bool) {
survey.AskOne(
&survey.Confirm{Message: msg, Default: dflt},
&answer,
nil,
)
return
}
// we need to copy the original output so that we can restore
// it on retries in case we try to populate bogus fields that
// are rejected by the jira service.
dup := reflect.New(reflect.ValueOf(output).Elem().Type())
err = copier.Copy(dup.Interface(), output)
if err != nil {
return err
}
for {
if !opts.SkipEditing.Value {
changes, err := opts.editFile(tmpFile)
if err != nil {
log.Error(err.Error())
if confirm(true, "Editor reported an error, edit again?") {
continue
}
return EditLoopAbort
}
if !changes {
if !confirm(false, "No changes detected, submit anyway?") {
return EditLoopAbort
}
}
}
// parse template
data, err := ioutil.ReadFile(tmpFile)
if err != nil {
return err
}
defer func(mapType, iface reflect.Type) {
yaml.DefaultMapType = mapType
yaml.IfaceType = iface
}(yaml.DefaultMapType, yaml.IfaceType)
yaml.DefaultMapType = reflect.TypeOf(map[string]interface{}{})
yaml.IfaceType = yaml.DefaultMapType.Elem()
// restore output incase of retry loop
err = copier.Copy(output, dup.Interface())
if err != nil {
return err
}
// HACK HACK HACK we want to trim out all the yaml garbage that is not
// poplulated, like empty arrays, string values with only a newline,
// etc. We need to do this because jira will reject json documents
// with empty arrays, or empty strings typically. So here we process
// the data to a raw interface{} then we fixup the yaml parsed
// interface, then we serialize to a new yaml document ... then is
// parsed as the original document to populate the output struct. Phew.
var raw interface{}
if err := yaml.Unmarshal(data, &raw); err != nil {
log.Error(err.Error())
if confirm(true, "Invalid YAML syntax, edit again?") {
continue
}
return EditLoopAbort
}
yamlFixup(&raw)
fixedYAML, err := yaml.Marshal(&raw)
if err != nil {
log.Error(err.Error())
if confirm(true, "Invalid YAML syntax, edit again?") {
continue
}
return EditLoopAbort
}
if err := yaml.Unmarshal(fixedYAML, output); err != nil {
log.Error(err.Error())
if confirm(true, "Invalid YAML syntax, edit again?") {
continue
}
return EditLoopAbort
}
// submit template
if err := submit(); err != nil {
log.Error(err.Error())
if confirm(true, "Jira reported an error, edit again?") {
continue
}
return EditLoopAbort
}
break
}
return nil
}
var FileAbort = fmt.Errorf("file processing aborted")
func ReadYmlInputFile(opts *CommonOptions, input interface{}, output interface{}, submit func() error) error {
tmpFile, err := tmpTemplate(opts.Template.Value, input)
if err != nil {
return err
}
tmpFile = opts.File.String()
// we need to copy the original output so that we can restore
// it on retries in case we try to populate bogus fields that
// are rejected by the jira service.
dup := reflect.New(reflect.ValueOf(output).Elem().Type())
err = copier.Copy(dup.Interface(), output)
if err != nil {
return err
}
// parse template
data, err := ioutil.ReadFile(tmpFile)
if err != nil {
return err
}
defer func(mapType, iface reflect.Type) {
yaml.DefaultMapType = mapType
yaml.IfaceType = iface
}(yaml.DefaultMapType, yaml.IfaceType)
yaml.DefaultMapType = reflect.TypeOf(map[string]interface{}{})
yaml.IfaceType = yaml.DefaultMapType.Elem()
// restore output incase of retry loop
err = copier.Copy(output, dup.Interface())
if err != nil {
return err
}
// HACK HACK HACK we want to trim out all the yaml garbage that is not
// poplulated, like empty arrays, string values with only a newline,
// etc. We need to do this because jira will reject json documents
// with empty arrays, or empty strings typically. So here we process
// the data to a raw interface{} then we fixup the yaml parsed
// interface, then we serialize to a new yaml document ... then is
// parsed as the original document to populate the output struct. Phew.
var raw interface{}
if err := yaml.Unmarshal(data, &raw); err != nil {
log.Error(err.Error())
fmt.Printf("Invalid YAML syntax\n")
return FileAbort
}
yamlFixup(&raw)
fixedYAML, err := yaml.Marshal(&raw)
if err != nil {
log.Error(err.Error())
fmt.Printf("Invalid YAML syntax\n")
return FileAbort
}
if err := yaml.Unmarshal(fixedYAML, output); err != nil {
log.Error(err.Error())
fmt.Printf("Invalid YAML syntax\n")
return FileAbort
}
// submit template
if err := submit(); err != nil {
log.Error(err.Error())
fmt.Printf("Jira reported an error\n")
return FileAbort
}
return nil
}
func FormatIssue(issueKey string, project string) string {
if issueKey == "" {
return ""
}
// expect PROJ-1234 issue format, this will split and
// reassemble, converting proj-1234 to PROJ-1234
parts := strings.SplitN(issueKey, "-", 2)
if len(parts) > 1 {
return fmt.Sprintf("%s-%s", strings.ToUpper(parts[0]), parts[1])
}
// if issue is not PROJ-1234 then it might just be 1234, so verify
// it is a number here otherwise warn and return input
if _, err := strconv.Atoi(issueKey); err != nil {
log.Warningf("Unexpected issue format %q, expected PROJ-1234", issueKey)
return issueKey
}
if project == "" {
log.Warningf("Using abbreviated issue %q but `project` property is not defined", issueKey)
return issueKey
}
return fmt.Sprintf("%s-%s", strings.ToUpper(project), issueKey)
}
+13
View File
@@ -0,0 +1,13 @@
package jiracli
import "github.com/pkg/errors"
type Error struct {
error
}
func CliError(cause error) error {
return &Error{
errors.WithStack(cause),
}
}
+17
View File
@@ -0,0 +1,17 @@
// +build !windows
package jiracli
import "github.com/tmc/keyring"
func keyringGet(user string) (string, error) {
password, err := keyring.Get("go-jira", user)
if err != nil && err != keyring.ErrNotFound {
return password, err
}
return password, nil
}
func keyringSet(user, passwd string) error {
return keyring.Set("go-jira", user, passwd)
}
+11
View File
@@ -0,0 +1,11 @@
package jiracli
import "fmt"
func keyringGet(user string) (string, error) {
return "", fmt.Errorf("Keyring is not supported for Windows, see: https://github.com/tmc/keyring")
}
func keyringSet(user, passwd string) error {
return fmt.Errorf("Keyring is not supported for Windows, see: https://github.com/tmc/keyring")
}
+38
View File
@@ -0,0 +1,38 @@
package jiracli
import (
"os"
"strconv"
logging "gopkg.in/op/go-logging.v1"
)
var (
log = logging.MustGetLogger("jira")
)
func IncreaseLogLevel(verbosity int) {
logging.SetLevel(logging.GetLevel("")+logging.Level(verbosity), "")
}
func InitLogging() {
logBackend := logging.NewLogBackend(os.Stderr, "", 0)
format := os.Getenv("JIRA_LOG_FORMAT")
if format == "" {
format = "%{color}%{level:-5s}%{color:reset} %{message}"
}
logging.SetBackend(
logging.NewBackendFormatter(
logBackend,
logging.MustStringFormatter(format),
),
)
if os.Getenv("JIRA_DEBUG") == "" {
logging.SetLevel(logging.NOTICE, "")
} else {
logging.SetLevel(logging.DEBUG, "")
if verbosity, err := strconv.Atoi(os.Getenv("JIRA_DEBUG")); err == nil {
IncreaseLogLevel(verbosity)
}
}
}
+225
View File
@@ -0,0 +1,225 @@
package jiracli
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
"github.com/go-jira/jira/jiradata"
"gopkg.in/AlecAivazis/survey.v1"
)
func (o *GlobalOptions) ProvideAuthParams() *jiradata.AuthParams {
return &jiradata.AuthParams{
Username: o.Login.Value,
Password: o.GetPass(),
}
}
func (o *GlobalOptions) keyName() string {
user := o.Login.Value
if o.AuthMethodIsToken() {
user = "api-token:" + user
}
if o.PasswordSource.Value == "pass" {
if o.PasswordName.Value != "" {
return o.PasswordName.Value
}
return fmt.Sprintf("GoJira/%s", user)
}
if o.PasswordSource.Value == "gopass" {
if o.PasswordName.Value != "" {
return o.PasswordName.Value
}
return fmt.Sprintf("GoJira/%s", user)
}
return user
}
func (o *GlobalOptions) GetPasswordPath() string {
// if no password source path then just default
// to the password source name
if o.PasswordSourcePath.Value == "" {
return o.PasswordSource.Value
}
return o.PasswordSourcePath.Value
}
func (o *GlobalOptions) GetPass() string {
if o.cachedPassword != "" {
return o.cachedPassword
}
log.Debugf("Getting Password")
if o.PasswordSource.Value != "" {
log.Debugf("password-source: %s", o.PasswordSource)
if o.PasswordSource.Value == "keyring" {
log.Info("Querying keyring password source.")
var err error
o.cachedPassword, err = keyringGet(o.keyName())
if err != nil {
panic(err)
}
} else if o.PasswordSource.Value == "gopass" {
log.Debugf("Querying gopass password source.")
binary := o.GetPasswordPath()
if o.PasswordDirectory.Value != "" {
orig := os.Getenv("PASSWORD_STORE_DIR")
log.Debugf("using password-directory: %s", o.PasswordDirectory)
os.Setenv("PASSWORD_STORE_DIR", o.PasswordDirectory.Value)
defer os.Setenv("PASSWORD_STORE_DIR", orig)
}
if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" {
log.Debugf("using PASSWORD_STORE_DIR=%s", passDir)
}
if bin, err := exec.LookPath(binary); err == nil {
log.Debugf("found gopass at: %s", bin)
buf := bytes.NewBufferString("")
cmd := exec.Command(bin, "show", "-o", o.keyName())
cmd.Stdout = buf
cmd.Stderr = os.Stderr
if err := cmd.Run(); err == nil {
o.cachedPassword = strings.TrimSpace(buf.String())
} else {
log.Warningf("gopass command failed with:\n%s", buf.String())
}
} else {
log.Warning("Gopass binary was not found! Fallback to default password behaviour!")
}
} else if o.PasswordSource.Value == "pass" {
log.Debugf("Querying pass password source.")
binary := o.GetPasswordPath()
if o.PasswordDirectory.Value != "" {
orig := os.Getenv("PASSWORD_STORE_DIR")
log.Debugf("using password-directory: %s", o.PasswordDirectory)
os.Setenv("PASSWORD_STORE_DIR", o.PasswordDirectory.Value)
defer os.Setenv("PASSWORD_STORE_DIR", orig)
}
if passDir := os.Getenv("PASSWORD_STORE_DIR"); passDir != "" {
log.Debugf("using PASSWORD_STORE_DIR=%s", passDir)
}
if bin, err := exec.LookPath(binary); err == nil {
log.Debugf("found pass at: %s", bin)
buf := bytes.NewBufferString("")
cmd := exec.Command(bin, o.keyName())
cmd.Stdout = buf
cmd.Stderr = os.Stderr
if err := cmd.Run(); err == nil {
o.cachedPassword = strings.TrimSpace(buf.String())
} else {
log.Warningf("pass command failed with:\n%s", buf.String())
}
} else {
log.Warning("pass binary was not found! Fallback to default password behaviour!")
}
} else if o.PasswordSource.Value == "stdin" {
log.Info("Reading password from stdin.")
allBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
panic(fmt.Sprintf("unable to read bytes from stdin: %s", err))
}
o.cachedPassword = string(allBytes)
} else {
log.Warningf("Unknown password-source: %s", o.PasswordSource)
}
}
if o.cachedPassword != "" {
log.Info("Password cached.")
return o.cachedPassword
}
if o.cachedPassword = os.Getenv("JIRA_API_TOKEN"); o.cachedPassword != "" && o.AuthMethodIsToken() {
return o.cachedPassword
}
prompt := fmt.Sprintf("Jira Password [%s]: ", o.Login)
help := ""
if o.AuthMethodIsToken() {
prompt = fmt.Sprintf("Jira API-Token [%s]: ", o.Login)
help = "API Tokens may be required by your Jira service endpoint: https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/"
}
err := survey.AskOne(
&survey.Password{
Message: prompt,
Help: help,
},
&o.cachedPassword,
nil,
)
if err != nil {
log.Errorf("%s", err)
panic(Exit{Code: 1})
}
o.SetPass(o.cachedPassword)
return o.cachedPassword
}
func (o *GlobalOptions) SetPass(passwd string) error {
// dont reset password to empty string
if passwd == "" {
return nil
}
if o.PasswordSource.Value == "keyring" {
// save password in keychain so that it can be used for subsequent http requests
err := keyringSet(o.keyName(), passwd)
if err != nil {
log.Errorf("Failed to set password in keyring: %s", err)
return err
}
} else if o.PasswordSource.Value == "gopass" {
if o.PasswordDirectory.Value != "" {
orig := os.Getenv("PASSWORD_STORE_DIR")
os.Setenv("PASSWORD_STORE_DIR", o.PasswordDirectory.Value)
defer os.Setenv("PASSWORD_STORE_DIR", orig)
}
if bin, err := exec.LookPath("gopass"); err == nil {
log.Debugf("using %s", bin)
passName := o.keyName()
if passwd != "" {
in := bytes.NewBufferString(fmt.Sprintf("%s\n", passwd))
out := bytes.NewBufferString("")
cmd := exec.Command(bin, "insert", "--force", passName)
cmd.Stdin = in
cmd.Stdout = out
cmd.Stderr = out
if err := cmd.Run(); err != nil {
return fmt.Errorf("Failed to insert password: %s", out.String())
}
}
} else {
return fmt.Errorf("Gopass binary not found!")
}
} else if o.PasswordSource.Value == "pass" {
if o.PasswordDirectory.Value != "" {
orig := os.Getenv("PASSWORD_STORE_DIR")
os.Setenv("PASSWORD_STORE_DIR", o.PasswordDirectory.Value)
defer os.Setenv("PASSWORD_STORE_DIR", orig)
}
if bin, err := exec.LookPath("pass"); err == nil {
log.Debugf("using %s", bin)
passName := o.keyName()
in := bytes.NewBufferString(fmt.Sprintf("%s\n%s\n", passwd, passwd))
out := bytes.NewBufferString("")
cmd := exec.Command(bin, "insert", "--force", passName)
cmd.Stdin = in
cmd.Stdout = out
cmd.Stderr = out
if err := cmd.Run(); err != nil {
return fmt.Errorf("Failed to insert password: %s", out.String())
}
} else {
return fmt.Errorf("Pass binary not found!")
}
} else if o.PasswordSource.Value != "" {
return fmt.Errorf("Unknown password-source: %s", o.PasswordSource)
}
return nil
}
+31
View File
@@ -0,0 +1,31 @@
package jiracli
import (
"net"
"net/http"
"time"
"golang.org/x/net/proxy"
)
func socksProxy(address string) *http.Transport {
return newSocksProxyTransport(address)
}
func newSocksProxyTransport(address string) *http.Transport {
dialer, err := proxy.SOCKS5("tcp", address, nil, proxy.Direct)
if err != nil {
// TODO: whoops, return error?
panic(err)
}
dial := func(network, addr string) (net.Conn, error) {
return dialer.Dial(network, addr)
}
return &http.Transport{
Dial: dial,
DisableKeepAlives: true,
ResponseHeaderTimeout: 30 * time.Second,
ExpectContinueTimeout: 10 * time.Second,
}
}
+644
View File
@@ -0,0 +1,644 @@
package jiracli
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"regexp"
"strconv"
"strings"
"text/template"
yaml "gopkg.in/coryb/yaml.v2"
"github.com/Masterminds/sprig"
"github.com/coryb/figtree"
shellquote "github.com/kballard/go-shellquote"
"github.com/mgutz/ansi"
wordwrap "github.com/mitchellh/go-wordwrap"
"github.com/olekukonko/tablewriter"
"golang.org/x/crypto/ssh/terminal"
)
func findTemplate(name string) ([]byte, error) {
if file, err := findClosestParentPath(filepath.Join(".jira.d", "templates", name)); err == nil {
b, err := ioutil.ReadFile(file)
if err != nil {
return nil, err
}
return b, nil
}
return nil, nil
}
func getTemplate(name string) (string, error) {
if _, err := os.Stat(".jira.d/" + name); err == nil {
b, err := ioutil.ReadFile(".jira.d/" + name)
if err != nil {
return "", err
}
return string(b), nil
}
b, err := findTemplate(name)
if err != nil {
return "", err
}
if b != nil {
return string(b), nil
}
if s, ok := AllTemplates[name]; ok {
return s, nil
}
return "", fmt.Errorf("No Template found for %q", name)
}
func tmpTemplate(templateName string, data interface{}) (string, error) {
tmpFile, err := tmpYml(templateName)
if err != nil {
return "", err
}
defer tmpFile.Close()
return tmpFile.Name(), RunTemplate(templateName, data, tmpFile)
}
func TemplateProcessor() *template.Template {
funcs := map[string]interface{}{
"jira": func() string {
return os.Args[0]
},
"env": func() map[string]string {
out := map[string]string{}
for _, env := range os.Environ() {
kv := strings.SplitN(env, "=", 2)
out[kv[0]] = kv[1]
}
return out
},
"fit": func(size int, content string) string {
return fmt.Sprintf(fmt.Sprintf("%%-%d.%ds", size, size), content)
},
"shellquote": func(content string) string {
return shellquote.Join(content)
},
"toMinJson": func(content interface{}) (string, error) {
bytes, err := json.Marshal(content)
if err != nil {
return "", err
}
return string(bytes), nil
},
"toJson": func(content interface{}) (string, error) {
bytes, err := json.MarshalIndent(content, "", " ")
if err != nil {
return "", err
}
return string(bytes), nil
},
"termWidth": func() int {
w, _, err := terminal.GetSize(int(os.Stdout.Fd()))
if err == nil {
return w
}
if os.Getenv("COLUMNS") != "" {
w, err = strconv.Atoi(os.Getenv("COLUMNS"))
}
if err == nil {
return w
}
return 120
},
"pctOf": func(size, percent int) int {
return int(float32(size) * (float32(percent) / 100))
},
"sub": func(a, b int) int {
return a - b
},
"append": func(more string, content interface{}) (string, error) {
switch value := content.(type) {
case string:
return string(append([]byte(content.(string)), []byte(more)...)), nil
case []byte:
return string(append(content.([]byte), []byte(more)...)), nil
default:
return "", fmt.Errorf("Unknown type: %s", value)
}
},
"indent": func(spaces int, content string) string {
indent := make([]rune, spaces+1)
indent[0] = '\n'
for i := 1; i < spaces+1; i++ {
indent[i] = ' '
}
lineSeps := []rune{'\n', '\u0085', '\u2028', '\u2029'}
for _, sep := range lineSeps {
indent[0] = sep
content = strings.Replace(content, string(sep), string(indent), -1)
}
return content
},
"comment": func(content string) string {
lineSeps := []rune{'\n', '\u0085', '\u2028', '\u2029'}
for _, sep := range lineSeps {
content = strings.Replace(content, string(sep), string([]rune{sep, '#', ' '}), -1)
}
return content
},
"color": func(color string) string {
return ansi.ColorCode(color)
},
"remLineBreak": func(content string) string {
return strings.Replace(strings.Replace(content, string('\r'), string(' '), -1), string('\n'), string(' '), -1)
},
"regReplace": func(search string, replace string, content string) string {
re := regexp.MustCompile(search)
return re.ReplaceAllString(content, replace)
},
"split": func(sep string, content string) []string {
return strings.Split(content, sep)
},
"join": func(sep string, content []interface{}) string {
vals := make([]string, len(content))
for i, v := range content {
vals[i] = v.(string)
}
return strings.Join(vals, sep)
},
"abbrev": func(max int, content string) string {
if len(content) > max && max > 2 {
var buffer bytes.Buffer
buffer.WriteString(content[:max-3])
buffer.WriteString("...")
return buffer.String()
}
return content
},
"rep": func(count int, content string) string {
var buffer bytes.Buffer
for i := 0; i < count; i++ {
buffer.WriteString(content)
}
return buffer.String()
},
"age": func(content string) (string, error) {
return fuzzyAge(content)
},
"dateFormat": func(format string, content string) (string, error) {
return dateFormat(format, content)
},
"wrap": func(width uint, content string) string {
return wordwrap.WrapString(content, width)
},
}
return template.New("gojira").Funcs(sprig.GenericFuncMap()).Funcs(funcs)
}
func ConfigTemplate(fig *figtree.FigTree, template, command string, opts interface{}) (string, error) {
var tmp map[string]interface{}
err := ConvertType(opts, &tmp)
if err != nil {
return "", err
}
fig.LoadAllConfigs(command+".yml", &tmp)
fig.LoadAllConfigs("config.yml", &tmp)
tmpl, err := TemplateProcessor().Parse(template)
if err != nil {
return "", err
}
buf := bytes.NewBufferString("")
if err := tmpl.Execute(buf, &tmp); err != nil {
return "", err
}
return buf.String(), nil
}
func ConvertType(input interface{}, output interface{}) error {
// HACK HACK HACK: convert data formats to json for backwards compatibilty with templates
jsonData, err := json.Marshal(input)
if err != nil {
return err
}
defer func(mapType, iface reflect.Type) {
yaml.DefaultMapType = mapType
yaml.IfaceType = iface
}(yaml.DefaultMapType, yaml.IfaceType)
yaml.DefaultMapType = reflect.TypeOf(map[string]interface{}{})
yaml.IfaceType = yaml.DefaultMapType.Elem()
if err := yaml.Unmarshal(jsonData, output); err != nil {
return err
}
return nil
}
func RunTemplate(templateName string, data interface{}, out io.Writer) error {
templateContent, err := getTemplate(templateName)
if err != nil {
return err
}
if out == nil {
out = os.Stdout
}
var rawData interface{}
err = ConvertType(data, &rawData)
if err != nil {
return err
}
table := tablewriter.NewWriter(out)
table.SetAutoFormatHeaders(false)
headers := []string{}
cells := [][]string{}
tmpl, err := TemplateProcessor().Funcs(map[string]interface{}{
"defaultColWidth": func(cw int) string {
table.SetColWidth(cw)
return ""
},
"headers": func(titles ...string) string {
headers = append(headers, titles...)
return ""
},
"row": func() string {
cells = append(cells, []string{})
return ""
},
"cell": func(value interface{}) (string, error) {
if len(cells) == 0 {
return "", fmt.Errorf(`"cell" template function called before "row" template function`)
}
cells[len(cells)-1] = append(cells[len(cells)-1], fmt.Sprintf("%v", value))
return "", nil
},
}).Parse(templateContent)
if err != nil {
return err
}
if err := tmpl.Execute(out, rawData); err != nil {
return err
}
if len(headers) > 0 || len(cells) > 0 {
table.SetHeader(headers)
table.AppendBulk(cells)
table.Render()
}
return nil
}
var AllTemplates = map[string]string{
"attach-list": defaultAttachListTemplate,
"comment": defaultCommentTemplate,
"component-add": defaultComponentAddTemplate,
"components": defaultComponentsTemplate,
"create": defaultCreateTemplate,
"createmeta": defaultDebugTemplate,
"debug": defaultDebugTemplate,
"edit": defaultEditTemplate,
"editmeta": defaultDebugTemplate,
"epic-create": defaultEpicCreateTemplate,
"epic-list": defaultTableTemplate,
"fields": defaultDebugTemplate,
"issuelinktypes": defaultDebugTemplate,
"issuetypes": defaultIssuetypesTemplate,
"json": defaultDebugTemplate,
"list": defaultListTemplate,
"request": defaultDebugTemplate,
"subtask": defaultSubtaskTemplate,
"table": defaultTableTemplate,
"transition": defaultTransitionTemplate,
"transitions": defaultTransitionsTemplate,
"transmeta": defaultDebugTemplate,
"view": defaultViewTemplate,
"worklog": defaultWorklogTemplate,
"worklogs": defaultWorklogsTemplate,
}
const defaultDebugTemplate = "{{ . | toJson}}\n"
const defaultListTemplate = "{{ range .issues }}{{ .key | append \":\" | printf \"%-12s\"}} {{ .fields.summary }}\n{{ end }}"
const defaultTableTemplate = `{{/* table template */ -}}
{{- headers "Issue" "Summary" "Type" "Priority" "Status" "Age" "Reporter" "Assignee" -}}
{{- range .issues -}}
{{- row -}}
{{- cell .key -}}
{{- cell .fields.summary -}}
{{- cell .fields.issuetype.name -}}
{{- if .fields.priority -}}
{{- cell .fields.priority.name -}}
{{- else -}}
{{- cell "<none>" -}}
{{- end -}}
{{- cell .fields.status.name -}}
{{- cell (.fields.created | age) -}}
{{- if .fields.reporter -}}
{{- cell .fields.reporter.displayName -}}
{{- else -}}
{{- cell "<unknown>" -}}
{{- end -}}
{{- if .fields.assignee -}}
{{- cell .fields.assignee.displayName -}}
{{- else -}}
{{- cell "<unassigned>" -}}
{{- end -}}
{{- end -}}
`
const defaultAttachListTemplate = `{{/* attach list template */ -}}
{{- headers "id" "filename" "bytes" "user" "created" -}}
{{- range . -}}
{{- row -}}
{{- cell .id -}}
{{- cell .filename -}}
{{- cell .size -}}
{{- cell .author.displayName -}}
{{- cell (.created | age) -}}
{{- end -}}
`
const defaultViewTemplate = `{{/* view template */ -}}
issue: {{ .key }}
{{if .fields.created -}}
created: {{ .fields.created | age }} ago
{{end -}}
{{if .fields.status -}}
status: {{ .fields.status.name }}
{{end -}}
summary: {{ .fields.summary }}
project: {{ .fields.project.key }}
{{if .fields.components -}}
components: {{ range .fields.components }}{{ .name }} {{end}}
{{end -}}
{{if .fields.issuetype -}}
issuetype: {{ .fields.issuetype.name }}
{{end -}}
{{if .fields.assignee -}}
assignee: {{ .fields.assignee.displayName }}
{{end -}}
reporter: {{ if .fields.reporter }}{{ .fields.reporter.displayName }}{{end}}
{{if .fields.customfield_10110 -}}
watchers: {{ range .fields.customfield_10110 }}{{ .displayName }} {{end}}
{{end -}}
{{if .fields.issuelinks -}}
blockers: {{ range .fields.issuelinks }}{{if .outwardIssue}}{{ .outwardIssue.key }}[{{.outwardIssue.fields.status.name}}]{{end}}{{end}}
depends: {{ range .fields.issuelinks }}{{if .inwardIssue}}{{ .inwardIssue.key }}[{{.inwardIssue.fields.status.name}}]{{end}}{{end}}
{{end -}}
{{if .fields.priority -}}
priority: {{ .fields.priority.name }}
{{end -}}
{{if .fields.votes -}}
votes: {{ .fields.votes.votes}}
{{end -}}
{{if .fields.labels -}}
labels: {{ join ", " .fields.labels }}
{{end -}}
description: |
{{ or .fields.description "" | indent 2 }}
{{if .fields.comment.comments}}
comments:
{{ range .fields.comment.comments }} - | # {{.author.displayName}}, {{.created | age}} ago
{{ or .body "" | indent 4}}
{{end}}
{{end -}}
`
const defaultEditTemplate = `{{/* edit template */ -}}
# issue: {{ .key }} - created: {{ .fields.created | age}} ago
update:
comment:
- add:
body: |~
{{ or .overrides.comment "" | indent 10 }}
fields:
summary: >-
{{ or .overrides.summary .fields.summary }}
{{- if and .meta.fields.components .meta.fields.components.allowedValues }}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{if .overrides.components }}{{ range (split "," .overrides.components)}}
- name: {{.}}{{end}}{{else}}{{ range .fields.components }}
- name: {{ .name }}{{end}}{{end}}{{end}}
{{- if .meta.fields.assignee }}
{{- if .overrides.assignee }}
assignee:
emailAddress: {{ .overrides.assignee }}
{{- else if .fields.assignee }}
assignee: {{if .fields.assignee.name}}
emailAddress: {{ or .fields.assignee.name}}
{{- else }}
emailAddress: {{.fields.assignee.emailAddress}}{{end}}{{end}}{{end}}
{{- if .meta.fields.reporter}}
reporter:
emailAddress: {{ if .overrides.reporter }}{{ .overrides.reporter }}{{else if .fields.reporter}}{{ .fields.reporter.emailAddress }}{{end}}{{end}}
{{- if .meta.fields.customfield_10110}}
# watchers
customfield_10110: {{ range .fields.customfield_10110 }}
- name: {{ .name }}{{end}}{{if .overrides.watcher}}
- name: {{ .overrides.watcher}}{{end}}{{end}}
{{- if .meta.fields.priority }}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority .fields.priority.name "" }}{{end}}
description: |~
{{ or .overrides.description .fields.description "" | indent 4 }}
# votes: {{ .fields.votes.votes }}
# comments:
# {{ range .fields.comment.comments }} - | # {{.author.displayName}}, {{.created | age}} ago
# {{ or .body "" | indent 4 | comment}}
# {{end}}
`
const defaultTransitionsTemplate = `{{ range .transitions }}{{.id }}: {{.name}}
{{end}}`
const defaultComponentsTemplate = `{{ range . }}{{.id }}: {{.name}}
{{end}}`
const defaultComponentAddTemplate = `{{/* compoinent add template */ -}}
project: {{or .project ""}}
name: {{or .name ""}}
description: {{or .description ""}}
leadUserName: {{or .leadUserName ""}}
`
const defaultIssuetypesTemplate = `{{/* issuetypes template */ -}}
{{ range .issuetypes }}{{color "+bh"}}{{.name | append ":" | printf "%-13s" }}{{color "reset"}} {{.description}}
{{end}}`
const defaultCreateTemplate = `{{/* create template */ -}}
fields:
project:
key: {{ or .overrides.project "" }}
issuetype:
name: {{ or .overrides.issuetype "" }}
summary: >-
{{ or .overrides.summary "" }}{{if .meta.fields.priority.allowedValues}}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority ""}}{{end}}{{if .meta.fields.components.allowedValues}}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{ range split "," (or .overrides.components "")}}
- name: {{ . }}{{end}}{{end}}
description: |~
{{ or .overrides.description "" | indent 4 }}{{if .meta.fields.assignee}}
assignee:
emailAddress: {{ or .overrides.assignee "" }}{{end}}{{if .meta.fields.reporter}}
reporter:
emailAddress: {{ or .overrides.reporter .overrides.login }}{{end}}{{if .meta.fields.customfield_10110}}
# watchers
customfield_10110: {{ range split "," (or .overrides.watchers "")}}
- name: {{.}}{{end}}
- name:{{end}}`
const defaultEpicCreateTemplate = `{{/* epic create template */ -}}
fields:
project:
key: {{ or .overrides.project "" }}
# Epic Name
customfield_10120: {{ or (index .overrides "epic-name") "" }}
summary: >-
{{ or .overrides.summary "" }}{{if .meta.fields.priority.allowedValues}}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority ""}}{{end}}{{if .meta.fields.components.allowedValues}}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{ range split "," (or .overrides.components "")}}
- name: {{ . }}{{end}}{{end}}
description: |~
{{ or .overrides.description "" | indent 4 }}{{if .meta.fields.assignee}}
assignee:
emailAddress: {{ or .overrides.assignee "" }}{{end}}{{if .meta.fields.reporter}}
reporter:
emailAddress: {{ or .overrides.reporter .overrides.login }}{{end}}{{if .meta.fields.customfield_10110}}
# watchers
customfield_10110: {{ range split "," (or .overrides.watchers "")}}
- name: {{.}}{{end}}
- name:{{end}}
issuetype:
name: Epic`
const defaultSubtaskTemplate = `{{/* create subtask template */ -}}
fields:
project:
key: {{ .parent.fields.project.key }}
summary: >-
{{ or .overrides.summary "" }}{{if .meta.fields.priority.allowedValues}}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority ""}}{{end}}{{if .meta.fields.components.allowedValues}}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{ range split "," (or .overrides.components "")}}
- name: {{ . }}{{end}}{{end}}
description: |~
{{ or .overrides.description "" | indent 4 }}{{if .meta.fields.assignee}}
assignee:
emailAddress: {{ or .overrides.assignee "" }}{{end}}{{if .meta.fields.reporter}}
reporter:
emailAddress: {{ or .overrides.reporter .overrides.login }}{{end}}{{if .meta.fields.customfield_10110}}
# watchers
customfield_10110: {{ range split "," (or .overrides.watchers "")}}
- name: {{.}}{{end}}
- name:{{end}}
issuetype:
name: Sub-task
parent:
key: {{ .parent.key }}`
const defaultCommentTemplate = `body: |~
{{ or .overrides.comment "" | indent 2 }}
`
const defaultTransitionTemplate = `{{/* transition template */ -}}
{{- if .meta.fields.comment }}
update:
comment:
- add:
body: |~
{{ or .overrides.comment "" | indent 10 }}
{{- end -}}
fields:
{{- if .meta.fields.assignee }}
{{- if .overrides.assignee }}
assignee:
emailAddress: {{ .overrides.assignee }}
{{- else if .fields.assignee }}
assignee: {{if .fields.assignee.name}}
emailAddress: {{ or .fields.assignee.name}}
{{- else }}
emailAddress: {{.fields.assignee.emailAddress}}{{end}}{{end}}
{{- end -}}
{{if .meta.fields.components}}
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{if .overrides.components }}{{ range (split "," .overrides.components)}}
- name: {{.}}{{end}}{{else}}{{ range .fields.components }}
- name: {{ .name }}{{end}}{{end}}
{{- end -}}
{{if .meta.fields.description}}
description: |~
{{ or .fields.description "" | indent 4 }}
{{- end -}}
{{if .meta.fields.fixVersions -}}
{{if .meta.fields.fixVersions.allowedValues}}
fixVersions: # Values: {{ range .meta.fields.fixVersions.allowedValues }}{{.name}}, {{end}}{{if .overrides.fixVersions}}{{ range (split "," .overrides.fixVersions)}}
- name: {{.}}{{end}}{{else}}{{range .fields.fixVersions}}
- name: {{.name}}{{end}}{{end}}
{{- end -}}
{{- end -}}
{{if .meta.fields.issuetype}}
issuetype: # Values: {{ range .meta.fields.issuetype.allowedValues }}{{.name}}, {{end}}
name: {{if .overrides.issuetype}}{{.overrides.issuetype}}{{else}}{{if .fields.issuetype}}{{.fields.issuetype.name}}{{end}}{{end}}
{{- end -}}
{{if .meta.fields.labels}}
labels: {{range .fields.labels}}
- {{.}}{{end}}{{if .overrides.labels}}{{range (split "," .overrides.labels)}}
- {{.}}{{end}}{{end}}
{{- end -}}
{{if .meta.fields.priority}}
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
name: {{ or .overrides.priority "unassigned" }}
{{- end -}}
{{- if .meta.fields.reporter }}
{{- if .overrides.reporter }}
reporter:
name: {{ .overrides.reporter }}
{{- else if .fields.reporter }}
reporter: {{if .fields.reporter.name}}
name: {{ or .fields.reporter.name}}
{{- else }}
displayName: {{.fields.reporter.displayName}}{{end}}{{end}}
{{- end -}}
{{if .meta.fields.resolution}}
resolution: # Values: {{ range .meta.fields.resolution.allowedValues }}{{.name}}, {{end}}
name: {{if .overrides.resolution}}{{.overrides.resolution}}{{else if .fields.resolution}}{{.fields.resolution.name}}{{else}}{{or .overrides.defaultResolution "Fixed"}}{{end}}
{{- end -}}
{{if .meta.fields.summary}}
summary: >-
{{or .overrides.summary .fields.summary}}
{{- end -}}
{{if .meta.fields.versions.allowedValues}}
versions: # Values: {{ range .meta.fields.versions.allowedValues }}{{.name}}, {{end}}{{if .overrides.versions}}{{ range (split "," .overrides.versions)}}
- name: {{.}}{{end}}{{else}}{{range .fields.versions}}
- name: {{.}}{{end}}{{end}}
{{- end}}
transition:
id: {{ .transition.id }}
name: {{ .transition.name }}
`
const defaultWorklogTemplate = `{{/* worklog template */ -}}
# issue: {{ .issue }}
comment: |~
{{ or .comment "" | indent 2 }}
timeSpent: {{ or .timeSpent "" }}
started: {{ or .started "" }}
`
const defaultWorklogsTemplate = `{{/* worklogs template */ -}}
{{ range .worklogs }}- # {{.author.displayName}}, {{.created | age}} ago
comment: {{ or .comment "" }}
started: {{ .started }}
timeSpent: {{ .timeSpent }}
{{end}}`
+41
View File
@@ -0,0 +1,41 @@
package jiracli
import (
"fmt"
"net"
"net/http"
"os"
"time"
)
type transport struct {
shadow *http.Transport
}
func newUnixProxyTransport(path string) *transport {
dial := func(network, addr string) (net.Conn, error) {
return net.Dial("unix", path)
}
shadow := &http.Transport{
Dial: dial,
DialTLS: dial,
DisableKeepAlives: true,
ResponseHeaderTimeout: 30 * time.Second,
ExpectContinueTimeout: 10 * time.Second,
}
return &transport{shadow}
}
func unixProxy(path string) *transport {
return newUnixProxyTransport(os.ExpandEnv(path))
}
func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
req2 := *req
url2 := *req.URL
req2.URL = &url2
req2.URL.Opaque = fmt.Sprintf("//%s%s", req.URL.Host, req.URL.EscapedPath())
return t.shadow.RoundTrip(&req2)
}
+199
View File
@@ -0,0 +1,199 @@
package jiracli
import (
"fmt"
"os"
"os/exec"
"regexp"
"runtime"
"syscall"
"github.com/coryb/figtree"
"github.com/coryb/kingpeon"
"github.com/coryb/oreo"
jira "github.com/go-jira/jira"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
var usage = `{{define "FormatCommand"}}\
{{if .FlagSummary}} {{.FlagSummary}}{{end}}\
{{range .Args}} {{if not .Required}}[{{end}}<{{.Name}}>{{if .Value|IsCumulative}}...{{end}}{{if not .Required}}]{{end}}{{end}}\
{{end}}\
{{define "FormatBriefCommands"}}\
{{range .FlattenedCommands}}\
{{if not .Hidden}}\
{{ print .FullCommand ":" | printf "%-20s"}} {{.Help}}
{{end}}\
{{end}}\
{{end}}\
{{define "FormatCommands"}}\
{{range .FlattenedCommands}}\
{{if not .Hidden}}\
{{.FullCommand}}{{if .Default}}*{{end}}{{template "FormatCommand" .}}
{{.Help|Wrap 4}}
{{with .Flags|FlagsToTwoColumns}}{{FormatTwoColumnsWithIndent . 4 2}}{{end}}
{{end}}\
{{end}}\
{{end}}\
{{define "FormatUsage"}}\
{{template "FormatCommand" .}}{{if .Commands}} <command> [<args> ...]{{end}}
{{if .Help}}
{{.Help|Wrap 0}}\
{{end}}\
{{end}}\
{{if .Context.SelectedCommand}}\
usage: {{.App.Name}} {{.Context.SelectedCommand}}{{template "FormatCommand" .Context.SelectedCommand}}
{{if .Context.SelectedCommand.Aliases }}\
{{range $top := .App.Commands}}\
{{if eq $top.FullCommand $.Context.SelectedCommand.FullCommand}}\
{{range $alias := $.Context.SelectedCommand.Aliases}}\
alias: {{$.App.Name}} {{$alias}}{{template "FormatCommand" $.Context.SelectedCommand}}
{{end}}\
{{else}}\
{{range $sub := $top.Commands}}\
{{if eq $sub.FullCommand $.Context.SelectedCommand.FullCommand}}\
{{range $alias := $.Context.SelectedCommand.Aliases}}\
alias: {{$.App.Name}} {{$top.Name}} {{$alias}}{{template "FormatCommand" $.Context.SelectedCommand}}
{{end}}\
{{end}}\
{{end}}\
{{end}}\
{{end}}\
{{end}}
{{if .Context.SelectedCommand.Help}}\
{{.Context.SelectedCommand.Help|Wrap 0}}
{{end}}\
{{else}}\
usage: {{.App.Name}}{{template "FormatUsage" .App}}
{{end}}\
{{if .App.Flags}}\
Global flags:
{{.App.Flags|FlagsToTwoColumns|FormatTwoColumns}}
{{end}}\
{{if .Context.SelectedCommand}}\
{{if and .Context.SelectedCommand.Flags|RequiredFlags}}\
Required flags:
{{.Context.SelectedCommand.Flags|RequiredFlags|FlagsToTwoColumns|FormatTwoColumns}}
{{end}}\
{{if .Context.SelectedCommand.Flags|OptionalFlags}}\
Optional flags:
{{.Context.SelectedCommand.Flags|OptionalFlags|FlagsToTwoColumns|FormatTwoColumns}}
{{end}}\
{{end}}\
{{if .Context.Args}}\
Args:
{{.Context.Args|ArgsToTwoColumns|FormatTwoColumns}}
{{end}}\
{{if .Context.SelectedCommand}}\
{{if .Context.SelectedCommand.Commands}}\
Subcommands:
{{template "FormatCommands" .Context.SelectedCommand}}
{{end}}\
{{else if .App.Commands}}\
Commands:
{{template "FormatBriefCommands" .App}}
{{end}}\
`
func CommandLine(fig *figtree.FigTree, o *oreo.Client) *kingpin.Application {
app := kingpin.New("jira", "Jira Command Line Interface")
app.HelpFlag.Short('h')
app.UsageWriter(os.Stdout)
app.ErrorWriter(os.Stderr)
app.Command("version", "Prints version").PreAction(func(*kingpin.ParseContext) error {
fmt.Println(jira.VERSION)
panic(Exit{Code: 0})
})
app.UsageTemplate(usage)
var verbosity int
app.Flag("verbose", "Increase verbosity for debugging").Short('v').PreAction(func(_ *kingpin.ParseContext) error {
os.Setenv("JIRA_DEBUG", fmt.Sprintf("%d", verbosity))
IncreaseLogLevel(1)
return nil
}).CounterVar(&verbosity)
app.Terminate(func(status int) {
for _, arg := range os.Args {
if arg == "-h" || arg == "--help" || len(os.Args) == 1 {
panic(Exit{Code: 0})
}
}
panic(Exit{Code: 1})
})
register(app, o, fig)
// register custom commands
data := struct {
CustomCommands kingpeon.DynamicCommands `yaml:"custom-commands" json:"custom-commands"`
}{}
if err := fig.LoadAllConfigs("config.yml", &data); err != nil {
log.Errorf("%s", err)
panic(Exit{Code: 1})
}
if len(data.CustomCommands) > 0 {
runner := syscall.Exec
if runtime.GOOS == "windows" {
runner = func(binary string, cmd []string, env []string) error {
command := exec.Command(binary, cmd[1:]...)
command.Stdin = os.Stdin
command.Stdout = os.Stdout
command.Stderr = os.Stderr
command.Env = env
return command.Run()
}
}
tmp := map[string]interface{}{}
fig.LoadAllConfigs("config.yml", &tmp)
kingpeon.RegisterDynamicCommandsWithRunner(runner, app, data.CustomCommands, TemplateProcessor())
}
return app
}
func ParseCommandLine(app *kingpin.Application, args []string) {
// checking for default usage of `jira ISSUE-123` but need to allow
// for global options first like: `jira --user mothra ISSUE-123`
ctx, err := app.ParseContext(args)
if err != nil && ctx == nil {
// This is an internal kingpin usage error, duplicate options/commands
log.Fatalf("error: %s, ctx: %v", err, ctx)
}
if ctx != nil {
if ctx.SelectedCommand == nil {
next := ctx.Next()
if next != nil {
if ok, err := regexp.MatchString("^([A-Z]+-)?[0-9]+$", next.Value); err != nil {
log.Errorf("Invalid Regex: %s", err)
} else if ok {
// insert "view" at i=1 (2nd position)
os.Args = append(os.Args[:1], append([]string{"view"}, os.Args[1:]...)...)
}
}
}
}
if _, err := app.Parse(os.Args[1:]); err != nil {
if _, ok := err.(*Error); ok {
log.Errorf("%s", err)
panic(Exit{Code: 1})
}
ctx, _ := app.ParseContext(os.Args[1:])
if ctx != nil {
app.UsageForContext(ctx)
}
log.Errorf("Invalid Usage: %s", err)
panic(Exit{Code: 1})
}
}
+180
View File
@@ -0,0 +1,180 @@
package jiracli
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
"time"
kingpin "gopkg.in/alecthomas/kingpin.v2"
"github.com/coryb/figtree"
)
func Homedir() string {
if runtime.GOOS == "windows" {
return os.Getenv("USERPROFILE")
}
return os.Getenv("HOME")
}
func findClosestParentPath(fileName string) (string, error) {
cwd, err := os.Getwd()
if err != nil {
return "", err
}
paths := figtree.FindParentPaths(Homedir(), cwd, fileName)
if len(paths) > 0 {
return paths[len(paths)-1], nil
}
return "", fmt.Errorf("%s not found in parent directory hierarchy", fileName)
}
func tmpYml(tmpFilePrefix string) (*os.File, error) {
fh, err := ioutil.TempFile("", filepath.Base(tmpFilePrefix))
if err != nil {
return nil, err
}
// now we need to rename the file since we dont control the file extensions
// ... it has to be `.yml` so that vim/emacs etc know what edit mode to apply
// for easier editing
oldFileName := fh.Name()
newFileName := oldFileName + ".yml"
// close tmpfile so we can rename on windows
fh.Close()
if err := os.Rename(oldFileName, newFileName); err != nil {
return nil, err
}
return os.OpenFile(newFileName, os.O_RDWR|os.O_EXCL, 0600)
}
func FlagValue(ctx *kingpin.ParseContext, name string) string {
for _, elem := range ctx.Elements {
if flag, ok := elem.Clause.(*kingpin.FlagClause); ok {
if flag.Model().Name == name {
return *elem.Value
}
}
}
return ""
}
func copyFile(src, dst string) (err error) {
var s, d *os.File
if s, err = os.Open(src); err == nil {
defer s.Close()
if d, err = os.Create(dst); err == nil {
if _, err = io.Copy(d, s); err != nil {
d.Close()
return
}
return d.Close()
}
}
return
}
func fuzzyAge(start string) (string, error) {
t, err := time.Parse("2006-01-02T15:04:05.000-0700", start)
if err != nil {
return "", err
}
delta := time.Since(t)
if delta.Minutes() < 2 {
return "a minute", nil
} else if dm := delta.Minutes(); dm < 45 {
return fmt.Sprintf("%d minutes", int(dm)), nil
} else if dm := delta.Minutes(); dm < 90 {
return "an hour", nil
} else if dh := delta.Hours(); dh < 24 {
return fmt.Sprintf("%d hours", int(dh)), nil
} else if dh := delta.Hours(); dh < 48 {
return "a day", nil
}
return fmt.Sprintf("%d days", int(delta.Hours()/24)), nil
}
func dateFormat(format string, content string) (string, error) {
t, err := time.Parse("2006-01-02T15:04:05.000-0700", content)
if err != nil {
return "", err
}
return t.Format(format), nil
}
// this is a HACK to make yaml parsed documents to be serializable
// to json, so prevent this:
// json: unsupported type: map[interface {}]interface {}
// Also we want to clean up common input errors for the edit
// templates, like dangling "\n"
func yamlFixup(data interface{}) (interface{}, error) {
switch d := data.(type) {
case map[interface{}]interface{}:
// need to copy this map into a string map so json can encode it
copy := make(map[string]interface{})
for key, val := range d {
switch k := key.(type) {
case string:
if fixed, err := yamlFixup(val); err != nil {
return nil, err
} else if fixed != nil {
copy[k] = fixed
}
default:
err := fmt.Errorf("YAML: key %s is type '%T', require 'string'", key, k)
log.Errorf("%s", err)
return nil, err
}
}
if len(copy) == 0 {
return nil, nil
}
return copy, nil
case map[string]interface{}:
copy := make(map[string]interface{})
for k, v := range d {
if fixed, err := yamlFixup(v); err != nil {
return nil, err
} else if fixed != nil {
copy[k] = fixed
}
}
if len(copy) == 0 {
return nil, nil
}
return copy, nil
case []interface{}:
copy := make([]interface{}, 0, len(d))
for _, val := range d {
if fixed, err := yamlFixup(val); err != nil {
return nil, err
} else if fixed != nil {
copy = append(copy, fixed)
}
}
if len(copy) == 0 {
return nil, nil
}
return copy, nil
case *interface{}:
if fixed, err := yamlFixup(*d); err != nil {
return nil, err
} else if fixed != nil {
*d = fixed
}
return d, nil
case string:
if d == "" || d == "\n" {
return nil, nil
}
return d, nil
default:
return d, nil
}
}
+92
View File
@@ -0,0 +1,92 @@
package jiracmd
import (
"fmt"
"strings"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type AssignOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
Assignee string `yaml:"assignee,omitempty" json:"assignee,omitempty"`
}
func CmdAssignRegistry() *jiracli.CommandRegistryEntry {
opts := AssignOptions{}
return &jiracli.CommandRegistryEntry{
"Assign user to issue",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAssignUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
return CmdAssign(o, globals, &opts)
},
}
}
func CmdAssignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
cmd.Flag("default", "use default user for assignee").PreAction(func(ctx *kingpin.ParseContext) error {
if jiracli.FlagValue(ctx, "default") == "true" {
opts.Assignee = "-1"
}
return nil
}).Bool()
cmd.Arg("ISSUE", "issue to assign").Required().StringVar(&opts.Issue)
cmd.Arg("ASSIGNEE", "email or display name of user to assign to issue").StringVar(&opts.Assignee)
return nil
}
// CmdAssign will assign an issue to a user
func CmdAssign(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AssignOptions) error {
if globals.JiraDeploymentType.Value == "" {
serverInfo, err := jira.ServerInfo(o, globals.Endpoint.Value)
if err != nil {
return err
}
globals.JiraDeploymentType.Value = strings.ToLower(serverInfo.DeploymentType)
}
assignFunc := jira.IssueAssign
if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType {
if opts.Assignee != "" && opts.Assignee != "-1" {
users, err := jira.UserSearch(o, globals.Endpoint.Value, &jira.UserSearchOptions{
Query: opts.Assignee,
})
if err != nil {
return err
}
if len(users) > 1 {
return fmt.Errorf("Found %d accounts for users with username %q", len(users), opts.Assignee)
} else if len(users) == 1 {
opts.Assignee = users[0].AccountID
}
}
assignFunc = jira.IssueAssignAccountID
}
err := assignFunc(o, globals.Endpoint.Value, opts.Issue, opts.Assignee)
if err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
}
if opts.Browse.Value {
return CmdBrowse(globals, opts.Issue)
}
return nil
}
+101
View File
@@ -0,0 +1,101 @@
package jiracmd
import (
"fmt"
"os"
"sort"
"golang.org/x/crypto/ssh/terminal"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
jira "github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
yaml "gopkg.in/coryb/yaml.v2"
)
type AttachCreateOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
Attachment string `yaml:"attachment,omitempty" json:"attachment,omitempty"`
Filename string `yaml:"filename,omitempty" json:"filename,omitempty"`
SaveFile string `yaml:"savefile,omitempty" json:"savefile,omitempty"`
}
func CmdAttachCreateRegistry() *jiracli.CommandRegistryEntry {
opts := AttachCreateOptions{}
return &jiracli.CommandRegistryEntry{
"Attach file to issue",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAttachCreateUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
return CmdAttachCreate(o, globals, &opts)
},
}
}
func CmdAttachCreateUsage(cmd *kingpin.CmdClause, opts *AttachCreateOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
cmd.Flag("saveFile", "Write attachment information as yaml to file").StringVar(&opts.SaveFile)
cmd.Flag("filename", "Filename to use for attachment").Short('f').StringVar(&opts.Filename)
cmd.Arg("ISSUE", "issue to assign").Required().StringVar(&opts.Issue)
cmd.Arg("ATTACHMENT", "File to attach to issue, if not provided read from stdin").StringVar(&opts.Attachment)
return nil
}
func CmdAttachCreate(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AttachCreateOptions) error {
var contents *os.File
var err error
if opts.Attachment == "" {
if terminal.IsTerminal(int(os.Stdin.Fd())) {
return fmt.Errorf("ATTACHMENT argument required or redirect from STDIN")
}
contents = os.Stdin
if opts.Filename == "" {
return fmt.Errorf("--filename required when reading from stdin")
}
} else {
contents, err = os.Open(opts.Attachment)
if err != nil {
return err
}
if opts.Filename == "" {
opts.Filename = opts.Attachment
}
}
attachments, err := jira.IssueAttachFile(o, globals.Endpoint.Value, opts.Issue, opts.Filename, contents)
if err != nil {
return err
}
sort.Sort(sort.Reverse(attachments))
if opts.SaveFile != "" {
fh, err := os.Create(opts.SaveFile)
if err != nil {
return err
}
defer fh.Close()
out, err := yaml.Marshal((*attachments)[0])
if err != nil {
return err
}
fh.Write(out)
}
if !globals.Quiet.Value {
fmt.Printf("OK %d %s\n", (*attachments)[0].ID, (*attachments)[0].Content)
}
if opts.Browse.Value {
return CmdBrowse(globals, opts.Issue)
}
return nil
}
+79
View File
@@ -0,0 +1,79 @@
package jiracmd
import (
"fmt"
"io"
"os"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
jira "github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type AttachGetOptions struct {
AttachmentID string `yaml:"attachment-id,omitempty" json:"attachment-id,omitempty"`
OutputFile string `yaml:"output-file,omitempty" json:"output-file,omitempty"`
}
func CmdAttachGetRegistry() *jiracli.CommandRegistryEntry {
opts := AttachGetOptions{}
return &jiracli.CommandRegistryEntry{
"Fetch attachment",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAttachGetUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdAttachGet(o, globals, &opts)
},
}
}
func CmdAttachGetUsage(cmd *kingpin.CmdClause, opts *AttachGetOptions) error {
cmd.Flag("output", "Write attachment to specified file name, '-' for stdout").Short('o').StringVar(&opts.OutputFile)
cmd.Arg("ATTACHMENT-ID", "Attachment id to fetch").StringVar(&opts.AttachmentID)
return nil
}
func CmdAttachGet(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AttachGetOptions) error {
attachment, err := jira.GetAttachment(o, globals.Endpoint.Value, opts.AttachmentID)
if err != nil {
return err
}
resp, err := o.Get(attachment.Content)
if err != nil {
return err
}
defer resp.Body.Close()
var output *os.File
if opts.OutputFile == "-" {
output = os.Stdout
} else if opts.OutputFile != "" {
output, err = os.Create(opts.OutputFile)
if err != nil {
return err
}
defer output.Close()
} else {
output, err = os.Create(attachment.Filename)
if err != nil {
return err
}
defer output.Close()
}
_, err = io.Copy(output, resp.Body)
if err != nil {
return err
}
output.Close()
if opts.OutputFile != "-" && !globals.Quiet.Value {
fmt.Printf("OK Wrote %s\n", output.Name())
}
return nil
}
+69
View File
@@ -0,0 +1,69 @@
package jiracmd
import (
"sort"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type AttachListOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdAttachListRegistry() *jiracli.CommandRegistryEntry {
opts := AttachListOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("attach-list"),
},
}
return &jiracli.CommandRegistryEntry{
"Prints attachment details for issue",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAttachListUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
return CmdAttachList(o, globals, &opts)
},
}
}
func CmdAttachListUsage(cmd *kingpin.CmdClause, opts *AttachListOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Arg("ISSUE", "Issue id to lookup attachments").Required().StringVar(&opts.Issue)
return nil
}
func CmdAttachList(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AttachListOptions) error {
data, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, nil)
if err != nil {
return err
}
// need to conver the interface{} "attachment" field to an actual
// ListOfAttachment object so we can sort it
var attachments jiradata.ListOfAttachment
err = jiracli.ConvertType(data.Fields["attachment"], &attachments)
if err != nil {
return err
}
sort.Sort(&attachments)
if err := opts.PrintTemplate(attachments); err != nil {
return err
}
if opts.Browse.Value {
return CmdBrowse(globals, opts.Issue)
}
return nil
}
+46
View File
@@ -0,0 +1,46 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
jira "github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type AttachRemoveOptions struct {
AttachmentID string `yaml:"attachment-id,omitempty" json:"attachment-id,omitempty"`
}
func CmdAttachRemoveRegistry() *jiracli.CommandRegistryEntry {
opts := AttachRemoveOptions{}
return &jiracli.CommandRegistryEntry{
"Delete attachment",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdAttachRemoveUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdAttachRemove(o, globals, &opts)
},
}
}
func CmdAttachRemoveUsage(cmd *kingpin.CmdClause, opts *AttachRemoveOptions) error {
cmd.Arg("ATTACHMENT-ID", "Attachment id to fetch").StringVar(&opts.AttachmentID)
return nil
}
func CmdAttachRemove(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AttachRemoveOptions) error {
if err := jira.RemoveAttachment(o, globals.Endpoint.Value, opts.AttachmentID); err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK Deleted Attachment %s\n", opts.AttachmentID)
}
return nil
}
+83
View File
@@ -0,0 +1,83 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type BlockOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}
func CmdBlockRegistry() *jiracli.CommandRegistryEntry {
opts := BlockOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("edit"),
},
LinkIssueRequest: jiradata.LinkIssueRequest{
Type: &jiradata.IssueLinkType{
Name: "Blocks",
},
InwardIssue: &jiradata.IssueRef{},
OutwardIssue: &jiradata.IssueRef{},
},
}
return &jiracli.CommandRegistryEntry{
"Mark issues as blocker",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdBlockUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.OutwardIssue.Key = jiracli.FormatIssue(opts.OutwardIssue.Key, opts.Project)
opts.InwardIssue.Key = jiracli.FormatIssue(opts.InwardIssue.Key, opts.Project)
return CmdBlock(o, globals, &opts)
},
}
}
func CmdBlockUsage(cmd *kingpin.CmdClause, opts *BlockOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("comment", "Comment message when marking issue as blocker").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Comment = &jiradata.Comment{
Body: jiracli.FlagValue(ctx, "comment"),
}
return nil
}).String()
cmd.Arg("ISSUE", "issue that is blocked").Required().StringVar(&opts.OutwardIssue.Key)
cmd.Arg("BLOCKER", "blocker issue").Required().StringVar(&opts.InwardIssue.Key)
return nil
}
// CmdBlock will update the given issue as being a duplicate by the given dup issue
// and will attempt to resolve the dup issue
func CmdBlock(o *oreo.Client, globals *jiracli.GlobalOptions, opts *BlockOptions) error {
if err := jira.LinkIssues(o, globals.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.InwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.InwardIssue.Key))
fmt.Printf("OK %s %s\n", opts.OutwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.OutwardIssue.Key))
}
if opts.Browse.Value {
if err := CmdBrowse(globals, opts.InwardIssue.Key); err != nil {
return CmdBrowse(globals, opts.OutwardIssue.Key)
}
}
return nil
}
+37
View File
@@ -0,0 +1,37 @@
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
jira "github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/pkg/browser"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type BrowseOptions struct {
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdBrowseRegistry() *jiracli.CommandRegistryEntry {
opts := BrowseOptions{}
return &jiracli.CommandRegistryEntry{
"Open issue in browser",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
cmd.Arg("ISSUE", "Issue to browse to").Required().StringVar(&opts.Issue)
jiracli.LoadConfigs(cmd, fig, &opts)
return nil
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
return CmdBrowse(globals, opts.Issue)
},
}
}
// CmdBrowse open the default system browser to the provided issue
func CmdBrowse(globals *jiracli.GlobalOptions, issue string) error {
return browser.OpenURL(jira.URLJoin(globals.Endpoint.Value, "browse", issue))
}
+81
View File
@@ -0,0 +1,81 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type CommentOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdCommentRegistry() *jiracli.CommandRegistryEntry {
opts := CommentOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("comment"),
},
Overrides: map[string]string{},
}
return &jiracli.CommandRegistryEntry{
"Add comment to issue",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdCommentUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
return CmdComment(o, globals, &opts)
},
}
}
func CmdCommentUsage(cmd *kingpin.CmdClause, opts *CommentOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
return nil
}).String()
cmd.Arg("ISSUE", "issue id to update").StringVar(&opts.Issue)
return nil
}
// CmdComment will update issue with comment
func CmdComment(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CommentOptions) error {
comment := jiradata.Comment{}
input := struct {
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
}{
opts.Overrides,
}
err := jiracli.EditLoop(&opts.CommonOptions, &input, &comment, func() error {
_, err := jira.IssueAddComment(o, globals.Endpoint.Value, opts.Issue, &comment)
return err
})
if err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
}
if opts.Browse.Value {
return CmdBrowse(globals, opts.Issue)
}
return nil
}
+67
View File
@@ -0,0 +1,67 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type ComponentAddOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.Component `yaml:",inline" json:",inline" figtree:",inline"`
}
func CmdComponentAddRegistry() *jiracli.CommandRegistryEntry {
opts := ComponentAddOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("component-add"),
},
}
return &jiracli.CommandRegistryEntry{
"Add component",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdComponentAddUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdComponentAdd(o, globals, &opts)
},
}
}
func CmdComponentAddUsage(cmd *kingpin.CmdClause, opts *ComponentAddOptions) error {
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
cmd.Flag("project", "project to create component in").Short('p').StringVar(&opts.Project)
cmd.Flag("name", "name of component").Short('n').StringVar(&opts.Name)
cmd.Flag("description", "description of component").Short('d').StringVar(&opts.Description)
cmd.Flag("lead", "person that acts as lead for component").Short('l').StringVar(&opts.LeadUserName)
return nil
}
// CmdComponentAdd sends the provided overrides to the "component-add" template for editing, then
// will parse the edited document as YAML and submit the document to jira.
func CmdComponentAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ComponentAddOptions) error {
var err error
component := &jiradata.Component{}
err = jiracli.EditLoop(&opts.CommonOptions, &opts.Component, component, func() error {
_, err = jira.CreateComponent(o, globals.Endpoint.Value, component)
return err
})
if err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", component.Project, component.Name)
}
return nil
}
+56
View File
@@ -0,0 +1,56 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type ComponentsOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}
func CmdComponentsRegistry() *jiracli.CommandRegistryEntry {
opts := ComponentsOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("components"),
},
}
return &jiracli.CommandRegistryEntry{
"Show components for a project",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdComponentsUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdComponents(o, globals, &opts)
},
}
}
func CmdComponentsUsage(cmd *kingpin.CmdClause, opts *ComponentsOptions) error {
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
jiracli.GJsonQueryUsage(cmd, &opts.CommonOptions)
cmd.Flag("project", "project to list components").Short('p').StringVar(&opts.Project)
return nil
}
// CmdComponents will get available components for project and send to the "components" template
func CmdComponents(o *oreo.Client, globals *jiracli.GlobalOptions, opts *ComponentsOptions) error {
if opts.Project == "" {
return fmt.Errorf("Project Required.")
}
data, err := jira.GetProjectComponents(o, globals.Endpoint.Value, opts.Project)
if err != nil {
return err
}
return opts.PrintTemplate(data)
}
+183
View File
@@ -0,0 +1,183 @@
package jiracmd
import (
"fmt"
"os"
"strings"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
yaml "gopkg.in/coryb/yaml.v2"
)
type CreateOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.IssueUpdate `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Summary string `yaml:"summary,omitempty" json:"summary`
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
SaveFile string `yaml:"savefile,omitempty" json:"savefile,omitempty"`
}
func CmdCreateRegistry() *jiracli.CommandRegistryEntry {
opts := CreateOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("create"),
},
Overrides: map[string]string{},
}
return &jiracli.CommandRegistryEntry{
"Create issue",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdCreateUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdCreate(o, globals, &opts)
},
}
}
func CmdCreateUsage(cmd *kingpin.CmdClause, opts *CreateOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.FileUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
cmd.Flag("project", "project to create issue in").Short('p').StringVar(&opts.Project)
cmd.Flag("summary", "Summary of the issue").Short('s').StringVar(&opts.Summary)
cmd.Flag("issuetype", "issuetype in to create").Short('i').StringVar(&opts.IssueType)
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
return nil
}).String()
cmd.Flag("override", "Set issue property").Short('o').StringMapVar(&opts.Overrides)
cmd.Flag("saveFile", "Write issue as yaml to file").StringVar(&opts.SaveFile)
return nil
}
// CmdCreate sends the create-metadata to the "create" template for editing, then
// will parse the edited document as YAML and submit the document to jira.
func CmdCreate(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateOptions) error {
if globals.JiraDeploymentType.Value == "" {
serverInfo, err := jira.ServerInfo(o, globals.Endpoint.Value)
if err != nil {
return err
}
globals.JiraDeploymentType.Value = strings.ToLower(serverInfo.DeploymentType)
}
type templateInput struct {
Meta *jiradata.IssueType `yaml:"meta" json:"meta"`
Overrides map[string]string `yaml:"overrides" json:"overrides"`
}
if err := defaultIssueType(o, globals.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
return err
}
createMeta, err := jira.GetIssueCreateMetaIssueType(o, globals.Endpoint.Value, opts.Project, opts.IssueType)
if err != nil {
return err
}
issueUpdate := jiradata.IssueUpdate{}
input := templateInput{
Meta: createMeta,
Overrides: opts.Overrides,
}
input.Overrides["project"] = opts.Project
if opts.Summary != "" {
input.Overrides["summary"] = opts.Summary
}
input.Overrides["issuetype"] = opts.IssueType
input.Overrides["login"] = globals.Login.Value
var issueResp *jiradata.IssueCreateResponse
var fnameOptsFile string
fnameOptsFile = opts.File.String()
if fnameOptsFile != "" {
err = jiracli.ReadYmlInputFile(&opts.CommonOptions, &input, &issueUpdate, func() error {
issueResp, err = jira.CreateIssue(o, globals.Endpoint.Value, &issueUpdate)
return err
})
} else {
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType {
err := fixGDPRUserFields(o, globals.Endpoint.Value, createMeta.Fields, issueUpdate.Fields)
if err != nil {
return err
}
}
issueResp, err = jira.CreateIssue(o, globals.Endpoint.Value, &issueUpdate)
return err
})
}
if err != nil {
return err
}
browseLink := jira.URLJoin(globals.Endpoint.Value, "browse", issueResp.Key)
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", issueResp.Key, browseLink)
}
if opts.SaveFile != "" {
fh, err := os.Create(opts.SaveFile)
if err != nil {
return err
}
defer fh.Close()
out, err := yaml.Marshal(map[string]string{
"issue": issueResp.Key,
"link": browseLink,
})
if err != nil {
return err
}
fh.Write(out)
}
if opts.Browse.Value {
return CmdBrowse(globals, issueResp.Key)
}
return nil
}
func defaultIssueType(o *oreo.Client, endpoint string, project, issuetype *string) error {
if project == nil || *project == "" {
return fmt.Errorf("Project undefined, please use --project argument or set the `project` config property")
}
if issuetype != nil && *issuetype != "" {
return nil
}
projectMeta, err := jira.GetIssueCreateMetaProject(o, endpoint, *project)
if err != nil {
return err
}
issueTypes := map[string]bool{}
for _, issuetype := range projectMeta.IssueTypes {
issueTypes[issuetype.Name] = true
}
// prefer "Bug" type
if _, ok := issueTypes["Bug"]; ok {
*issuetype = "Bug"
return nil
}
// next best default it "Task"
if _, ok := issueTypes["Task"]; ok {
*issuetype = "Task"
return nil
}
return fmt.Errorf("Unable to find default issueType of Bug or Task, please set --issuetype argument or set the `issuetype` config property")
}
+54
View File
@@ -0,0 +1,54 @@
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type CreateMetaOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
IssueType string `yaml:"issuetype,omitempty" json:"issuetype,omitempty"`
}
func CmdCreateMetaRegistry() *jiracli.CommandRegistryEntry {
opts := CreateMetaOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("createmeta"),
},
}
return &jiracli.CommandRegistryEntry{
"View 'create' metadata",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdCreateMetaUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdCreateMeta(o, globals, &opts)
},
}
}
func CmdCreateMetaUsage(cmd *kingpin.CmdClause, opts *CreateMetaOptions) error {
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
jiracli.GJsonQueryUsage(cmd, &opts.CommonOptions)
cmd.Flag("project", "project to fetch create metadata").Short('p').StringVar(&opts.Project)
cmd.Flag("issuetype", "issuetype in project to fetch create metadata").Short('i').StringVar(&opts.IssueType)
return nil
}
// Create will get issue create metadata and send to "createmeta" template
func CmdCreateMeta(o *oreo.Client, globals *jiracli.GlobalOptions, opts *CreateMetaOptions) error {
if err := defaultIssueType(o, globals.Endpoint.Value, &opts.Project, &opts.IssueType); err != nil {
return err
}
createMeta, err := jira.GetIssueCreateMetaIssueType(o, globals.Endpoint.Value, opts.Project, opts.IssueType)
if err != nil {
return err
}
return opts.PrintTemplate(createMeta)
}
+118
View File
@@ -0,0 +1,118 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type DupOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.LinkIssueRequest `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}
func CmdDupRegistry() *jiracli.CommandRegistryEntry {
opts := DupOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("edit"),
},
LinkIssueRequest: jiradata.LinkIssueRequest{
Type: &jiradata.IssueLinkType{
Name: "Duplicate",
},
InwardIssue: &jiradata.IssueRef{},
OutwardIssue: &jiradata.IssueRef{},
},
}
return &jiracli.CommandRegistryEntry{
"Mark issues as duplicate",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdDupUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.OutwardIssue.Key = jiracli.FormatIssue(opts.OutwardIssue.Key, opts.Project)
opts.InwardIssue.Key = jiracli.FormatIssue(opts.InwardIssue.Key, opts.Project)
return CmdDup(o, globals, &opts)
},
}
}
func CmdDupUsage(cmd *kingpin.CmdClause, opts *DupOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("comment", "Comment message when marking issue as duplicate").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Comment = &jiradata.Comment{
Body: jiracli.FlagValue(ctx, "comment"),
}
return nil
}).String()
cmd.Arg("DUPLICATE", "duplicate issue to mark closed").Required().StringVar(&opts.InwardIssue.Key)
cmd.Arg("ISSUE", "duplicate issue to leave open").Required().StringVar(&opts.OutwardIssue.Key)
return nil
}
// CmdDup will update the given issue as being a duplicate by the given dup issue
// and will attempt to resolve the dup issue
func CmdDup(o *oreo.Client, globals *jiracli.GlobalOptions, opts *DupOptions) error {
if err := jira.LinkIssues(o, globals.Endpoint.Value, &opts.LinkIssueRequest); err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.OutwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.OutwardIssue.Key))
}
meta, err := jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.InwardIssue.Key)
if err != nil {
return err
}
for _, trans := range []string{"close", "done", "cancel", "start", "stop"} {
transMeta := meta.Transitions.Find(trans)
if transMeta == nil {
continue
}
issueUpdate := jiradata.IssueUpdate{
Transition: transMeta,
}
resolution := defaultResolution(transMeta)
if resolution != "" {
issueUpdate.Fields = map[string]interface{}{
"resolution": map[string]interface{}{
"name": resolution,
},
}
}
if err = jira.TransitionIssue(o, globals.Endpoint.Value, opts.InwardIssue.Key, &issueUpdate); err != nil {
return err
}
if trans != "start" {
break
}
// if we are here then we must be stopping, so need to reset the meta
meta, err = jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.InwardIssue.Key)
if err != nil {
return err
}
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.InwardIssue.Key, jira.URLJoin(globals.Endpoint.Value, "browse", opts.InwardIssue.Key))
}
if opts.Browse.Value {
if err := CmdBrowse(globals, opts.OutwardIssue.Key); err != nil {
return CmdBrowse(globals, opts.InwardIssue.Key)
}
}
return nil
}
+248
View File
@@ -0,0 +1,248 @@
package jiracmd
import (
"fmt"
"strings"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
"gopkg.in/AlecAivazis/survey.v1"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type EditOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
jiradata.IssueUpdate `yaml:",inline" json:",inline" figtree:",inline"`
jira.SearchOptions `yaml:",inline" json:",inline" figtree:",inline"`
Overrides map[string]string `yaml:"overrides,omitempty" json:"overrides,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
Queries map[string]string `yaml:"queries,omitempty" json:"queries,omitempty"`
}
func CmdEditRegistry() *jiracli.CommandRegistryEntry {
opts := EditOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("edit"),
},
Overrides: map[string]string{},
}
return &jiracli.CommandRegistryEntry{
"Edit issue details",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEditUsage(cmd, &opts, fig)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
if opts.QueryFields == "" {
opts.QueryFields = "assignee,created,priority,reporter,status,summary,updated,issuetype,comment,description,votes,created,customfield_10110,components"
}
return CmdEdit(o, globals, &opts)
},
}
}
func CmdEditUsage(cmd *kingpin.CmdClause, opts *EditOptions, fig *figtree.FigTree) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
cmd.Flag("named-query", "The name of a query in the `queries` configuration").Short('n').PreAction(func(ctx *kingpin.ParseContext) error {
name := jiracli.FlagValue(ctx, "named-query")
if query, ok := opts.Queries[name]; ok && query != "" {
var err error
opts.Query, err = jiracli.ConfigTemplate(fig, query, cmd.FullCommand(), opts)
return err
}
return fmt.Errorf("A valid named-query %q not found in `queries` configuration", name)
}).String()
cmd.Flag("query", "Jira Query Language (JQL) expression for the search to edit multiple issues").Short('q').StringVar(&opts.Query)
cmd.Flag("comment", "Comment message for issue").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
return nil
}).String()
cmd.Flag("override", "Set issue property").Short('o').StringMapVar(&opts.Overrides)
cmd.Arg("ISSUE", "issue id to edit").StringVar(&opts.Issue)
return nil
}
// Edit will get issue data and send to "edit" template
func CmdEdit(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditOptions) error {
if globals.JiraDeploymentType.Value == "" {
serverInfo, err := jira.ServerInfo(o, globals.Endpoint.Value)
if err != nil {
return err
}
globals.JiraDeploymentType.Value = strings.ToLower(serverInfo.DeploymentType)
}
type templateInput struct {
*jiradata.Issue `yaml:",inline"`
Meta *jiradata.EditMeta `yaml:"meta" json:"meta"`
Overrides map[string]string `yaml:"overrides" json:"overrides"`
}
if opts.Issue != "" {
issueData, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, nil)
if err != nil {
return err
}
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, opts.Issue)
if err != nil {
return err
}
issueUpdate := jiradata.IssueUpdate{}
input := templateInput{
Issue: issueData,
Meta: editMeta,
Overrides: opts.Overrides,
}
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType {
err := fixGDPRUserFields(o, globals.Endpoint.Value, editMeta.Fields, issueUpdate.Fields)
if err != nil {
return err
}
}
return jira.EditIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate)
})
if err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.Issue, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Issue))
}
if opts.Browse.Value {
return CmdBrowse(globals, opts.Issue)
}
return nil
}
results, err := jira.Search(o, globals.Endpoint.Value, opts)
if err != nil {
return err
}
for i, issueData := range results.Issues {
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, issueData.Key)
if err != nil {
return err
}
issueUpdate := jiradata.IssueUpdate{}
input := templateInput{
Issue: issueData,
Meta: editMeta,
Overrides: opts.Overrides,
}
err = jiracli.EditLoop(&opts.CommonOptions, &input, &issueUpdate, func() error {
if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType {
err := fixGDPRUserFields(o, globals.Endpoint.Value, editMeta.Fields, issueUpdate.Fields)
if err != nil {
return err
}
}
return jira.EditIssue(o, globals.Endpoint.Value, issueData.Key, &issueUpdate)
})
if err == jiracli.EditLoopAbort && len(results.Issues) > i+1 {
var answer bool
survey.AskOne(
&survey.Confirm{
Message: fmt.Sprintf("Continue to edit next issue %s?", results.Issues[i+1].Key),
Default: true,
},
&answer,
nil,
)
if answer {
continue
}
panic(jiracli.Exit{1})
}
if err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", issueData.Key, jira.URLJoin(globals.Endpoint.Value, "browse", issueData.Key))
}
if opts.Browse.Value {
return CmdBrowse(globals, issueData.Key)
}
}
return nil
}
func fixUserField(ua jira.HttpClient, endpoint string, userField map[string]interface{}) error {
if _, ok := userField["accountId"].(string); ok {
// this field is already GDPR ready
return nil
}
queryName, ok := userField["displayName"].(string)
if !ok {
queryName, ok = userField["emailAddress"].(string)
if !ok {
// no fields to search on, skip user lookup
return nil
}
}
users, err := jira.UserSearch(ua, endpoint, &jira.UserSearchOptions{
// Query field will search users displayName and emailAddress
Query: queryName,
})
if err != nil {
return err
}
if len(users) != 1 {
return fmt.Errorf("Found %d accounts for users with query %q", len(users), queryName)
}
userField["accountId"] = users[0].AccountID
return nil
}
func fixGDPRUserFields(ua jira.HttpClient, endpoint string, meta jiradata.FieldMetaMap, fields map[string]interface{}) error {
for fieldName, fieldMeta := range meta {
// check to see if meta-field is in fields data, otherwise skip
if _, ok := fields[fieldName]; !ok {
continue
}
if fieldMeta.Schema.Type == "user" {
userField, ok := fields[fieldName].(map[string]interface{})
if !ok {
// for some reason the field seems to be the wrong type in the data
// even though the schema is a "user"
continue
}
err := fixUserField(ua, endpoint, userField)
if err != nil {
return err
}
fields[fieldName] = userField
}
if fieldMeta.Schema.Type == "array" && fieldMeta.Schema.Items == "user" {
listUserField, ok := fields[fieldName].([]interface{})
if !ok {
// for some reason the field seems to be the wrong type in the data
// even though the schema is a list of "user"
continue
}
for i, userFieldItem := range listUserField {
userField, ok := userFieldItem.(map[string]interface{})
if !ok {
// for some reason the field seems to be the wrong type in the data
// even though the schema is a "user"
continue
}
err := fixUserField(ua, endpoint, userField)
if err != nil {
return err
}
listUserField[i] = userField
}
fields[fieldName] = listUserField
}
}
return nil
}
+59
View File
@@ -0,0 +1,59 @@
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type EditMetaOptions struct {
jiracli.CommonOptions `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Issue string `yaml:"issue,omitempty" json:"issue,omitempty"`
}
func CmdEditMetaRegistry() *jiracli.CommandRegistryEntry {
opts := EditMetaOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("editmeta"),
},
}
return &jiracli.CommandRegistryEntry{
"View 'edit' metadata",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEditMetaUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Issue = jiracli.FormatIssue(opts.Issue, opts.Project)
return CmdEditMeta(o, globals, &opts)
},
}
}
func CmdEditMetaUsage(cmd *kingpin.CmdClause, opts *EditMetaOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
jiracli.GJsonQueryUsage(cmd, &opts.CommonOptions)
cmd.Arg("ISSUE", "edit metadata for issue id").Required().StringVar(&opts.Issue)
return nil
}
// CmdEditMeta will get issue edit metadata and send to "editmeta" template
func CmdEditMeta(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EditMetaOptions) error {
editMeta, err := jira.GetIssueEditMeta(o, globals.Endpoint.Value, opts.Issue)
if err != nil {
return err
}
if err := opts.PrintTemplate(editMeta); err != nil {
return err
}
if opts.Browse.Value {
return CmdBrowse(globals, opts.Issue)
}
return nil
}
+59
View File
@@ -0,0 +1,59 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type EpicAddOptions struct {
jiradata.EpicIssues `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
Epic string `yaml:"epic,omitempty" json:"epic,omitempty"`
}
func CmdEpicAddRegistry() *jiracli.CommandRegistryEntry {
opts := EpicAddOptions{}
return &jiracli.CommandRegistryEntry{
"Add issues to Epic",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEpicAddUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Epic = jiracli.FormatIssue(opts.Epic, opts.Project)
for i := range opts.Issues {
opts.Issues[i] = jiracli.FormatIssue(opts.Issues[i], opts.Project)
}
return CmdEpicAdd(o, globals, &opts)
},
}
}
func CmdEpicAddUsage(cmd *kingpin.CmdClause, opts *EpicAddOptions) error {
cmd.Arg("EPIC", "Epic Key or ID to add issues to").Required().StringVar(&opts.Epic)
cmd.Arg("ISSUE", "Issues to add to epic").Required().StringsVar(&opts.Issues)
return nil
}
func CmdEpicAdd(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EpicAddOptions) error {
if err := jira.EpicAddIssues(o, globals.Endpoint.Value, opts.Epic, &opts.EpicIssues); err != nil {
return err
}
if !globals.Quiet.Value {
fmt.Printf("OK %s %s\n", opts.Epic, jira.URLJoin(globals.Endpoint.Value, "browse", opts.Epic))
for _, issue := range opts.Issues {
fmt.Printf("OK %s %s\n", issue, jira.URLJoin(globals.Endpoint.Value, "browse", issue))
}
}
return nil
}
+48
View File
@@ -0,0 +1,48 @@
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdEpicCreateRegistry() *jiracli.CommandRegistryEntry {
opts := CreateOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("epic-create"),
},
Overrides: map[string]string{},
}
return &jiracli.CommandRegistryEntry{
"Create Epic",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEpicCreateUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdCreate(o, globals, &opts)
},
}
}
func CmdEpicCreateUsage(cmd *kingpin.CmdClause, opts *CreateOptions) error {
jiracli.BrowseUsage(cmd, &opts.CommonOptions)
jiracli.EditorUsage(cmd, &opts.CommonOptions)
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
cmd.Flag("noedit", "Disable opening the editor").SetValue(&opts.SkipEditing)
cmd.Flag("project", "project to create epic in").Short('p').StringVar(&opts.Project)
cmd.Flag("epic-name", "Epic Name").Short('n').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Overrides["epic-name"] = jiracli.FlagValue(ctx, "epic-name")
return nil
}).String()
cmd.Flag("comment", "Comment message for epic").Short('m').PreAction(func(ctx *kingpin.ParseContext) error {
opts.Overrides["comment"] = jiracli.FlagValue(ctx, "comment")
return nil
}).String()
cmd.Flag("override", "Set epic property").Short('o').StringMapVar(&opts.Overrides)
cmd.Flag("saveFile", "Write epic as yaml to file").StringVar(&opts.SaveFile)
return nil
}
+59
View File
@@ -0,0 +1,59 @@
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type EpicListOptions struct {
ListOptions `yaml:",inline" json:",inline" figtree:",inline"`
Epic string `yaml:"epic,omitempty" json:"epic,omitempty"`
}
func CmdEpicListRegistry() *jiracli.CommandRegistryEntry {
opts := EpicListOptions{
ListOptions: ListOptions{
CommonOptions: jiracli.CommonOptions{
Template: figtree.NewStringOption("epic-list"),
},
},
}
return &jiracli.CommandRegistryEntry{
"Prints list of issues for an epic with optional search criteria",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEpicListUsage(cmd, &opts, fig)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
opts.Epic = jiracli.FormatIssue(opts.Epic, opts.Project)
if opts.MaxResults == 0 {
opts.MaxResults = 500
}
if opts.QueryFields == "" {
opts.QueryFields = "assignee,created,priority,reporter,status,summary,updated,issuetype"
}
if opts.Sort == "" {
opts.Sort = "priority asc, key"
}
return CmdEpicList(o, globals, &opts)
},
}
}
func CmdEpicListUsage(cmd *kingpin.CmdClause, opts *EpicListOptions, fig *figtree.FigTree) error {
CmdListUsage(cmd, &opts.ListOptions, fig)
cmd.Arg("EPIC", "Epic Key or ID to list").Required().StringVar(&opts.Epic)
return nil
}
func CmdEpicList(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EpicListOptions) error {
data, err := jira.EpicSearch(o, globals.Endpoint.Value, opts.Epic, opts)
if err != nil {
return err
}
return opts.PrintTemplate(data)
}
+55
View File
@@ -0,0 +1,55 @@
package jiracmd
import (
"fmt"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
"github.com/go-jira/jira/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type EpicRemoveOptions struct {
jiradata.EpicIssues `yaml:",inline" json:",inline" figtree:",inline"`
Project string `yaml:"project,omitempty" json:"project,omitempty"`
}
func CmdEpicRemoveRegistry() *jiracli.CommandRegistryEntry {
opts := EpicRemoveOptions{}
return &jiracli.CommandRegistryEntry{
"Remove issues from Epic",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdEpicRemoveUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
for i := range opts.Issues {
opts.Issues[i] = jiracli.FormatIssue(opts.Issues[i], opts.Project)
}
return CmdEpicRemove(o, globals, &opts)
},
}
}
func CmdEpicRemoveUsage(cmd *kingpin.CmdClause, opts *EpicRemoveOptions) error {
cmd.Arg("ISSUE", "Issues to remove from any epic").Required().StringsVar(&opts.Issues)
return nil
}
func CmdEpicRemove(o *oreo.Client, globals *jiracli.GlobalOptions, opts *EpicRemoveOptions) error {
if err := jira.EpicRemoveIssues(o, globals.Endpoint.Value, &opts.EpicIssues); err != nil {
return err
}
if !globals.Quiet.Value {
for _, issue := range opts.Issues {
fmt.Printf("OK %s %s\n", issue, jira.URLJoin(globals.Endpoint.Value, "browse", issue))
}
}
return nil
}
+71
View File
@@ -0,0 +1,71 @@
package jiracmd
import (
"fmt"
"os"
"path"
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type ExportTemplatesOptions struct {
Template string `yaml:"template,omitempty" json:"template,omitempty"`
Dir string `yaml:"dir,omitempty" json:"dir,omitempty"`
}
func CmdExportTemplatesRegistry() *jiracli.CommandRegistryEntry {
opts := ExportTemplatesOptions{}
return &jiracli.CommandRegistryEntry{
"Export templates for customizations",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdExportTemplatesUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
if opts.Dir == "" {
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
}
return CmdExportTemplates(globals, &opts)
},
}
}
func CmdExportTemplatesUsage(cmd *kingpin.CmdClause, opts *ExportTemplatesOptions) error {
cmd.Flag("template", "Template to export").Short('t').StringVar(&opts.Template)
cmd.Flag("dir", "directory to write tempates to").Short('d').StringVar(&opts.Dir)
return nil
}
// CmdExportTemplates will export templates to directory
func CmdExportTemplates(globals *jiracli.GlobalOptions, opts *ExportTemplatesOptions) error {
if err := os.MkdirAll(opts.Dir, 0755); err != nil {
return err
}
for name, template := range jiracli.AllTemplates {
if opts.Template != "" && opts.Template != name {
continue
}
templateFile := path.Join(opts.Dir, name)
if _, err := os.Stat(templateFile); err == nil {
log.Warning("Skipping %s, already exists", templateFile)
continue
}
fh, err := os.OpenFile(templateFile, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
log.Errorf("Failed to open %s for writing: %s", templateFile, err)
return err
}
defer fh.Close()
if !globals.Quiet.Value {
log.Noticef("Creating %s", templateFile)
}
fh.Write([]byte(template))
}
return nil
}
+36
View File
@@ -0,0 +1,36 @@
package jiracmd
import (
"github.com/coryb/figtree"
"github.com/coryb/oreo"
"github.com/go-jira/jira"
"github.com/go-jira/jira/jiracli"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
func CmdFieldsRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{
Template: figtree.NewStringOption("fields"),
}
return &jiracli.CommandRegistryEntry{
"Prints all fields, both System and Custom",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
jiracli.TemplateUsage(cmd, &opts)
jiracli.GJsonQueryUsage(cmd, &opts)
return nil
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdFields(o, globals, &opts)
},
}
}
// Fields will send data from /rest/api/2/field API to "fields" template
func CmdFields(o *oreo.Client, globals *jiracli.GlobalOptions, opts *jiracli.CommonOptions) error {
data, err := jira.GetFields(o, globals.Endpoint.Value)
if err != nil {
return err
}
return opts.PrintTemplate(data)
}

Some files were not shown because too many files have changed in this diff Show More