diff options
author | Xin Li <delphij@google.com> | 2021-09-26 23:20:32 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2021-09-27 06:36:05 +0000 |
commit | e0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6 (patch) | |
tree | 7759c55cdbe045de3974be17bc3a5557d42619db /git_superproject.py | |
parent | d669d2dee5bd7986593d5df1dd8a736778501bbf (diff) | |
download | git-repo-e0b16a22a01c54a00a9e4a0c53dddfce3b0d59d6.tar.gz |
superproject: support a new revision attribute.
Tested:
$ ./run_tests
Verified that a manifest that specified superproject revision would use
the specified revision, and superproject will use the default revision.
Note that this is a slight behavior change from earlier repo versions,
which would always use the branch name of the manifest itself. However,
the new behavior would be more consisitent with regular "project"
element and would allow superproject be used even if it is not enabled
for the particular manifest branch, so we have decided to make the
change as it would provide more flexibility and better matches what
other elements would do.
Bug: [google internal] b/187868160
Change-Id: I35255ee347aff6e65179f7879d52931f168b477e
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/317643
Tested-by: Xin Li <delphij@google.com>
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_superproject.py')
-rw-r--r-- | git_superproject.py | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/git_superproject.py b/git_superproject.py index 935e1250..ce68690f 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
@@ -90,7 +90,7 @@ class Superproject(object): | |||
90 | self._git_event_log = git_event_log | 90 | self._git_event_log = git_event_log |
91 | self._quiet = quiet | 91 | self._quiet = quiet |
92 | self._print_messages = print_messages | 92 | self._print_messages = print_messages |
93 | self._branch = self._GetBranch() | 93 | self._branch = manifest.branch |
94 | self._repodir = os.path.abspath(repodir) | 94 | self._repodir = os.path.abspath(repodir) |
95 | self._superproject_dir = superproject_dir | 95 | self._superproject_dir = superproject_dir |
96 | self._superproject_path = os.path.join(self._repodir, superproject_dir) | 96 | self._superproject_path = os.path.join(self._repodir, superproject_dir) |
@@ -100,6 +100,7 @@ class Superproject(object): | |||
100 | if self._manifest.superproject: | 100 | if self._manifest.superproject: |
101 | remote = self._manifest.superproject['remote'] | 101 | remote = self._manifest.superproject['remote'] |
102 | git_name = hashlib.md5(remote.name.encode('utf8')).hexdigest() + '-' | 102 | git_name = hashlib.md5(remote.name.encode('utf8')).hexdigest() + '-' |
103 | self._branch = self._manifest.superproject['revision'] | ||
103 | self._remote_url = remote.url | 104 | self._remote_url = remote.url |
104 | else: | 105 | else: |
105 | self._remote_url = None | 106 | self._remote_url = None |
@@ -116,17 +117,6 @@ class Superproject(object): | |||
116 | """Returns the manifest path if the path exists or None.""" | 117 | """Returns the manifest path if the path exists or None.""" |
117 | return self._manifest_path if os.path.exists(self._manifest_path) else None | 118 | return self._manifest_path if os.path.exists(self._manifest_path) else None |
118 | 119 | ||
119 | def _GetBranch(self): | ||
120 | """Returns the branch name for getting the approved manifest.""" | ||
121 | p = self._manifest.manifestProject | ||
122 | b = p.GetBranch(p.CurrentBranch) | ||
123 | if not b: | ||
124 | return None | ||
125 | branch = b.merge | ||
126 | if branch and branch.startswith(R_HEADS): | ||
127 | branch = branch[len(R_HEADS):] | ||
128 | return branch | ||
129 | |||
130 | def _LogMessage(self, message): | 120 | def _LogMessage(self, message): |
131 | """Logs message to stderr and _git_event_log.""" | 121 | """Logs message to stderr and _git_event_log.""" |
132 | if self._print_messages: | 122 | if self._print_messages: |