-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[JENKINS-40529] Prune tags on fetch #847
[JENKINS-40529] Prune tags on fetch #847
Conversation
I missed a class in the previous commit |
@MarkEWaite could you review these changes? |
Rebased against latest commit on master and update javadoc |
@nfalco79 it will be a while before I have time to review this pull request. There is a proposal to improve fetch performance significantly on large repositories that needs review before this one. @rsandell or @fcojfernandez might be able to review it before I can. |
I'm travelling this week, so I will auto-request a review to do it during the next week |
This behavior may be quite difficult to maintain across different versions of command line git. Command line git 2.20 and later intentionally changed their behavior in handling tags that are updated on remote repositories. See JENKINS-55284 for more details on the change. I realize that the use case here is intended to discard a tag that only exists in the workspace repository and not on the remote. The reviewer of this pull request will need to check the behavior in cases like:
Some of those cases may be irrelevant. Others are likely relevant and should be expressed in automated tests so that they will be evaluated on the different versions of CLI git that are used in git plugin automated testing. |
@MarkEWaite I know this command is valid only for git command line version >= 1.7.8. Should I check if the git command is a GitCliCommand implementation and get it's version. For JGit should not be an issue, I do not know any different behaviour. |
I will perform a manual test for git version >= 2.20.1 is requires a --force parameter on fetch or the prune parameters already acts like force |
If you know that it is valid for command line git versions 1.7.8 and newer, then there is no official need to check the version because the Jenkins git plugin officially supports git 1.7.10 and newer. I still run tests on CentOS 6 with its command line git version that is older than 1.7.10, but those tests are run only as a "best effort" to not break CentOS 6 git any worse than it is already broken. If I find surprises when I run this on CentOS 6, then I'll either add the version check or exclude the tests from running on CentOS 6. The command line git version on CentOS 6 is ancient and there are many alternatives for CentOS 6 users to install a more modern version of command line git. The command line git version on CentOS 7 (1.8.3) also has its share of issues, but is still officially supported by the git plugin. The day will come when that old CLI git version will no longer be supported, but not yet. |
I got the information on a stackoverflow response. Which way do you suggest? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test of command line git, not just JGit implementation. Otherwise, the git platform configurations won't help us detect problems.
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
src/main/java/jenkins/plugins/git/traits/PruneStaleTagTrait.java
Outdated
Show resolved
Hide resolved
src/main/java/jenkins/plugins/git/traits/PruneStaleTagTrait.java
Outdated
Show resolved
Hide resolved
src/test/java/hudson/plugins/git/extensions/impl/PruneStaleTagTest.java
Outdated
Show resolved
Hide resolved
src/test/java/hudson/plugins/git/extensions/impl/PruneStaleTagTest.java
Outdated
Show resolved
Hide resolved
I prefer the implementation you used. It is compatible with all the command line git versions supported by the git plugin (1.7.10 and newer). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for adding the broader tests and for testing with command line git!
I'm traveling currently and unable to spend the time in the IDE that will be needed to adequately review the latest changes. I'll rely on a review from @fcojfernandez or will review it after I return from traveling.
Thanks again for your effort on the pull request!
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
If you noted I had change the trait implementation because I did suppose that I miss to fix the constructor suggest because is not clear to me if you would have two contructors, one annotated DataBoundConstructor and other one that takes a boolean to skip any logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @nfalco79 ! Overall looks well, but I'd like to have more context/details, so I've added some questions in order to feel more confortable with my review
src/main/java/hudson/plugins/git/extensions/impl/PruneStaleTag.java
Outdated
Show resolved
Hide resolved
src/test/java/hudson/plugins/git/extensions/impl/PruneStaleTagTest.java
Outdated
Show resolved
Hide resolved
src/test/java/hudson/plugins/git/extensions/impl/PruneStaleTagTest.java
Outdated
Show resolved
Hide resolved
Comments fixed. |
rebase on master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. These days have been a bit craazy. The code looks good to me. @MarkEWaite , @nfalco79 has included the tests you requested. Do you want to review them in depth or are you fine with me merging this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to unblock the merge
@fcojfernandez since you reviewed the code in detail, I'd love to have you merge the code . |
Than I can proceed with a squash commit |
Add a new Trait to prune all tags that does not exists anymore on remotes
The CI has failed after the last commit. Closing and re-opening to relaunch it (the failure seems to be infra related) |
@nfalco79 thanks for the pull request and @fcojfernandez thanks for merging it. I was performing some interactive testing today to prepare for a beta release of git plugin 4.3.0 As part of that, I discovered JENKINS-61869. I think that will need to be fixed before we allow this feature to reach users. I'll report additional bugs as I learn more from my interactive testing. If you'd like a Docker image definition that includes a Freestyle job that I was using for experiments, refer to the lts-with-plugin branch of my docker-lfs repository. |
I've also submitted JENKINS-61871 to describe the cases I'm seeing where stale tags are not pruned by fetch into the workspace. |
it's the same bug. The suggested property in code review to enable/disable the extensions must be true by default. That option causes all these issues. |
That's good to hear. Will you submit a pull request to resolve it? Will the change then alter the default behavior by enabling tag pruning by default? I hope not, since that is not the way the git plugin handles compatibility in general. We try to retain behavioral compatibility so that users are not surprised by changes in default behavior. |
Already done #867 |
JENKINS-40529 - Trait to prune stale tags on fetch
I our infrastructure we use pipeline to perform releases. Releases are performed in Maven, Lerna (NodeJS) and fastlane (IOS). All tools requires that release tag does not in the current git repo. When a releases fails for some reason we fix and re-run the process that will fail again because the tag exists locally. This force the DevOps teams manually remove tags from workspaces in Jenkins slaves. The trait in this PR always prune tags that do not exists on remote.
Checklist
Types of changes