Compare commits

..

24 Commits

Author SHA1 Message Date
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
18 changed files with 97 additions and 45 deletions
+6 -3
View File
@@ -5,12 +5,15 @@ before_install:
language: go
go_import_path: gopkg.in/Netflix-Skunkworks/go-jira.v1
go:
- 1.8
- 1.9
matrix:
fast_finish: true
script:
- make vet
- go get -t -v ./...
- go test ./...
- go vet -composites=false ./...
- make
- make prove 2>&1
- make prove 2>&1
+15
View File
@@ -1,5 +1,20 @@
# Changelog
## 1.0.13 - 2017-10-28
* 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)]
+1 -1
View File
@@ -473,7 +473,7 @@ Commands:
labels set: Set labels on an issue
list: Prints list of issues for given search criteria
login: Attempt to login into jira server
logout: Deactivate sesssion with Jira server
logout: Deactivate session with Jira server
rank: Mark issues as blocker
reopen: Transition issue to reopen state
request: Open issue in requestr
+1 -10
View File
@@ -246,7 +246,7 @@ func (j *Jira) GetIssueCreateMetaIssueType(projectKey, issueTypeName string) (*j
}
func GetIssueCreateMetaIssueType(ua HttpClient, endpoint string, projectKey, issueTypeName string) (*jiradata.IssueType, error) {
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", endpoint, projectKey, issueTypeName)
uri := fmt.Sprintf("%s/rest/api/2/issue/createmeta?projectKeys=%s&issuetypeNames=%s&expand=projects.issuetypes.fields", endpoint, projectKey, url.QueryEscape(issueTypeName))
resp, err := ua.GetJSON(uri)
if err != nil {
return nil, err
@@ -571,15 +571,6 @@ func IssueAttachFile(ua HttpClient, endpoint string, issue, filename string, con
defer resp.Body.Close()
if resp.StatusCode == 200 {
// FIXME move this to a test, and run go tests as part of our regression
if false {
// this is because schema is wrong, defaults to type `int`, so we manually change it
// to `string`. If the jiradata is regenerated we need to manually make the change
// again.
log.Debugf("Assert Attachment.ID is a string, rather than int: %v", &jiradata.Attachment{
ID: jiradata.IntOrString(0),
})
}
results := jiradata.ListOfAttachment{}
return &results, readJSON(resp.Body, &results)
}
+1 -1
View File
@@ -7,7 +7,7 @@ import (
var log = logging.MustGetLogger("jira")
const VERSION = "1.0.11"
const VERSION = "1.0.13"
type Jira struct {
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
+13
View File
@@ -8,6 +8,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
"reflect"
"strconv"
"strings"
@@ -65,6 +66,14 @@ func TemplateProcessor() *template.Template {
"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
},
"toJson": func(content interface{}) (string, error) {
bytes, err := json.MarshalIndent(content, "", " ")
if err != nil {
@@ -123,6 +132,10 @@ func TemplateProcessor() *template.Template {
"color": func(color string) string {
return ansi.ColorCode(color)
},
"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)
},
+3 -3
View File
@@ -33,12 +33,12 @@ func CmdEditRegistry() *jiracli.CommandRegistryEntry {
"Edit issue details",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
if opts.QueryFields == "" {
opts.QueryFields = "assignee,created,priority,reporter,status,summary,updated,issuetype,comments,description,votes,created,customfield_10110,components"
}
return CmdEditUsage(cmd, &opts, fig)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
if opts.QueryFields == "" {
opts.QueryFields = "assignee,created,priority,reporter,status,summary,updated,issuetype,comments,description,votes,created,customfield_10110,components"
}
return CmdEdit(o, globals, &opts)
},
}
+3 -3
View File
@@ -26,6 +26,9 @@ func CmdEpicListRegistry() *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 {
if opts.MaxResults == 0 {
opts.MaxResults = 500
}
@@ -35,9 +38,6 @@ func CmdEpicListRegistry() *jiracli.CommandRegistryEntry {
if opts.Sort == "" {
opts.Sort = "priority asc, key"
}
return CmdEpicListUsage(cmd, &opts, fig)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdEpicList(o, globals, &opts)
},
}
+3 -3
View File
@@ -23,12 +23,12 @@ func CmdExportTemplatesRegistry() *jiracli.CommandRegistryEntry {
"Export templates for customizations",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
if opts.Dir == "" {
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
}
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)
},
}
+3 -3
View File
@@ -27,6 +27,9 @@ func CmdListRegistry() *jiracli.CommandRegistryEntry {
"Prints list of issues for given search criteria",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return CmdListUsage(cmd, &opts, fig)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
if opts.MaxResults == 0 {
opts.MaxResults = 500
}
@@ -36,9 +39,6 @@ func CmdListRegistry() *jiracli.CommandRegistryEntry {
if opts.Sort == "" {
opts.Sort = "priority asc, key"
}
return CmdListUsage(cmd, &opts, fig)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
return CmdList(o, globals, &opts)
},
}
+1 -1
View File
@@ -14,7 +14,7 @@ import (
func CmdLogoutRegistry() *jiracli.CommandRegistryEntry {
opts := jiracli.CommonOptions{}
return &jiracli.CommandRegistryEntry{
"Deactivate sesssion with Jira server",
"Deactivate session with Jira server",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
return nil
+3 -3
View File
@@ -32,14 +32,14 @@ func CmdRequestRegistry() *jiracli.CommandRegistryEntry {
"Open issue in requestr",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
if opts.Method == "" {
opts.Method = "GET"
}
jiracli.TemplateUsage(cmd, &opts.CommonOptions)
jiracli.GJsonQueryUsage(cmd, &opts.CommonOptions)
return CmdRequestUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
if opts.Method == "" {
opts.Method = "GET"
}
return CmdRequest(o, globals, &opts)
},
}
+3 -3
View File
@@ -33,12 +33,12 @@ func CmdSubtaskRegistry() *jiracli.CommandRegistryEntry {
"Subtask issue",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
if opts.IssueType == "" {
opts.IssueType = "Sub-task"
}
return CmdSubtaskUsage(cmd, &opts)
},
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
if opts.IssueType == "" {
opts.IssueType = "Sub-task"
}
return CmdSubtask(o, globals, &opts)
},
}
+1
View File
@@ -63,6 +63,7 @@ func CmdTransitionUsage(cmd *kingpin.CmdClause, opts *TransitionOptions) error {
cmd.Arg("TRANSITION", "State to transition issue to").Required().StringVar(&opts.Transition)
}
cmd.Arg("ISSUE", "issue to transition").Required().StringVar(&opts.Issue)
cmd.Flag("resolution", "Set resolution on transition").StringVar(&opts.Resolution)
return nil
}
+3 -4
View File
@@ -20,13 +20,12 @@ func CmdUnexportTemplatesRegistry() *jiracli.CommandRegistryEntry {
"Remove unmodified exported templates",
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
jiracli.LoadConfigs(cmd, fig, &opts)
if opts.Dir != "" {
opts.Dir = fmt.Sprintf("%s/.jira.d/templates", jiracli.Homedir())
}
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 CmdUnexportTemplates(globals, &opts)
},
}
+15
View File
@@ -0,0 +1,15 @@
package jiradata
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestAttachmentID(t *testing.T) {
// this is because schema is wrong, defaults to type `int`, so we manually change it
// to `string`. If the jiradata is regenerated we need to manually make the change
// again to include:
// ID IntOrString `json:"id,omitempty" yaml:"id,omitempty"`
assert.IsType(t, IntOrString(0), Attachment{}.ID)
}
+8 -7
View File
@@ -46,11 +46,12 @@ package jiradata
// }
// }
type IssueType struct {
AvatarID int `json:"avatarId,omitempty" yaml:"avatarId,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
IconURL string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Self string `json:"self,omitempty" yaml:"self,omitempty"`
Subtask bool `json:"subtask,omitempty" yaml:"subtask,omitempty"`
AvatarID int `json:"avatarId,omitempty" yaml:"avatarId,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Fields FieldMetaMap `json:"fields,omitempty" yaml:"fields,omitempty"`
IconURL string `json:"iconUrl,omitempty" yaml:"iconUrl,omitempty"`
ID string `json:"id,omitempty" yaml:"id,omitempty"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Self string `json:"self,omitempty" yaml:"self,omitempty"`
Subtask bool `json:"subtask,omitempty" yaml:"subtask,omitempty"`
}
+14
View File
@@ -0,0 +1,14 @@
package jiradata
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIssueTypeFields(t *testing.T) {
// this is because schema is wrong, missing the 'Fields' arguments, so we manually add it.
// If the jiradata is regenerated we need to manually make the change again to include:
// Fields FieldMetaMap `json:"fields,omitempty" yaml:"fields,omitempty"`
assert.IsType(t, FieldMetaMap{}, IssueType{}.Fields)
}