Skip to content

Commit

Permalink
✨ Make issue transition by Name rather than ID, so custom workflows n…
Browse files Browse the repository at this point in the history
…eed not be configured

Issue: none

Test plan:

Signed-off-by: Steve Coffman <[email protected]>
  • Loading branch information
StevenACoffman committed Aug 28, 2021
1 parent 106852a commit 6d9689a
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 379 deletions.
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,39 @@

`jt` is a CLI tool for viewing and manipulating JIRA issues.

An example usage to transition an issue to a new status:
```
jt "In Progress" TEAM-1234
```

If you are in a git repository on a topic branch who's name matches `team-1234[-whatever]`, you can omit
the issue argument as it is implied.

### Usage:
jt [command]
jt [new state] [issue number]

**Note:**

We case insensitively look for valid transition states in your issue's workflow. If you give `tRiAgE`
we will find `Triage`, if that is a valid transition for your issue's current status.

### Available Commands:
If no valid transition state matches *exactly*, we then try matching against
possible states that have had their whitespace removed. If you give "todo" we will find possible state `To Do`.

If still no valid transition state is matched, we will then try partial match, so that
"done" will match possible state `Deployed / Done`.

This will otherwise only transition an issue to a matching valid state according to your
JIRA board's workflow.

### Other Available Commands:
| command | what it does |
|---|---|
| block | Transition an issue to Blocked status |
| completion | generate the autocompletion script for the specified shell |
| done | Transition an issue to Deployed / Done status |
| help | Help about any command |
| land | Transition an issue to Landed status |
| onit | Self-assign and transition an issue to In Progress status |
| review | Transition an issue to Review status |
| take | Assign an issue to you |
| todo | Transition an issue to To Do status |
| triage | Transition an issue to Triage status |
| wti | What The Issue? - View an issue |
| wti | What The Issue? - View an issue in Github Markdown |

Shared Flags:
| flag | what it does |
Expand All @@ -41,7 +57,9 @@ Go developers with `$HOME/bin` in their `$PATH` can run `mage` if they have [mag
Alternatively, `go run mage.go` will work even without `mage` installed, but it will still put the binary in `$HOME/bin`.

### Development and Limitations
Currently, the config does not allow overriding the workflow states.

Also, if a user doesn't have a config file, it should help them create one.

### Alternatives

There is another [jira cli](https://github.com/go-jira/jira) that is quite sophisticated, featureful,
and maybe complicated, but I found custom workflow transitions either didn't work, or were cumbersome.
49 changes: 0 additions & 49 deletions cmd/block.go

This file was deleted.

53 changes: 0 additions & 53 deletions cmd/done.go

This file was deleted.

49 changes: 0 additions & 49 deletions cmd/land.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/onit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var onitCmd = &cobra.Command{
os.Exit(exitFail)
}

err := atlassian.MoveIssueToStatus(jiraClient, issue, issueKey, atlassian.InProgressStatusID)
err := atlassian.MoveIssueToStatusByName(jiraClient, issue, issueKey, "In Progress")
if err != nil {
fmt.Println(err)
os.Exit(exitFail)
Expand Down
49 changes: 0 additions & 49 deletions cmd/review.go

This file was deleted.

33 changes: 26 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,34 @@ var rootCmd = &cobra.Command{
Use: "jt",
Short: "jt - JIRA Issue Tool",
Long: `jt is a CLI tool for viewing and manipulating JIRA issues.`,
Args: cobra.RangeArgs(1, 2),
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) {
// fmt.Println("hi")
// },
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
fmt.Println("You need to pass a desired jira status argument (and maybe a jira issue like TEAM-1234)")
os.Exit(exitFail)
}
var issueKey string
statusName := args[0]
if len(args) > 1 {
issueKey = args[1]
} else {

}
issue, _, issueErr := jiraClient.Issue.Get(issueKey, nil)
if issueErr != nil {
fmt.Printf("Unable to get Issue %s: %+v", issueKey, issueErr)
os.Exit(exitFail)
}

err := atlassian.MoveIssueToStatusByName(jiraClient, issue, issueKey, statusName)
if err != nil {
fmt.Println(err)
os.Exit(exitFail)
}
os.Exit(exitSuccess)
},
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand All @@ -51,10 +74,6 @@ func init() {
// will be global for your application.

rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.config/jira)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}


Expand Down
49 changes: 0 additions & 49 deletions cmd/todo.go

This file was deleted.

Loading

0 comments on commit 6d9689a

Please sign in to comment.