-
Notifications
You must be signed in to change notification settings - Fork 149
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
Added repository configuration to only push tags to remote repositories #81
Added repository configuration to only push tags to remote repositories #81
Conversation
@@ -83,12 +87,16 @@ class GitRepository implements ScmRepository { | |||
} | |||
|
|||
private void callPush(String remoteName, boolean all) { | |||
repository.push(remote: remoteName, all: all) | |||
if(pushTagsOnly == false) { |
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.
!pushTagsOnly
?
It would be probably good to have a simple test case for the new feature. |
@szpak I agree. I am working on a test. |
Waiting for the test before merge :) Could you also update the documentation? At least the overview section (in |
@adamdubiel Sure thing. I just wanted to be sure this approach was acceptable before changing docs. |
Adam, as David mentioned instead of introducing a new option we can just skip pushing if no 'releaseCommit' option specified. |
private static final String ATTACH_REMOTE_PROPERTY = 'release.attachRemote' | ||
|
||
private static final String FETCH_TAGS_PROPERTY = 'release.fetchTags' | ||
|
||
ScmInitializationOptions(String remote, boolean fetchTags, boolean attachRemote, String remoteUrl) { | ||
ScmInitializationOptions(String remote, boolean fetchTags, boolean attachRemote, String remoteUrl, boolean pushTagsOnly) { |
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.
i wonder - this option might be set from cmd line as well (via -Prelease.pusthTagsOnly
), so there would be no need to leak CI settings into buildscript
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.
I agree. I wasn't sure exactly where to pipe it in, I just needed to demonstrate the functionality. I was hoping you would have the better vision for how to apply it.
@vbuell - right, but then i think having manual override via cmdline for CI could be useful. The |
@erichsend wrapping it all up:
|
def "should not push commits if the pushTagsOnly flag is set to true"() { | ||
given: | ||
initializationOptions = ScmInitializationOptions.fromProject(project, 'origin', true) | ||
repository = new GitRepository(project.file('./repo'), identity, initializationOptions) |
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.
hm, this creates nested repository, i would be careful with that - maybe just create new Project object? (this is a bit of hack for creating temp file, but it also makes the domain look nicer :P)
… own projects and repositories
@adamdubiel I currently have it set to behave like the dryRun flag:
|
…pushTagsOnly configuration and flag
@adamdubiel |
@erichsend - sorry for delay, i been on short vacation, i will take a look at this today or tomorrow |
@@ -14,14 +14,19 @@ class ScmRepositoryFactory { | |||
|
|||
private static final String GIT = 'git' | |||
|
|||
private static final String REPOSITORY_PUSH_TAGS_ONLY_FLAG = "repository.pushTagsOnly"; |
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.
could you change the name to release.pushTagsOnly
? Name clash is very unlikely for such a long flag, but i would like to keep everything in release
namespace
There is just one "big" remark about naming. Other than that, i feel that there is room for improvement, but it's not critical and would involve bigger refactor. I will take care of it after merge. Please change the variable name and we are set. |
…release.pushTagsOnly
I agree this change is more of a work around than a good long term solution. Your suggestion of removing the flag as a property of the repository and instead adding it as an argument to the push() method certainly seems desirable. If I can find the time in the next week or two I could attempt that assuming you do not get to it first. Another thing I would bring up is whether pushTagsOnly should be the default behavior. Maybe it is because my team has a policy to only do releases from the CI system, but I was actually surprised that the plugin was attempting to push local commits, as it seems like any commit important enough to be a release should first be published and vetted (by the CI system and peer review) before the release tag is applied. As I said though, my experience would be quite different from someone who primarily did all of their release maintenance from their laptop. |
Regarding the naming, should the configuration item (not the flag) remain as a property in RepositoryConfig? I'm just working on the docs now and still have this example:
|
Naming: yest, this should be part of As to the default behavior: we also release only from CI, but mind, that when using pre-release hooks there might be some local commits that i.e. change version number in Readme or some docs, that should be pushed as well. I would rather keep the new option optional instead of default not to break it :) |
Added repository configuration to only push tags to remote repositories
Merged, thanks for this contribution :) |
Thanks for pulling this in, Adam, and thanks for the great plugin. |
This relates to #66
In a detached head state that can occur on some CI systems, the release task will fail when it attempts to push local commits to the remote repository. My attempt to fix was to add an optional configuration parameter to signal that only local tags, and not local commits, should be pushed to the remote repository.
Output of my jenkins job showing a successful push from a detached head state:
https://gist.github.com/erichsend/4b9327c58dec98e22ae2