Skip to content

Commit

Permalink
fix closing duplicate issue on dup command
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Aug 14, 2017
1 parent 36632a5 commit fc696c3
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 793 deletions.
4 changes: 4 additions & 0 deletions cmd/jira/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
9 changes: 8 additions & 1 deletion jiracli/block.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package jiracli

import (
"fmt"

"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
Expand Down Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions jiracli/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 27 additions & 2 deletions jiracli/dup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package jiracli

import (
"fmt"

"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions jiracli/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions jiracli/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions jiracli/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading

0 comments on commit fc696c3

Please sign in to comment.