1
0
Fork 0

add --superproject-rev for repo status

If the option is given, repo status prints the superproject revision

Change-Id: I5d1c709518d76d777a7f07c4c774569773c5a265
Bug: 416589884
This commit is contained in:
Scott Lee 2025-05-27 18:30:56 +00:00
parent 8d37f61471
commit e47369cd16
3 changed files with 30 additions and 2 deletions

View file

@ -129,6 +129,29 @@ class Superproject:
"""Set the _print_messages attribute.""" """Set the _print_messages attribute."""
self._print_messages = value self._print_messages = value
@property
def commit_id(self):
"""Returns the commit ID of the superproject checkout."""
cmd = ["rev-parse", self.revision]
p = GitCommand(
None, # project
cmd,
gitdir=self._work_git,
bare=True,
capture_stdout=True,
capture_stderr=True,
)
retval = p.Wait()
if retval != 0:
self._LogWarning(
"git rev-parse call failed, command: git {}, "
"return code: {}, stderr: {}",
cmd,
p.stdwerr,
)
return None
return p.stdout
@property @property
def project_commit_ids(self): def project_commit_ids(self):
"""Returns a dictionary of projects and their commit ids.""" """Returns a dictionary of projects and their commit ids."""
@ -276,7 +299,7 @@ class Superproject:
Works only in git repositories. Works only in git repositories.
Returns: Returns:
data: data returned from 'git ls-tree ...' instead of None. data: data returned from 'git ls-tree ...'. None on error.
""" """
if not os.path.exists(self._work_git): if not os.path.exists(self._work_git):
self._LogWarning( self._LogWarning(
@ -306,6 +329,7 @@ class Superproject:
retval, retval,
p.stderr, p.stderr,
) )
return None
return data return data
def Sync(self, git_event_log): def Sync(self, git_event_log):

View file

@ -1,5 +1,5 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man. .\" DO NOT MODIFY THIS FILE! It was generated by help2man.
.TH REPO "1" "July 2022" "repo status" "Repo Manual" .TH REPO "1" "May 2025" "repo status" "Repo Manual"
.SH NAME .SH NAME
repo \- repo status - manual page for repo status repo \- repo status - manual page for repo status
.SH SYNOPSIS .SH SYNOPSIS

View file

@ -104,6 +104,10 @@ class Info(PagedCommand):
self.heading("Manifest groups: ") self.heading("Manifest groups: ")
self.headtext(manifestGroups) self.headtext(manifestGroups)
self.out.nl() self.out.nl()
sp = self.manifest.superproject
srev = sp.commit_id if sp and sp.commit_id else "None"
self.heading("Superproject Revision: ")
self.headtext(srev)
self.printSeparator() self.printSeparator()