[Draft] Present HEAD commit from source branch instead of merged commit in PreBuildMerge plugin #1210
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.
JENKINS-52926 - Present HEAD commit from source branch instead of merged commit in PreBuildMerge plugin
Linked issue is not completely resolved by this PR. This PR relates to my comment in linked ticket and should resolve a problem of displaying sha of merge commits, which makes hard to determine cloned code revision without looking into logs.
This is a draft PR, I'll add documentation, docstrings and clean code a bit if solution is approved. I'll be grateful for any feedback - what else should be added, alternative implementations, etc.
This PR introduces new option to PreBuildMerge extension, which allows to choose revision included on Git Build Data summary page. By default, the merged revision is displayed to keep backward compatibility. The other option is to display head of a source branch. In some cases this is more useful information, for example when we want to know which revision from PR branch was build, instead of getting the randomly generated commit, which does not exist on remote.
I didn't want to break any existing behavior, so I decided to not change revision returned by
decorateRevisionToBuild
method.Unfortunately, this PR do not fix original problem from linked PR - there are still a few build entries. I can open a new ticket if it is required to merge this PR.
Checklist
Types of changes
Further comments
Other possible solutions:
adding a method to
hudson.plugins.git.Revision
class fromgit-client
, which returns a string with display version of revision. This method by default returnsgetSha1String()
. Then, creating a new class ingit-plugin
, which extendsRevision
class and overrides new method.Pros:
- Probably the cleanest solution from
git-plugin
point of view.- Changes are required only in
PreBuildMerge
implementation and jelly files.- Backward compatible
Cons:
- New method in Revision, which is useless from
git-client
point of view- Chanes required in 2 repos
returning
marked
revision fromdecorateRevisionToBuild
method if user setdisplayRevision = source_branch
.Pros:
- Only a few lines of code needed
- Backward compatible because default behavior remains the same
- Probably fixes problem with duplicated Git Build Data
Cons:
- In case of
displayRevision = source_branch
not only display value is changed, so there might be some unexpected behaviour