diff options
author | Sean McAllister <smcallis@google.com> | 2020-04-15 12:24:43 -0600 |
---|---|---|
committer | Sean McAllister <smcallis@google.com> | 2020-04-16 18:42:53 +0000 |
commit | 74e8ed4bde37a3ce42579e4601e0a54120853c89 (patch) | |
tree | ca0c74f490498124d784d8f2c2ed4c146d10097f | |
parent | 2fe84e17b923f29139dc6056756ab30078864c18 (diff) | |
download | git-repo-74e8ed4bde37a3ce42579e4601e0a54120853c89.tar.gz |
Expose upstream and dest-branch attributes through environment
Recent changes in ChromeOS Infra to ensure we're reading from
snapshot manifests properly have exposed several bugs in our
assumptions about manifest files. Mainly that the revision field
for a project does _not_ have to refer to a ref, it can just be
a commit hash.
Several places assume that the revision field can be parsed as a
ref to get the branch the project is on, which isn't true. To fix
this we need to be able to look at the upstream and dest-branch
attributes of the repo, so we expose them through the environment
variables set in `repo forall`.
Test: manual 'repo forall' run
Bug: https://crbug.com/1032441
Change-Id: I2c039e0f4b2e0f430602932e91b782edb6f9b1ed
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/263132
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Sean McAllister <smcallis@google.com>
-rw-r--r-- | subcmds/forall.py | 4 | ||||
-rw-r--r-- | subcmds/manifest.py | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index a13793d0..55d61ecb 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -179,6 +179,8 @@ without iterating through the remaining projects. | |||
179 | 'annotations': dict((a.name, a.value) for a in project.annotations), | 179 | 'annotations': dict((a.name, a.value) for a in project.annotations), |
180 | 'gitdir': project.gitdir, | 180 | 'gitdir': project.gitdir, |
181 | 'worktree': project.worktree, | 181 | 'worktree': project.worktree, |
182 | 'upstream': project.upstream, | ||
183 | 'dest_branch': project.dest_branch, | ||
182 | } | 184 | } |
183 | 185 | ||
184 | def ValidateOptions(self, opt, args): | 186 | def ValidateOptions(self, opt, args): |
@@ -317,6 +319,8 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): | |||
317 | setenv('REPO_REMOTE', project['remote_name']) | 319 | setenv('REPO_REMOTE', project['remote_name']) |
318 | setenv('REPO_LREV', project['lrev']) | 320 | setenv('REPO_LREV', project['lrev']) |
319 | setenv('REPO_RREV', project['rrev']) | 321 | setenv('REPO_RREV', project['rrev']) |
322 | setenv('REPO_UPSTREAM', project['upstream']) | ||
323 | setenv('REPO_DEST_BRANCH', project['dest_branch']) | ||
320 | setenv('REPO_I', str(cnt + 1)) | 324 | setenv('REPO_I', str(cnt + 1)) |
321 | for name in project['annotations']: | 325 | for name in project['annotations']: |
322 | setenv("REPO__%s" % (name), project['annotations'][name]) | 326 | setenv("REPO__%s" % (name), project['annotations'][name]) |
diff --git a/subcmds/manifest.py b/subcmds/manifest.py index d9f242ee..399e241e 100644 --- a/subcmds/manifest.py +++ b/subcmds/manifest.py | |||
@@ -34,6 +34,11 @@ The manifest and (if present) local_manifest.xml are combined | |||
34 | together to produce a single manifest file. This file can be stored | 34 | together to produce a single manifest file. This file can be stored |
35 | in a Git repository for use during future 'repo init' invocations. | 35 | in a Git repository for use during future 'repo init' invocations. |
36 | 36 | ||
37 | The -r option can be used to generate a manifest file with project | ||
38 | revisions set to the current commit hash. These are known as | ||
39 | "revision locked manifests", as they don't follow a particular branch. | ||
40 | In this case, the 'upstream' attribute is set to the ref we were on | ||
41 | when the manifest was generated. | ||
37 | """ | 42 | """ |
38 | 43 | ||
39 | @property | 44 | @property |