Skip to content

Commit 3c8bae2

Browse files
Scott LeeLUCI
Scott Lee
authored and
LUCI
committed
info: print superproject revision
Bug: 416589884 Change-Id: I5d1c709518d76d777a7f07c4c774569773c5a265 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/478205 Lint: Scott Lee <[email protected]> Tested-by: Scott Lee <[email protected]> Reviewed-by: Mike Frysinger <[email protected]> Commit-Queue: Scott Lee <[email protected]>
1 parent 06338ab commit 3c8bae2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

git_superproject.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,29 @@ def SetPrintMessages(self, value):
129129
"""Set the _print_messages attribute."""
130130
self._print_messages = value
131131

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+
132155
@property
133156
def project_commit_ids(self):
134157
"""Returns a dictionary of projects and their commit ids."""
@@ -276,7 +299,7 @@ def _LsTree(self):
276299
Works only in git repositories.
277300
278301
Returns:
279-
data: data returned from 'git ls-tree ...' instead of None.
302+
data: data returned from 'git ls-tree ...'. None on error.
280303
"""
281304
if not os.path.exists(self._work_git):
282305
self._LogWarning(
@@ -306,6 +329,7 @@ def _LsTree(self):
306329
retval,
307330
p.stderr,
308331
)
332+
return None
309333
return data
310334

311335
def Sync(self, git_event_log):

subcmds/info.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def Execute(self, opt, args):
102102
self.heading("Manifest groups: ")
103103
self.headtext(manifestGroups)
104104
self.out.nl()
105+
sp = self.manifest.superproject
106+
srev = sp.commit_id if sp and sp.commit_id else "None"
107+
self.heading("Superproject revision: ")
108+
self.headtext(srev)
105109

106110
self.printSeparator()
107111

0 commit comments

Comments
 (0)