diff options
Diffstat (limited to 'git_superproject.py')
-rw-r--r-- | git_superproject.py | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/git_superproject.py b/git_superproject.py index aba836a3..687429ec 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
@@ -130,6 +130,29 @@ class Superproject: | |||
130 | self._print_messages = value | 130 | self._print_messages = value |
131 | 131 | ||
132 | @property | 132 | @property |
133 | def commit_id(self): | ||
134 | """Returns the commit ID of the superproject checkout.""" | ||
135 | cmd = ["rev-parse", self.revision] | ||
136 | p = GitCommand( | ||
137 | None, # project | ||
138 | cmd, | ||
139 | gitdir=self._work_git, | ||
140 | bare=True, | ||
141 | capture_stdout=True, | ||
142 | capture_stderr=True, | ||
143 | ) | ||
144 | retval = p.Wait() | ||
145 | if retval != 0: | ||
146 | self._LogWarning( | ||
147 | "git rev-parse call failed, command: git {}, " | ||
148 | "return code: {}, stderr: {}", | ||
149 | cmd, | ||
150 | p.stdwerr, | ||
151 | ) | ||
152 | return None | ||
153 | return p.stdout | ||
154 | |||
155 | @property | ||
133 | def project_commit_ids(self): | 156 | def project_commit_ids(self): |
134 | """Returns a dictionary of projects and their commit ids.""" | 157 | """Returns a dictionary of projects and their commit ids.""" |
135 | return self._project_commit_ids | 158 | return self._project_commit_ids |
@@ -150,12 +173,15 @@ class Superproject: | |||
150 | Then the repo_id would be: | 173 | Then the repo_id would be: |
151 | android/platform/superproject | 174 | android/platform/superproject |
152 | """ | 175 | """ |
153 | if review_url := self.remote.review: | 176 | review_url = self.remote.review |
177 | if review_url: | ||
154 | parsed_url = urllib.parse.urlparse(review_url) | 178 | parsed_url = urllib.parse.urlparse(review_url) |
155 | if netloc := parsed_url.netloc: | 179 | netloc = parsed_url.netloc |
180 | if netloc: | ||
156 | parts = netloc.split("-review", 1) | 181 | parts = netloc.split("-review", 1) |
157 | host = parts[0] | 182 | host = parts[0] |
158 | return f"{host}/{self.name}" | 183 | rev = GitRefs(self._work_git).get("HEAD") |
184 | return f"{host}/{self.name}@{rev}" | ||
159 | return None | 185 | return None |
160 | 186 | ||
161 | def _LogMessage(self, fmt, *inputs): | 187 | def _LogMessage(self, fmt, *inputs): |
@@ -276,7 +302,7 @@ class Superproject: | |||
276 | Works only in git repositories. | 302 | Works only in git repositories. |
277 | 303 | ||
278 | Returns: | 304 | Returns: |
279 | data: data returned from 'git ls-tree ...' instead of None. | 305 | data: data returned from 'git ls-tree ...'. None on error. |
280 | """ | 306 | """ |
281 | if not os.path.exists(self._work_git): | 307 | if not os.path.exists(self._work_git): |
282 | self._LogWarning( | 308 | self._LogWarning( |
@@ -306,6 +332,7 @@ class Superproject: | |||
306 | retval, | 332 | retval, |
307 | p.stderr, | 333 | p.stderr, |
308 | ) | 334 | ) |
335 | return None | ||
309 | return data | 336 | return data |
310 | 337 | ||
311 | def Sync(self, git_event_log): | 338 | def Sync(self, git_event_log): |