Compare commits

..

23 Commits

Author SHA1 Message Date
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
6 changed files with 69 additions and 11 deletions
+23
View File
@@ -1,5 +1,28 @@
# Changelog
## 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)]
+7 -1
View File
@@ -43,7 +43,11 @@ fmt:
install:
export GOBIN=~/bin && ${MAKE} build
CURVER ?= $(shell git fetch --tags && git tag | tail -1)
# need gsort on OSX (brew install coreutils) or newer sort on linux
# that supports the -V option for version sorting
SORT=gsort
CURVER ?= $(shell git fetch --tags && git tag | $(SORT) -V | tail -1)
NEWVER ?= $(shell echo $(CURVER) | awk -F. '{print $$1"."$$2"."$$3+1}')
TODAY := $(shell date +%Y-%m-%d)
@@ -61,6 +65,8 @@ update-changelog:
tail +2 CHANGELOG.md >> CHANGELOG.md.new; \
mv CHANGELOG.md.new CHANGELOG.md; \
git commit -m "Updated Changelog" CHANGELOG.md; \
perl -pi -e "s/version: $(CURVER)/version: $(NEWVER)/" jira/main.go; \
git commit -m "bump version" jira/main.go; \
git tag $(NEWVER)
clean:
+1 -1
View File
@@ -211,7 +211,7 @@ General Options:
Query Options:
-a --assignee=USER Username assigned the issue
-c --component=COMPONENT Component to Search for
-f --queryfields=FIELDS Fields that are used in "list" template: (default: summary,created,priority,status,reporter,assignee)
-f --queryfields=FIELDS Fields that are used in "list" template: (default: summary,created,updated,priority,status,reporter,assignee)
-i --issuetype=ISSUETYPE The Issue Type
-l --limit=VAL Maximum number of results to return in query (default: 500)
-p --project=PROJECT Project to Search for
+17 -4
View File
@@ -2,9 +2,10 @@ package cli
import (
"bytes"
"code.google.com/p/gopass"
"fmt"
"golang.org/x/crypto/ssh/terminal"
"net/http"
"net/http/httputil"
"os"
"strings"
// "github.com/kr/pretty"
@@ -16,13 +17,17 @@ func (c *Cli) CmdLogin() error {
req, _ := http.NewRequest("GET", uri, nil)
user, _ := c.opts["user"].(string)
prompt := fmt.Sprintf("Enter Password for %s: ", user)
passwd, _ := gopass.GetPass(prompt)
fmt.Printf("Enter Password for %s: ", user)
pwbytes, _ := terminal.ReadPassword(int(os.Stdin.Fd()))
passwd := string(pwbytes)
req.SetBasicAuth(user, passwd)
log.Info("%s %s", req.Method, req.URL.String())
if resp, err := c.makeRequest(req); err != nil {
return err
} else {
out, _ := httputil.DumpResponse(resp, true)
log.Debug("%s", out)
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
@@ -110,6 +115,7 @@ func (c *Cli) CmdEdit(issue string) error {
issueData,
func(json string) error {
if c.getOptBool("dryrun", false) {
log.Debug("PUT: %s", json)
log.Debug("Dryrun mode, skipping PUT")
return nil
}
@@ -218,7 +224,7 @@ func (c *Cli) CmdCreate() error {
issueData := make(map[string]interface{})
issueData["overrides"] = c.opts
issueData["overrides"].(map[string]string)["issuetype"] = issuetype
issueData["overrides"].(map[string]interface{})["issuetype"] = issuetype
if val, ok := data.(map[string]interface{})["projects"]; ok {
if len(val.([]interface{})) == 0 {
@@ -240,6 +246,7 @@ func (c *Cli) CmdCreate() error {
log.Debug("JSON: %s", json)
uri := fmt.Sprintf("%s/rest/api/2/issue", c.endpoint)
if c.getOptBool("dryrun", false) {
log.Debug("POST: %s", json)
log.Debug("Dryrun mode, skipping POST")
return nil
}
@@ -301,6 +308,7 @@ func (c *Cli) CmdBlocks(blocker string, issue string) error {
uri := fmt.Sprintf("%s/rest/api/2/issueLink", c.endpoint)
if c.getOptBool("dryrun", false) {
log.Debug("POST: %s", json)
log.Debug("Dryrun mode, skipping POST")
return nil
}
@@ -341,6 +349,7 @@ func (c *Cli) CmdDups(duplicate string, issue string) error {
uri := fmt.Sprintf("%s/rest/api/2/issueLink", c.endpoint)
if c.getOptBool("dryrun", false) {
log.Debug("POST: %s", json)
log.Debug("Dryrun mode, skipping POST")
return nil
}
@@ -372,6 +381,7 @@ func (c *Cli) CmdWatch(issue string) error {
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/watchers", c.endpoint, issue)
if c.getOptBool("dryrun", false) {
log.Debug("POST: %s", json)
log.Debug("Dryrun mode, skipping POST")
return nil
}
@@ -425,6 +435,7 @@ func (c *Cli) CmdTransition(issue string, trans string) error {
// os.Exit(0)
uri = fmt.Sprintf("%s/rest/api/2/issue/%s/transitions", c.endpoint, issue)
if c.getOptBool("dryrun", false) {
log.Debug("POST: %s", json)
log.Debug("Dryrun mode, skipping POST")
return nil
}
@@ -474,6 +485,7 @@ func (c *Cli) CmdComment(issue string) error {
log.Debug("JSON: %s", json)
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/comment", c.endpoint, issue)
if c.getOptBool("dryrun", false) {
log.Debug("POST: %s", json)
log.Debug("Dryrun mode, skipping POST")
return nil
}
@@ -526,6 +538,7 @@ func (c *Cli) CmdAssign(issue string, user string) error {
uri := fmt.Sprintf("%s/rest/api/2/issue/%s/assignee", c.endpoint, issue)
if c.getOptBool("dryrun", false) {
log.Debug("PUT: %s", json)
log.Debug("Dryrun mode, skipping PUT")
return nil
}
+12 -1
View File
@@ -100,6 +100,14 @@ func fuzzyAge(start string) (string, error) {
return "unknown", nil
}
func dateFormat(format string, content string) (string, error) {
if t, err := time.Parse("2006-01-02T15:04:05.000-0700", content); err != nil {
return "", err
} else {
return t.Format(format), nil
}
}
func runTemplate(templateContent string, data interface{}, out io.Writer) error {
if out == nil {
@@ -171,6 +179,9 @@ func runTemplate(templateContent string, data interface{}, out io.Writer) error
"age": func(content string) (string, error) {
return fuzzyAge(content)
},
"dateFormat": func(format string, content string) (string, error) {
return dateFormat(format, content)
},
}
if tmpl, err := template.New("template").Funcs(funcs).Parse(templateContent); err != nil {
log.Error("Failed to parse template: %s", err)
@@ -295,7 +306,7 @@ func yamlFixup(data interface{}) (interface{}, error) {
}
return copy, nil
case string:
if d == "" {
if d == "" || d == "\n" {
return nil, nil
}
return d, nil
+9 -4
View File
@@ -28,7 +28,7 @@ func main() {
user := os.Getenv("USER")
home := os.Getenv("HOME")
defaultQueryFields := "summary,created,priority,status,reporter,assignee"
defaultQueryFields := "summary,created,updated,priority,status,reporter,assignee"
defaultSort := "priority asc, created"
defaultMaxResults := 500
@@ -84,6 +84,7 @@ General Options:
-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 Print version
Query Options:
-a --assignee=USER Username assigned the issue
@@ -164,6 +165,10 @@ Command Options:
op := optigo.NewDirectAssignParser(map[string]interface{}{
"h|help": usage,
"version": func() {
fmt.Println("version: 0.0.14")
os.Exit(0)
},
"v|verbose+": func() {
logging.SetLevel(logging.GetLevel("")+1, "")
},
@@ -222,7 +227,7 @@ Command Options:
// check to see if it was set in the configs:
if value, ok := opts["command"].(string); ok {
command = value
} else {
} else if _, ok := jiraCommands[command]; !ok || command == "" {
args = append([]string{command}, args...)
command = "view"
}
@@ -239,7 +244,7 @@ Command Options:
log.Debug("args: %v", args)
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")
log.Error("endpoint option required. Either use --endpoint or set a endpoint option in your ~/.jira.d/config.yml file")
os.Exit(1)
}
@@ -347,7 +352,7 @@ Command Options:
case "browse":
opts["browse"] = true
err = c.Browse(args[0])
case "export-tempaltes":
case "export-templates":
err = c.CmdExportTemplates()
case "assign":
err = c.CmdAssign(args[0], args[1])