Skip to content

Commit

Permalink
Gong comment is implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
KensoDev committed Jun 3, 2017
1 parent a8b09e5 commit add0f35
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ While working on a branch that matches the gong regular expression (look
above), you can type `gong browse` and it will open up a browser opened on the
issue automatically.

## Upcoming features

### gong comment
### `gong comment`

While working on a branch that matches the gong regular expression, you can
type `gong comment "some comment"` and it will send a comment on the ticket.

This is a perfect way to streamline communication

## Upcoming features

### gong slack

Send a message to a slack channel, tagging the issue you are working on
Expand Down
42 changes: 42 additions & 0 deletions cmd/gong/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,48 @@ func main() {
return nil
},
},

{
Name: "comment",
Usage: "Comment on the issue you are working on, accepts an argument or STDIN",
Action: func(c *cli.Context) error {
comment := c.Args()[0]

cmd := "git"
args := []string{"rev-parse", "--abbrev-ref", "HEAD"}

out, err := exec.Command(cmd, args...).Output()

if err != nil {
return err
}

branchName := string(out)

issueID, err := gong.GetIssueID(branchName)

if err != nil {
return err
}

jiraClient, err := gong.GetAuthenticatedClient()
if err != nil {
fmt.Println(err)
return err
}

err = gong.AddComment(jiraClient, issueID, comment)

if err != nil {
fmt.Println(err)
return err
}

fmt.Println("Comment added to the jira ticket")

return nil
},
},
}
app.Run(os.Args)
}
9 changes: 9 additions & 0 deletions issue_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ func GetIssueID(branchName string) (string, error) {
return matches[0], nil
}

func AddComment(jiraClient *jira.Client, issueID string, commentBody string) error {
comment := &jira.Comment{
Body: commentBody,
}
_, _, err := jiraClient.Issue.AddComment(issueID, comment)

return err
}

func GetBranchName(jiraClient *jira.Client, issueId string, issueType string) string {
issue, _, _ := jiraClient.Issue.Get(issueId, nil)

Expand Down

0 comments on commit add0f35

Please sign in to comment.