Compare commits

..

8 Commits

Author SHA1 Message Date
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
7 changed files with 88 additions and 4 deletions
+6
View File
@@ -1,5 +1,11 @@
# Changelog
## 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)]
+1 -1
View File
@@ -544,7 +544,7 @@ func (c *Cli) FindIssues() (interface{}, error) {
json, err := jsonEncode(map[string]interface{}{
"jql": query,
"startAt": "0",
"startAt": c.opts["start_at"],
"maxResults": c.opts["max_results"],
"fields": fields,
"expand": c.expansions(),
+44
View File
@@ -531,6 +531,50 @@ func (c *Cli) CmdIssueLinkTypes() error {
return runTemplate(c.getTemplate("issuelinktypes"), data, nil)
}
// CmdIssueLink is a generic function for adding a link type to an issue
func (c *Cli) CmdIssueLink(inwardIssue string, issueLinkTypeName string, outwardIssue string) error {
log.Debugf("issuelink called")
json, err := jsonEncode(map[string]interface{}{
"type": map[string]string{
"name": issueLinkTypeName,
},
"inwardIssue": map[string]string{
"key": inwardIssue,
},
"outwardIssue": map[string]string{
"key": outwardIssue,
},
})
if err != nil {
return err
}
uri := fmt.Sprintf("%s/rest/api/2/issueLink", c.endpoint)
if c.getOptBool("dryrun", false) {
log.Debugf("POST: %s", json)
log.Debugf("Dryrun mode, skipping POST")
return nil
}
resp, err := c.post(uri, json)
if err != nil {
return err
}
if resp.StatusCode == 201 {
c.Browse(inwardIssue)
if !c.opts["quiet"].(bool) {
fmt.Printf("OK %s %s/browse/%s\n", inwardIssue, c.endpoint, inwardIssue)
}
} else {
logBuffer := bytes.NewBuffer(make([]byte, 0))
resp.Write(logBuffer)
err := fmt.Errorf("Unexpected Response From POST")
log.Errorf("%s:\n%s", err, logBuffer)
return err
}
return nil
}
// CmdBlocks will update the given issue as being "blocked" by the given blocker
func (c *Cli) CmdBlocks(blocker string, issue string) error {
log.Debugf("blocks called")
+13
View File
@@ -0,0 +1,13 @@
// +build !windows
package jira
import "github.com/tmc/keyring"
func keyringGet(user string) (string, error) {
return keyring.Get("go-jira", user)
}
func keyringSet(user, passwd string) error {
return keyring.Set("go-jira", user, passwd)
}
+11
View File
@@ -0,0 +1,11 @@
package jira
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")
}
+7
View File
@@ -64,6 +64,7 @@ Usage:
jira subtask ISSUE [--noedit] <Create Options>
jira DUPLICATE dups ISSUE
jira BLOCKER blocks ISSUE
jira issuelink OUTWARDISSUE ISSUELINKTYPE INWARDISSUE
jira vote ISSUE [--down]
jira rank ISSUE (after|before) ISSUE
jira watch ISSUE [-w WATCHER] [--remove]
@@ -115,6 +116,7 @@ Query Options:
-f --queryfields=FIELDS Fields that are used in "list" template: (default: %s)
-i --issuetype=ISSUETYPE The Issue Type
-l --limit=VAL Maximum number of results to return in query (default: %d)
--start=START Start parameter for pagination
-p --project=PROJECT Project to Search for
-q --query=JQL Jira Query Language expression for the search
-r --reporter=USER Reporter to search for
@@ -150,6 +152,7 @@ Command Options:
"subtask": "subtask",
"dups": "dups",
"blocks": "blocks",
"issuelink": "issuelink",
"watch": "watch",
"trans": "transition",
"transition": "transition",
@@ -236,6 +239,7 @@ Command Options:
"x|expand=s": setopt,
"s|sort=s": setopt,
"l|limit|max_results=i": setopt,
"start|start_at=i": setopt,
"o|override=s%": &opts,
"noedit": setopt,
"edit": setopt,
@@ -335,6 +339,9 @@ Command Options:
var err error
switch command {
case "issuelink":
requireArgs(3)
err = c.CmdIssueLink(args[0], args[1], args[2])
case "login":
err = c.CmdLogin()
case "logout":
+6 -3
View File
@@ -7,14 +7,17 @@ import (
"strings"
"github.com/howeyc/gopass"
"github.com/tmc/keyring"
)
func (c *Cli) GetPass(user string) string {
passwd := ""
if source, ok := c.opts["password-source"].(string); ok {
if source == "keyring" {
passwd, _ = keyring.Get("go-jira", user)
var err error
passwd, err = keyringGet(user)
if err != nil {
panic(err)
}
} else if source == "pass" {
if bin, err := exec.LookPath("pass"); err == nil {
buf := bytes.NewBufferString("")
@@ -48,7 +51,7 @@ func (c *Cli) SetPass(user, passwd string) error {
log.Debugf("password-source: %s", source)
if source == "keyring" {
// save password in keychain so that it can be used for subsequent http requests
err := keyring.Set("go-jira", user, passwd)
err := keyringSet(user, passwd)
if err != nil {
log.Errorf("Failed to set password in keyring: %s", err)
return err