mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Add total count and iteration count to forall environment
For long-running forall commands sometimes it's useful to know which iteration is currently running. Add REPO_I and REPO_COUNT environment variables to reflect the current iteration count as well as the total number of iterations so that the user can build simple status indicators. Example: $ repo forall -c 'echo $REPO_I / $REPO_COUNT; git gc' 1 / 579 Counting objects: 41, done. Delta compression using up to 8 threads. Compressing objects: 100% (19/19), done. Writing objects: 100% (41/41), done. Total 41 (delta 21), reused 41 (delta 21) 2 / 579 Counting objects: 53410, done. Delta compression using up to 8 threads. Compressing objects: 100% (10423/10423), done. Writing objects: 100% (53410/53410), done. Total 53410 (delta 42513), reused 53410 (delta 42513) 3 / 579 ... Change-Id: I9f28b0d8b7debe423eed3b4bc1198b23e40c0c50 Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
This commit is contained in:
parent
26c45a7958
commit
e81bc030bb
@ -87,6 +87,12 @@ revision to a locally executed git command, use REPO_LREV.
|
|||||||
REPO_RREV is the name of the revision from the manifest, exactly
|
REPO_RREV is the name of the revision from the manifest, exactly
|
||||||
as written in the manifest.
|
as written in the manifest.
|
||||||
|
|
||||||
|
REPO_COUNT is the total number of projects being iterated.
|
||||||
|
|
||||||
|
REPO_I is the current (1-based) iteration count. Can be used in
|
||||||
|
conjunction with REPO_COUNT to add a simple progress indicator to your
|
||||||
|
command.
|
||||||
|
|
||||||
REPO__* are any extra environment variables, specified by the
|
REPO__* are any extra environment variables, specified by the
|
||||||
"annotation" element under any project element. This can be useful
|
"annotation" element under any project element. This can be useful
|
||||||
for differentiating trees based on user-specific criteria, or simply
|
for differentiating trees based on user-specific criteria, or simply
|
||||||
@ -178,7 +184,9 @@ without iterating through the remaining projects.
|
|||||||
else:
|
else:
|
||||||
projects = self.FindProjects(args)
|
projects = self.FindProjects(args)
|
||||||
|
|
||||||
for project in projects:
|
os.environ['REPO_COUNT'] = str(len(projects))
|
||||||
|
|
||||||
|
for (cnt, project) in enumerate(projects):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
def setenv(name, val):
|
def setenv(name, val):
|
||||||
if val is None:
|
if val is None:
|
||||||
@ -190,6 +198,7 @@ without iterating through the remaining projects.
|
|||||||
setenv('REPO_REMOTE', project.remote.name)
|
setenv('REPO_REMOTE', project.remote.name)
|
||||||
setenv('REPO_LREV', project.GetRevisionId())
|
setenv('REPO_LREV', project.GetRevisionId())
|
||||||
setenv('REPO_RREV', project.revisionExpr)
|
setenv('REPO_RREV', project.revisionExpr)
|
||||||
|
setenv('REPO_I', str(cnt + 1))
|
||||||
for a in project.annotations:
|
for a in project.annotations:
|
||||||
setenv("REPO__%s" % (a.name), a.value)
|
setenv("REPO__%s" % (a.name), a.value)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user