Skip to content

Commit f83a19e

Browse files
authored
Merge pull request #144 from bonzofenix/fix-commitish-422-error
Fix 422 error when updating release without commitish parameter
2 parents 4e470f2 + 51fa479 commit f83a19e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

out_command.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
4848
}
4949
}
5050

51-
targetCommitish := ""
51+
var targetCommitish string
5252
if request.Params.CommitishPath != "" {
5353
targetCommitish, err = c.fileContents(filepath.Join(sourceDir, request.Params.CommitishPath))
5454
if err != nil {
@@ -94,10 +94,13 @@ func (c *OutCommand) Run(sourceDir string, request OutRequest) (OutResponse, err
9494
}
9595

9696
existingRelease.Name = github.String(name)
97-
existingRelease.TargetCommitish = github.String(targetCommitish)
9897
existingRelease.Draft = github.Bool(draft)
9998
existingRelease.Prerelease = github.Bool(prerelease)
10099

100+
if targetCommitish != "" {
101+
existingRelease.TargetCommitish = github.String(targetCommitish)
102+
}
103+
101104
if bodySpecified {
102105
existingRelease.Body = github.String(body)
103106
} else {

out_command_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ var _ = Describe("Out Command", func() {
194194
updatedRelease := githubClient.UpdateReleaseArgsForCall(0)
195195
Ω(*updatedRelease.Name).Should(Equal("v0.3.12"))
196196
Ω(*updatedRelease.Body).Should(Equal("this is a great release"))
197-
Ω(updatedRelease.TargetCommitish).Should(Equal(github.String("")))
197+
Ω(updatedRelease.TargetCommitish).Should(BeNil(), "does not set the TargetCommitish")
198198
})
199199
})
200200

0 commit comments

Comments
 (0)