github: close issue via comments on commit (not commit message)

I know, I can close an issue automatically when committing to github via the commit message. And it nicely gives two links (from commit to issue and vise versa). However, a collaborator forgot to include it (fix: #3).

Now, I see github has a comments on commit field, like e.g. here:

Can this field be used? I tried fix: #3. This at least referenced in the issue, but does not close the issue automatically. Or is there another way?

Changing the commit message or even undoing the whole commit appears cumbersome.

Upvotes: 1

Views: 134

Answers (1)

bk2204
bk2204

Reputation: 76409

I don't believe you can use commit comments to close an issue. Generally, issues are closed when a pull request that's been marked as fixing an issue, either with a commit message directive or a directive in the pull request description, ends up getting merged into the main branch.

What you're proposing is that a comment on a commit that's already merged be allowed to close the issue. That wouldn't be very efficient, because it would require checking every commit which had one of those comments to see if it was already merged (which is expensive), and it could cause problems since random users could close issues silently without getting a review from project leads.

Upvotes: 2

Related Questions