Skip to content

build: exclude redundant cherry-picked commits when generating changelog #17050

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

Merged
merged 1 commit into from
Feb 26, 2020

Conversation

clydin
Copy link
Member

@clydin clydin commented Feb 21, 2020

If generating a changelog between tags that are on different branches (e.g., 9.0.3 on 9.0.x and 9.1.0-next.0 on master), commits that were cherry-picked and present in the previous version would also show in the newer version's changelog. This update analyzes the commits and excludes any that fit this scenario. Any commits that had conflicts will not be able to be matched authoritatively. Manual review of the generated changelog may still be needed for attempted cherry-pick commits that had conflicts.

If generating a changelog between tags that are on different branches (e.g., 9.0.3 on 9.0.x and 9.1.0-next.0 on master), commits that were cherry-picked and present in the previous version would also show in the newer version's changelog.  This update analyzes the commits and excludes any that fit this scenario.  Any commits that had conflicts will not be able to be matched authoritatively.  Manual review of the generated changelog may still be needed for attempted cherry-pick commits that had conflicts.
@clydin clydin added the target: major This PR is targeted for the next major release label Feb 21, 2020
@clydin clydin requested a review from alan-agius4 February 25, 2020 14:28
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Feb 26, 2020
@dgp1130
Copy link
Collaborator

dgp1130 commented Feb 26, 2020

Typically when I cherry-pick commits I include the -x flag, which leaves a reference in the commit to the original hash. Would it be possible to use this to identify cherry picks which were modified due to merge conflicts?

Assuming caretakers always add -x (which we could probably enforce somehow on release branches) and always cherry pick from master (which itself should include the "original" commit, not another cherry-pick), then reading that value would always get the authoritative commit hash. That hash should be stable, even if a merge conflict was fixed.

Could we compare these "authoritative" hashes to identify the new commits and generate a changelog from that set?

@clydin
Copy link
Member Author

clydin commented Feb 26, 2020

The -x option only applies to cherry-picks without conflicts. There's also no guarantee that the option will always be used so the patch-id method that compares the diffs of the commit would still need to be used. This is also more authoritative since the commit message could erroneously contain the inserted text and point to an arbitrary commit.
The -x option should definitely be used when possible though since it provides an easy way for a user to relate the commits when reading through the history.

@dgp1130
Copy link
Collaborator

dgp1130 commented Feb 26, 2020

The -x option only applies to cherry-picks without conflicts.

Not true, I just had this happen while merging #17040. I did a git cherry-pick -x and hit a merge conflict. After fixing it, I ran git cherry-pick --confinue which generated a commit message including the cherry pick line: 35ad92c.

I would imagine there's a way to put a restriction on release branches that they must contain the -x info. If we did require this, could it be a more stable way of identifying commits? That way we don't need to manually check for merge conflicted commits (which I can't imagine anyone would take the time to do).

@clydin
Copy link
Member Author

clydin commented Feb 26, 2020

The documentation for the option says it doesn't (https://git-scm.com/docs/git-cherry-pick) so I'm not sure we should rely on the behavior. But we could augment the check to also try to find the text and analyze the referenced commit if no initial match is found.

This doesn't cover the case where separate PRs are created due to the conflicts though. From my manual review of 9.1.0-next.0, this was the more common case.

@dgp1130
Copy link
Collaborator

dgp1130 commented Feb 26, 2020

Interesting that -x does work with merge conflicts even though it is explicitly documented not to. Agreed that we probably shouldn't rely on this seemingly incorrect behavior. Also agreed that this doesn't address separate PRs to the release branch, so we'd still need to do the patch id trick there. Just wanted to see if utilizing -x could be better, but seems like it really wouldn't.

@dgp1130 dgp1130 merged commit 9a6b05d into angular:master Feb 26, 2020
@clydin
Copy link
Member Author

clydin commented Feb 26, 2020

Yes. I agree, I was hoping it would be more useful especially since I noticed you started using it when cherry-picking.
I'll do some further experiments with trying to further reduce the extra commits. While this PR isn't a perfect solution, it is a pretty good one (90+% of the commits were removed).

@clydin clydin deleted the changelog-cherry-pick branch February 26, 2020 21:23
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants