From f988235f74213413bb15ccccbf4dde630ecbbc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 21 Jan 2020 12:48:56 +0100 Subject: [PATCH] Allow updating issue state --- commands/issue.go | 9 +++++++-- features/issue.feature | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/commands/issue.go b/commands/issue.go index b6f46882..29d5aa4c 100644 --- a/commands/issue.go +++ b/commands/issue.go @@ -20,7 +20,7 @@ var ( issue [-a ] [-c ] [-@ ] [-s ] [-f ] [-M ] [-l ] [-d ] [-o [-^]] [-L ] issue show [-f ] issue create [-oc] [-m |-F ] [--edit] [-a ] [-M ] [-l ] -issue update [-m |-F ] [--edit] [-a ] [-M ] [-l ] +issue update [-m |-F ] [--edit] [-a ] [-M ] [-l ] [-s ] issue labels [--color] issue transfer `, @@ -243,6 +243,7 @@ hub-pr(1), hub(1) -l, --labels LIST -a, --assign USER -e, --edit + -s, --state STATE `, } ) @@ -635,7 +636,7 @@ func updateIssue(cmd *Command, args *Args) { if issueNumber == 0 { utils.Check(cmd.UsageError("")) } - if !hasField(args, "--message", "--file", "--labels", "--milestone", "--assign", "--edit") { + if !hasField(args, "--message", "--file", "--labels", "--milestone", "--assign", "--state", "--edit") { utils.Check(cmd.UsageError("please specify fields to update")) } @@ -652,6 +653,10 @@ func updateIssue(cmd *Command, args *Args) { setAssigneesFromArgs(params, args) setMilestoneFromArgs(params, args, gh, project) + if args.Flag.HasReceived("--state") { + params["state"] = args.Flag.Value("--state") + } + if hasField(args, "--message", "--file", "--edit") { messageBuilder := &github.MessageBuilder{ Filename: "ISSUE_EDITMSG", diff --git a/features/issue.feature b/features/issue.feature index 65c12c52..2759ee48 100644 --- a/features/issue.feature +++ b/features/issue.feature @@ -593,7 +593,6 @@ Feature: hub issue https://github.com/github/hub/issues/1337\n """ - Scenario: Update an issue's title Given the GitHub API server: """ @@ -602,10 +601,22 @@ Feature: hub issue :body => "", :milestone => :no, :assignees => :no, - :labels => :no + :labels => :no, + :state => :no } """ Then I successfully run `hub issue update 1337 -m "Not workie, pls fix"` + + Scenario: Update an issue's state + Given the GitHub API server: + """ + patch('/repos/github/hub/issues/1337') { + assert :title => :no, + :labels => :no, + :state => "closed" + } + """ + Then I successfully run `hub issue update 1337 -s closed` Scenario: Update an issue's labels Given the GitHub API server: