-
Notifications
You must be signed in to change notification settings - Fork 720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of #
in commit body causes closes
false positive
#415
Comments
I also observed the same: semantic-release/semantic-release#1129 |
@myii are you only using angular preset or do you supply your own https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#referenceactions? |
@myii and @joelmukuthu do y'all have a small example project, and release explanation, that we can use to reproduce this issue? It was really help us to better investigate this issue. |
i was able to find the following in a few minutes:
in each case the referenced issues were of the form i'm sure i could track down several others if it would be helpful. happy to provide additional info that would be helpful if there are more details needed. |
Hi, it looks to me that this issue is reproduced also on my repository. 🤔 The commit is ybiquitous/ybiq@0716e88. The following is the build log on Travis CI. Additional information:
I would be happy if my example could help the research. 😃 |
I'm using conventionalcommits and seeing this happening as well; is there some specific information that would help root cause this bug? I see that conventional commits has an option called I assume changing it to something like 'Fixes #' or 'FIXES: #' etc would solve the problem. Or maybe the issue is that the option isn't exposed in all presets or tools? |
Adding 'Fixes #' did not work so I assume there's some filtering or processing. I noticed there's a concept of reference actions which matches common prefexes like fixes and closes so it could be they get parsed first and thus don't match prefix. For log.txt:
I run with the default '#' prefix first:
Here we see that two references were created but only one has an action. Perhaps one solution to this issue is to only use action based references. I also ran with a prefix like 'Closes #' and got nothing:
I tried various regexes as per: #271 but nothing came up. |
One thing to note there is that the body has been merged into the footer after parsing and there may be logic which extracts all references from footers. (though See XXX is not uncommon in footer either) edit: it seems the presence of a reference in the body marks it as a part of the footer by definition. |
Update:I stepped through a bit and found the proximate cause of this problem. The code currently searches for references on every line of the commit message; usually the reference regex requires having an action before the issue number but in order to catch references everywhere, the code falls back to matching everything if there would otherwise be no matches:
When there is an reference action, as I surmised the regex splits them into an action keyword and the rest meaning you can't customize an Also as expected, there's logic which assumes we must be in the footer, not body, if there is ever a reference found which doesn't make sense given references are intentionally allowed everywhere. ( conventional-changelog/packages/conventional-commits-parser/lib/parser.js Lines 229 to 233 in 318b555
This was originally done because Github started adding PR references to the header and people wanted those extracted. Interestingly, the reference in the header does not get added a closed issue in the changelog which implies there's some special casing for it later since it shows up as a normal reference in the parser output! I think extracting references from anywhere makes sense from the parser's point of view so I'd guess the overall fix should exist at write time. Suggestions
Workaround
|
Small update: I see the logic to exclude header references from 'closes' section is specific to conventionalcommits preset: conventional-changelog/packages/conventional-changelog-conventionalcommits/writer-opts.js Line 146 in 318b555
This seems like something that should probably be core especially if we want to generalize the notion of actionable vs non-actionable reference. Though short term, updating that code to remove non actionable references would probably be pretty straightforward... |
Hi all |
#415 (comment) has a work around if you want to try it out! |
Thanks @melink14 |
These are options to the parser so you can pass them to the commit analyzer and release notes generator to override the behavior. See https://github.com/semantic-release/release-notes-generator#options for examples. The workaround listed above should definite prevent false positive closes but it might also prevent detecting intentional actions though I haven't looked closely at it in a long time. It would probably not be hard to fix but I've not heard from the maintainers if they have opinions on if my suggestions make sense to them. |
Notes:
semantic-release
.Current behavior
Had this happen a few times now but manually fixed previously. If a hash
#
appears in the commit body, it is seen as acloses
in the release notes and changelog. An existing example follows.Commit saltstack-formulas/template-formula@3a072c7:
Resulted in both:
Specifically:
Expected behavior
The
closes
shouldn't have been present:Environment
release.config.js
Release
stageFurther example that was manually fixed
The text was updated successfully, but these errors were encountered: