diff --git a/cmd/jira/main.go b/cmd/jira/main.go index a221da3b..c26bde67 100644 --- a/cmd/jira/main.go +++ b/cmd/jira/main.go @@ -120,6 +120,10 @@ func main() { Command: "dup", Entry: cli.CmdDupRegistry(), }, + jiracli.CommandRegistry{ + Command: "block", + Entry: cli.CmdBlockRegistry(), + }, jiracli.CommandRegistry{ Command: "transition", Aliases: []string{"trans"}, diff --git a/jiracli/block.go b/jiracli/block.go index f560c89b..e03f82c0 100644 --- a/jiracli/block.go +++ b/jiracli/block.go @@ -1,6 +1,8 @@ package jiracli import ( + "fmt" + "gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata" kingpin "gopkg.in/alecthomas/kingpin.v2" ) @@ -61,7 +63,12 @@ func (jc *JiraCli) CmdBlock(opts *BlockOptions) error { Key: opts.Blocker, } - return jc.LinkIssues(&opts.LinkIssueRequest) + if err := jc.LinkIssues(&opts.LinkIssueRequest); err != nil { + return err + } + + fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, jc.Endpoint, opts.Issue) + fmt.Printf("OK %s %s/browse/%s\n", opts.Blocker, jc.Endpoint, opts.Blocker) // FIXME implement browse diff --git a/jiracli/create.go b/jiracli/create.go index 55c21035..8f676899 100644 --- a/jiracli/create.go +++ b/jiracli/create.go @@ -85,8 +85,7 @@ func (jc *JiraCli) CmdCreate(opts *CreateOptions) error { return err } - link := fmt.Sprintf("%s/browse/%s", jc.Endpoint, issueResp.Key) - fmt.Printf("OK %s %s\n", issueResp.Key, link) + fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, jc.Endpoint, issueResp.Key) // FIXME implement browse return nil diff --git a/jiracli/dup.go b/jiracli/dup.go index 0e63e38e..40c7a704 100644 --- a/jiracli/dup.go +++ b/jiracli/dup.go @@ -1,6 +1,8 @@ package jiracli import ( + "fmt" + "gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata" kingpin "gopkg.in/alecthomas/kingpin.v2" ) @@ -61,9 +63,32 @@ func (jc *JiraCli) CmdDup(opts *DupOptions) error { Key: opts.Issue, } - return jc.LinkIssues(&opts.LinkIssueRequest) + if err := jc.LinkIssues(&opts.LinkIssueRequest); err != nil { + return err + } + fmt.Printf("OK %s %s/browse/%s\n", opts.Issue, jc.Endpoint, opts.Issue) + + meta, err := jc.GetIssueTransitions(opts.Duplicate) + if err != nil { + return err + } + for _, trans := range []string{"close", "done", "start", "stop"} { + transMeta := meta.Transitions.Find(trans) + if transMeta != nil { + issueUpdate := jiradata.IssueUpdate{ + Transition: transMeta, + } + if err = jc.TransitionIssue(opts.Duplicate, &issueUpdate); err != nil { + return err + } + // if we just started the issue now we need to stop it + if trans != "start" { + break + } + } + } - // FIXME need to close/done/start&stop dup issue + fmt.Printf("OK %s %s/browse/%s\n", opts.Duplicate, jc.Endpoint, opts.Duplicate) // FIXME implement browse diff --git a/jiracli/edit.go b/jiracli/edit.go index b46d2292..d97a6530 100644 --- a/jiracli/edit.go +++ b/jiracli/edit.go @@ -109,8 +109,8 @@ func (jc *JiraCli) CmdEdit(issue string, opts *EditOptions) error { if err != nil { return err } - link := fmt.Sprintf("%s/browse/%s", jc.Endpoint, issueData.Key) - fmt.Printf("OK %s %s\n", issueData.Key, link) + fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, jc.Endpoint, issueData.Key) + // FIXME implement browse } return nil diff --git a/jiracli/subtask.go b/jiracli/subtask.go index 11d2e8f6..72adb65b 100644 --- a/jiracli/subtask.go +++ b/jiracli/subtask.go @@ -101,8 +101,7 @@ func (jc *JiraCli) CmdSubtask(opts *SubtaskOptions) error { return err } - link := fmt.Sprintf("%s/browse/%s", jc.Endpoint, issueResp.Key) - fmt.Printf("OK %s %s\n", issueResp.Key, link) + fmt.Printf("OK %s %s/browse/%s\n", issueResp.Key, jc.Endpoint, issueResp.Key) // FIXME implement browse return nil diff --git a/jiracli/transition.go b/jiracli/transition.go index 8a7a4c24..775e9179 100644 --- a/jiracli/transition.go +++ b/jiracli/transition.go @@ -123,8 +123,8 @@ func (jc *JiraCli) CmdTransition(opts *TransitionOptions) error { if err != nil { return err } - link := fmt.Sprintf("%s/browse/%s", jc.Endpoint, issueData.Key) - fmt.Printf("OK %s %s\n", issueData.Key, link) + fmt.Printf("OK %s %s/browse/%s\n", issueData.Key, jc.Endpoint, issueData.Key) + // FIXME implement browse return nil } diff --git a/jiradata/#SearchResults.go# b/jiradata/#SearchResults.go# deleted file mode 100644 index 0797c83c..00000000 --- a/jiradata/#SearchResults.go# +++ /dev/null @@ -1,781 +0,0 @@ -package jiradata - -///////////////////////////////////////////////////////////////////////// -// This Code is Generated by SlipScheme Project: -// https://github.com/coryb/slipscheme -// -// Generated with command: -// slipscheme -dir data -pkg jiradata -overwrite schemas/SearchResults.json -///////////////////////////////////////////////////////////////////////// -// DO NOT EDIT // -///////////////////////////////////////////////////////////////////////// - -// SearchResults defined from schema: -// { -// "title": "Search Results", -// "id": "https://docs.atlassian.com/jira/REST/schema/search-results#", -// "type": "object", -// "definitions": { -// "field-meta": { -// "title": "Field Meta", -// "type": "object", -// "properties": { -// "allowedValues": { -// "type": "array", -// "items": {} -// }, -// "autoCompleteUrl": { -// "type": "string" -// }, -// "defaultValue": {}, -// "hasDefaultValue": { -// "type": "boolean" -// }, -// "key": { -// "type": "string" -// }, -// "name": { -// "type": "string" -// }, -// "operations": { -// "type": "array", -// "items": { -// "type": "string" -// } -// }, -// "required": { -// "type": "boolean" -// }, -// "schema": { -// "$ref": "#/definitions/json-type" -// } -// } -// }, -// "history-metadata-participant": { -// "title": "History Metadata Participant", -// "type": "object", -// "properties": { -// "avatarUrl": { -// "type": "string" -// }, -// "displayName": { -// "type": "string" -// }, -// "displayNameKey": { -// "type": "string" -// }, -// "id": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// }, -// "url": { -// "type": "string" -// } -// } -// }, -// "json-type": { -// "title": "Json Type", -// "type": "object", -// "properties": { -// "custom": { -// "type": "string" -// }, -// "customId": { -// "type": "integer" -// }, -// "items": { -// "type": "string" -// }, -// "system": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// } -// } -// }, -// "link-group": { -// "title": "Link Group", -// "type": "object", -// "properties": { -// "groups": { -// "type": "array", -// "items": { -// "$ref": "#/definitions/link-group" -// } -// }, -// "header": { -// "$ref": "#/definitions/simple-link" -// }, -// "id": { -// "type": "string" -// }, -// "links": { -// "type": "array", -// "items": { -// "$ref": "#/definitions/simple-link" -// } -// }, -// "styleClass": { -// "type": "string" -// }, -// "weight": { -// "type": "integer" -// } -// } -// }, -// "simple-link": { -// "title": "Simple Link", -// "type": "object", -// "properties": { -// "href": { -// "type": "string" -// }, -// "iconClass": { -// "type": "string" -// }, -// "id": { -// "type": "string" -// }, -// "label": { -// "type": "string" -// }, -// "styleClass": { -// "type": "string" -// }, -// "title": { -// "type": "string" -// }, -// "weight": { -// "type": "integer" -// } -// } -// } -// }, -// "properties": { -// "expand": { -// "title": "expand", -// "type": "string" -// }, -// "issues": { -// "title": "issues", -// "type": "array", -// "items": { -// "title": "Issue", -// "type": "object", -// "properties": { -// "changelog": { -// "title": "Changelog", -// "type": "object", -// "properties": { -// "histories": { -// "title": "histories", -// "type": "array", -// "items": { -// "title": "Change History", -// "type": "object", -// "properties": { -// "author": { -// "title": "User", -// "type": "object", -// "properties": { -// "accountId": { -// "title": "accountId", -// "type": "string" -// }, -// "active": { -// "title": "active", -// "type": "boolean" -// }, -// "avatarUrls": { -// "title": "avatarUrls", -// "type": "object", -// "patternProperties": { -// ".+": { -// "type": "string" -// } -// } -// }, -// "displayName": { -// "title": "displayName", -// "type": "string" -// }, -// "emailAddress": { -// "title": "emailAddress", -// "type": "string" -// }, -// "key": { -// "title": "key", -// "type": "string" -// }, -// "name": { -// "title": "name", -// "type": "string" -// }, -// "self": { -// "title": "self", -// "type": "string" -// }, -// "timeZone": { -// "title": "timeZone", -// "type": "string" -// } -// } -// }, -// "created": { -// "title": "created", -// "type": "string" -// }, -// "historyMetadata": { -// "title": "History Metadata", -// "type": "object", -// "properties": { -// "activityDescription": { -// "title": "activityDescription", -// "type": "string" -// }, -// "activityDescriptionKey": { -// "title": "activityDescriptionKey", -// "type": "string" -// }, -// "actor": { -// "title": "History Metadata Participant", -// "type": "object", -// "properties": { -// "avatarUrl": { -// "type": "string" -// }, -// "displayName": { -// "type": "string" -// }, -// "displayNameKey": { -// "type": "string" -// }, -// "id": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// }, -// "url": { -// "type": "string" -// } -// } -// }, -// "cause": { -// "title": "History Metadata Participant", -// "type": "object", -// "properties": { -// "avatarUrl": { -// "type": "string" -// }, -// "displayName": { -// "type": "string" -// }, -// "displayNameKey": { -// "type": "string" -// }, -// "id": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// }, -// "url": { -// "type": "string" -// } -// } -// }, -// "description": { -// "title": "description", -// "type": "string" -// }, -// "descriptionKey": { -// "title": "descriptionKey", -// "type": "string" -// }, -// "emailDescription": { -// "title": "emailDescription", -// "type": "string" -// }, -// "emailDescriptionKey": { -// "title": "emailDescriptionKey", -// "type": "string" -// }, -// "extraData": { -// "title": "extraData", -// "type": "object", -// "patternProperties": { -// ".+": { -// "type": "string" -// } -// } -// }, -// "generator": { -// "title": "History Metadata Participant", -// "type": "object", -// "properties": { -// "avatarUrl": { -// "type": "string" -// }, -// "displayName": { -// "type": "string" -// }, -// "displayNameKey": { -// "type": "string" -// }, -// "id": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// }, -// "url": { -// "type": "string" -// } -// } -// }, -// "type": { -// "title": "type", -// "type": "string" -// } -// } -// }, -// "id": { -// "title": "id", -// "type": "string" -// }, -// "items": { -// "title": "items", -// "type": "array", -// "items": { -// "title": "Change Item", -// "type": "object", -// "properties": { -// "field": { -// "title": "field", -// "type": "string" -// }, -// "fieldId": { -// "title": "fieldId", -// "type": "string" -// }, -// "fieldtype": { -// "title": "fieldtype", -// "type": "string" -// }, -// "from": { -// "title": "from", -// "type": "string" -// }, -// "fromString": { -// "title": "fromString", -// "type": "string" -// }, -// "to": { -// "title": "to", -// "type": "string" -// }, -// "toString": { -// "title": "toString", -// "type": "string" -// } -// } -// } -// } -// } -// } -// }, -// "maxResults": { -// "title": "maxResults", -// "type": "integer" -// }, -// "startAt": { -// "title": "startAt", -// "type": "integer" -// }, -// "total": { -// "title": "total", -// "type": "integer" -// } -// } -// }, -// "editmeta": { -// "title": "Edit Meta", -// "type": "object", -// "properties": { -// "fields": { -// "title": "fields", -// "type": "object", -// "patternProperties": { -// ".+": { -// "title": "Field Meta", -// "type": "object", -// "properties": { -// "allowedValues": { -// "type": "array", -// "items": {} -// }, -// "autoCompleteUrl": { -// "type": "string" -// }, -// "defaultValue": {}, -// "hasDefaultValue": { -// "type": "boolean" -// }, -// "key": { -// "type": "string" -// }, -// "name": { -// "type": "string" -// }, -// "operations": { -// "type": "array", -// "items": { -// "type": "string" -// } -// }, -// "required": { -// "type": "boolean" -// }, -// "schema": { -// "$ref": "#/definitions/json-type" -// } -// } -// } -// } -// } -// } -// }, -// "expand": { -// "title": "expand", -// "type": "string" -// }, -// "fields": { -// "title": "fields", -// "type": "object", -// "patternProperties": { -// ".+": {} -// } -// }, -// "fieldsToInclude": { -// "title": "Included Fields", -// "type": "object" -// }, -// "id": { -// "title": "id", -// "type": "string" -// }, -// "key": { -// "title": "key", -// "type": "string" -// }, -// "names": { -// "title": "names", -// "type": "object", -// "patternProperties": { -// ".+": { -// "type": "string" -// } -// } -// }, -// "operations": { -// "title": "Opsbar", -// "type": "object", -// "properties": { -// "linkGroups": { -// "title": "linkGroups", -// "type": "array", -// "items": { -// "title": "Link Group", -// "type": "object", -// "properties": { -// "groups": { -// "type": "array", -// "items": { -// "$ref": "#/definitions/link-group" -// } -// }, -// "header": { -// "$ref": "#/definitions/simple-link" -// }, -// "id": { -// "type": "string" -// }, -// "links": { -// "type": "array", -// "items": { -// "$ref": "#/definitions/simple-link" -// } -// }, -// "styleClass": { -// "type": "string" -// }, -// "weight": { -// "type": "integer" -// } -// } -// } -// } -// } -// }, -// "properties": { -// "title": "Properties", -// "type": "object", -// "properties": { -// "properties": { -// "title": "properties", -// "type": "object", -// "patternProperties": { -// ".+": { -// "type": "string" -// } -// } -// } -// } -// }, -// "renderedFields": { -// "title": "renderedFields", -// "type": "object", -// "patternProperties": { -// ".+": {} -// } -// }, -// "schema": { -// "title": "schema", -// "type": "object", -// "patternProperties": { -// ".+": { -// "title": "Json Type", -// "type": "object", -// "properties": { -// "custom": { -// "type": "string" -// }, -// "customId": { -// "type": "integer" -// }, -// "items": { -// "type": "string" -// }, -// "system": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// } -// } -// } -// } -// }, -// "self": { -// "title": "self", -// "type": "string" -// }, -// "transitions": { -// "title": "transitions", -// "type": "array", -// "items": { -// "title": "Transition", -// "type": "object", -// "properties": { -// "expand": { -// "title": "expand", -// "type": "string" -// }, -// "fields": { -// "title": "fields", -// "type": "object", -// "patternProperties": { -// ".+": { -// "title": "Field Meta", -// "type": "object", -// "properties": { -// "allowedValues": { -// "type": "array", -// "items": {} -// }, -// "autoCompleteUrl": { -// "type": "string" -// }, -// "defaultValue": {}, -// "hasDefaultValue": { -// "type": "boolean" -// }, -// "key": { -// "type": "string" -// }, -// "name": { -// "type": "string" -// }, -// "operations": { -// "type": "array", -// "items": { -// "type": "string" -// } -// }, -// "required": { -// "type": "boolean" -// }, -// "schema": { -// "$ref": "#/definitions/json-type" -// } -// } -// } -// } -// }, -// "hasScreen": { -// "title": "hasScreen", -// "type": "boolean" -// }, -// "id": { -// "title": "id", -// "type": "string" -// }, -// "name": { -// "title": "name", -// "type": "string" -// }, -// "to": { -// "title": "Status", -// "type": "object", -// "properties": { -// "description": { -// "title": "description", -// "type": "string" -// }, -// "iconUrl": { -// "title": "iconUrl", -// "type": "string" -// }, -// "id": { -// "title": "id", -// "type": "string" -// }, -// "name": { -// "title": "name", -// "type": "string" -// }, -// "self": { -// "title": "self", -// "type": "string" -// }, -// "statusCategory": { -// "title": "Status Category", -// "type": "object", -// "properties": { -// "colorName": { -// "title": "colorName", -// "type": "string" -// }, -// "id": { -// "title": "id", -// "type": "integer" -// }, -// "key": { -// "title": "key", -// "type": "string" -// }, -// "name": { -// "title": "name", -// "type": "string" -// }, -// "self": { -// "title": "self", -// "type": "string" -// } -// } -// }, -// "statusColor": { -// "title": "statusColor", -// "type": "string" -// } -// } -// } -// } -// } -// }, -// "versionedRepresentations": { -// "title": "versionedRepresentations", -// "type": "object", -// "patternProperties": { -// ".+": { -// "type": "object", -// "patternProperties": { -// ".+": {} -// } -// } -// } -// } -// } -// } -// }, -// "maxResults": { -// "title": "maxResults", -// "type": "integer" -// }, -// "names": { -// "title": "names", -// "type": "object", -// "patternProperties": { -// ".+": { -// "type": "string" -// } -// } -// }, -// "schema": { -// "title": "schema", -// "type": "object", -// "patternProperties": { -// ".+": { -// "title": "Json Type", -// "type": "object", -// "properties": { -// "custom": { -// "type": "string" -// }, -// "customId": { -// "type": "integer" -// }, -// "items": { -// "type": "string" -// }, -// "system": { -// "type": "string" -// }, -// "type": { -// "type": "string" -// } -// } -// } -// } -// }, -// "startAt": { -// "title": "startAt", -// "type": "integer" -// }, -// "total": { -// "title": "total", -// "type": "integer" -// }, -I// "warningMessages": { -// "title": "warningMessages", -// "type": "array", -// "items": { -// "type": "string" -// } -// } -// } -// } -type SearchResults struct { - Expand string `json:"expand,omitempty" yaml:"expand,omitempty"` - Issues Issues `json:"issues,omitempty" yaml:"issues,omitempty"` - MaxResults int `json:"maxResults,omitempty" yaml:"maxResults,omitempty"` - Names map[string]string `json:"names,omitempty" yaml:"names,omitempty"` - Schema JSONTypeMap `json:"schema,omitempty" yaml:"schema,omitempty"` - StartAt int `json:"startAt,omitempty" yaml:"startAt,omitempty"` - Total int `json:"total,omitempty" yaml:"total,omitempty"` - WarningMessages WarningMessages `json:"warningMessages,omitempty" yaml:"warningMessages,omitempty"` -} diff --git a/jiradata/.#SearchResults.go b/jiradata/.#SearchResults.go deleted file mode 120000 index 0b3e5efa..00000000 --- a/jiradata/.#SearchResults.go +++ /dev/null @@ -1 +0,0 @@ -cbennett@lgml-cbennett.corp.netflix.com.24999 \ No newline at end of file