Skip to content

git-client: add support for --force option to submodule update#200

Closed
jacob-keller wants to merge 1 commit intojenkinsci:masterfrom
jacob-keller:jk-submodule-add-force-option
Closed

git-client: add support for --force option to submodule update#200
jacob-keller wants to merge 1 commit intojenkinsci:masterfrom
jacob-keller:jk-submodule-add-force-option

Conversation

@jacob-keller
Copy link
Contributor

The purpose of this is to extend the CLI wrapper to allow --force option which enables recovery from some specific failures when the network has intermittent issues. Particularly, if the submodule update command happens to fail due to network issue, a re-run of the command will not re-checkout the files, as the way git CLI implemenation works it will see that the submodule is already at the desired commit. The Git mailing list said the best way to handle this is to use --force, but I don't think it should be default behavior considering that behavior change which can result.

Signed-off-by: Jacob Keller jacob.keller@gmail.com

@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@jacob-keller jacob-keller force-pushed the jk-submodule-add-force-option branch from b9bdafd to 1ff4f75 Compare February 18, 2016 22:30
@jacob-keller
Copy link
Contributor Author

I submitted a new version that has a test case which covers the behavior I need and the expected behavior of --force. it will force a re-checkout even if you already have it checked out. Thus, it will recheckout any files which we deleted.

@jacob-keller
Copy link
Contributor Author

One alternative to this approach is to add "--force" by default, as this is what we already do inside the git plugin for regular checkouts. It seems weird that we wouldn't also add it for submodules as well.

I haven't yet tried this change, and I think it's riskier because it is more invasive than the addition of an option. That being said, if we already know that we want it generally why not also for submodules? Options are only good if they are infact useful being both on and off.. If everyone ends up having to check "yes" why should it be optional in the first place.

Thoughts?

@jacob-keller
Copy link
Contributor Author

Note it may be possible for the same effect to be had by using the clean option, which also (not entirely documented?) performs a git-reset as well.

@jacob-keller
Copy link
Contributor Author

I am testing, but I think the clean option may actually already do what Ineed so this pull request ist not necessary. I will report back with my results from the clean plugin and see if it is workable instead.

Also add a test case for --force option

Since the supported versions of git do not all support "-C" syntax,
extend our cmd(), and launchCommand() syntax with a launchCommandIn()
syntax, which we will make use of. This compiled with w.file() allows us
to launch a command within a sub directory.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
@jacob-keller jacob-keller force-pushed the jk-submodule-add-force-option branch from 1ff4f75 to ff96fa9 Compare April 28, 2016 23:14
@jacob-keller
Copy link
Contributor Author

I updated this pull request to include launchCommandIn support, and updated it to use cmdIn() instead, which will help ensure compatibility across platforms of Git.

I do believe this functionality is still important, as the clean() extension does not appear to fully fix the issue that --force can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants