Skip to content

Commit

Permalink
gitlab: Return error when trying to close a closed issue
Browse files Browse the repository at this point in the history
This is the behavior for merge requests, do the same for issues for
consistency (and because it makes sense).
  • Loading branch information
fmuellner committed Dec 19, 2020
1 parent b569d45 commit 894625e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,14 @@ func IssueList(project string, opts gitlab.ListProjectIssuesOptions, n int) ([]*

// IssueClose closes an issue on a GitLab project
func IssueClose(pid interface{}, id int) error {
_, _, err := lab.Issues.UpdateIssue(pid, id, &gitlab.UpdateIssueOptions{
issue, _, err := lab.Issues.GetIssue(pid, id)
if err != nil {
return err
}
if issue.State == "closed" {
return fmt.Errorf("issue already closed")
}
_, _, err = lab.Issues.UpdateIssue(pid, id, &gitlab.UpdateIssueOptions{
StateEvent: gitlab.String("close"),
})
if err != nil {
Expand Down

0 comments on commit 894625e

Please sign in to comment.