build: correctly handle merge commits when calculating a build tag #226
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merge commits were incorrectly handled due to the named use of
git rev-list
, which does not give an ancestry path as I expected, but simply a list of unique commits between the two refs.Additionally, the check for the base tag was wrong in the face of merge commits, since a tag could be an ancestor through a merge commit, but not be the actual base of the branch.
Both of these issues resulted in an incorrect tag being calculated, as well as a build slowdown due to the iteration over all of the commits from the other parent of the merge commit, which is unneeded. After the changes in this PR, running the script on the branch mentioned in the linked issue (#225) results in the following output:
The reason for the mismatch is that the
2.1.0
tag was imported through a merge rather than being a direct base, so in order to include all of the changes in the branch,2.0.0
had to be considered the base.While at it, add logic for caching the build tag in order to speed up builds when the checked-out git tree hasn't changed.