Skip to content
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

git.py: Allow setting of submodule push branch #228

Merged
merged 2 commits into from
Feb 14, 2018
Merged

git.py: Allow setting of submodule push branch #228

merged 2 commits into from
Feb 14, 2018

Conversation

rleigh-codelibre
Copy link
Contributor

@rleigh-codelibre rleigh-codelibre commented Feb 13, 2018

--push is used to set the branch in .gitmodules.

@rleigh-codelibre
Copy link
Contributor Author

Copy link
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The synchronization of submodule.<name>.branch with the --push-branch API makes sense in the context of the new feature introduced in #225.
One question about the default contract when modifying .gitmodules. As for the previous improvements to support tracking branches, we could also capture the expected behavior via integration tests.

scc/git.py Outdated
@@ -1007,7 +1007,8 @@ def find_candidate_branches(self, filters,

class GitRepository(object):

def __init__(self, gh, path, remote="origin", repository_config=None):
def __init__(self, gh, path, remote="origin", push_branch="origin",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case where --push-branch is not passed to the original command, am I correct that with the current implementation scc merge <xxx> --update-gitmodules would unconditionally write branch = origin in the .gitmodules?

My expectation would be that in that case, we might not want to modify this key i.e. set the default here to None and conditionally skip the setting of submodule.<name>.branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the additional commit.

@rleigh-codelibre
Copy link
Contributor Author

@sbesson
Copy link
Member

sbesson commented Feb 14, 2018

Functionally tested using the sandbox repository. Without --push arguments

(venv) sbesson@ls30630:snoopys-sandbox ((aed9f2f...)) $ python /opt/ome/snoopycrimecop/scc/main.py merge dev_4_4  --update-gitmodules 
2018-02-14 13:56:42,538 [   scc.merge] INFO  Merging Pull Request(s) based on dev_4_4
...
2018-02-14 13:56:55,976 [   scc.merge] INFO  
(venv) sbesson@ls30630:snoopys-sandbox ((3ea130c...)) $ git diff HEAD^
diff --git a/snoopys-sandbox-2 b/snoopys-sandbox-2
index 33abb18..1b59ef2 160000
--- a/snoopys-sandbox-2
+++ b/snoopys-sandbox-2
@@ -1 +1 @@
-Subproject commit 33abb18f09519d2174a86e1933a6d62dc959f2f9
+Subproject commit 1b59ef2408a95c22030614b3be75a50e658f6cd0

With --push arguments

(venv) sbesson@ls30630:snoopys-sandbox ((aed9f2f...)) $ python /opt/ome/snoopycrimecop/scc/main.py merge dev_4_4  --update-gitmodules --push test
2018-02-14 13:57:35,872 [   scc.merge] INFO  Merging Pull Request(s) based on dev_4_4
...
2018-02-14 13:57:56,995 [   scc.merge] INFO  Merged branch pushed to https://github.com/sbesson/snoopys-sandbox/tree/test
(venv) sbesson@ls30630:snoopys-sandbox ((2ca119a...)) $ git diff HEAD^
diff --git a/.gitmodules b/.gitmodules
index b0dae12..9a6e374 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,4 @@
 [submodule "snoopys-sandbox-2"]
        path = snoopys-sandbox-2
        url = git://github.com/openmicroscopy/snoopys-sandbox-2
+       branch = test
diff --git a/snoopys-sandbox-2 b/snoopys-sandbox-2
index 33abb18..53b6588 160000
--- a/snoopys-sandbox-2
+++ b/snoopys-sandbox-2
@@ -1 +1 @@
-Subproject commit 33abb18f09519d2174a86e1933a6d62dc959f2f9
+Subproject commit 53b65889596635873a10ef0060a4739cce6860af

Using my local scc version (0.8.0), both commands result in the first behavior. This seems to match the expectation from the description of this PR.

As a side note, I realized that the submodule URL are not updated for this sandbox repository. This is likely related to pattern of the URL which does not match the expectation from the library (not ending in .git). THis is independent of this PR but probably worth fixing if we start writing integration tests assessing the content of .gitmodules.

@joshmoore
Copy link
Member

Reading that as good to go for 0.9.2. Merging & releasing.

@joshmoore joshmoore merged commit 476601f into ome:master Feb 14, 2018
@rleigh-codelibre rleigh-codelibre deleted the submodule-branch branch February 14, 2018 21:25
@sbesson sbesson added this to the 0.9.2 milestone Jun 6, 2018
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.

3 participants