mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-07-16 21:57:00 +00:00
project: Add REPO_PROJECT_FETCH_URL environment variable
Add REPO_PROJECT_FETCH_URL to Project.GetEnvVars(), which resolves to the remote fetch URL of the project. This is useful for exposing the URL to custom fetch commands or other external scripts. Bug: 513329573 Change-Id: Ic2b0a83493934d16bb1152366ee4e1a2c35ea2dc Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/596121 Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
committed by
gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
4b462634e0
commit
cd307a6089
@@ -125,6 +125,8 @@ REPO_UPSTREAM is the name of the upstream branch as specified in the manifest.
|
|||||||
REPO_DEST_BRANCH is the name of the destination branch for code review, as
|
REPO_DEST_BRANCH is the name of the destination branch for code review, as
|
||||||
specified in the manifest.
|
specified in the manifest.
|
||||||
.PP
|
.PP
|
||||||
|
REPO_PROJECT_FETCH_URL is the full resolved fetch URL for the project.
|
||||||
|
.PP
|
||||||
REPO_COUNT is the total number of projects being iterated.
|
REPO_COUNT is the total number of projects being iterated.
|
||||||
.PP
|
.PP
|
||||||
REPO_I is the current (1\-based) iteration count. Can be used in conjunction with
|
REPO_I is the current (1\-based) iteration count. Can be used in conjunction with
|
||||||
|
|||||||
@@ -680,6 +680,7 @@ class Project:
|
|||||||
setenv("REPO_INNERPATH", self.relpath)
|
setenv("REPO_INNERPATH", self.relpath)
|
||||||
setenv("REPO_PATH", self.RelPath(local=local))
|
setenv("REPO_PATH", self.RelPath(local=local))
|
||||||
setenv("REPO_REMOTE", self.remote.name)
|
setenv("REPO_REMOTE", self.remote.name)
|
||||||
|
setenv("REPO_PROJECT_FETCH_URL", self.remote.url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lrev = "" if self.manifest.IsMirror else self.GetRevisionId()
|
lrev = "" if self.manifest.IsMirror else self.GetRevisionId()
|
||||||
|
|||||||
@@ -107,6 +107,8 @@ manifest.
|
|||||||
REPO_DEST_BRANCH is the name of the destination branch for code review,
|
REPO_DEST_BRANCH is the name of the destination branch for code review,
|
||||||
as specified in the manifest.
|
as specified in the manifest.
|
||||||
|
|
||||||
|
REPO_PROJECT_FETCH_URL is the full resolved fetch URL for the project.
|
||||||
|
|
||||||
REPO_COUNT is the total number of projects being iterated.
|
REPO_COUNT is the total number of projects being iterated.
|
||||||
|
|
||||||
REPO_I is the current (1-based) iteration count. Can be used in
|
REPO_I is the current (1-based) iteration count. Can be used in
|
||||||
|
|||||||
@@ -1060,6 +1060,9 @@ class GetEnvVarsTests(unittest.TestCase):
|
|||||||
self.assertEqual(env["REPO_RREV"], "main")
|
self.assertEqual(env["REPO_RREV"], "main")
|
||||||
self.assertEqual(env["REPO_UPSTREAM"], "upstream-branch")
|
self.assertEqual(env["REPO_UPSTREAM"], "upstream-branch")
|
||||||
self.assertEqual(env["REPO_DEST_BRANCH"], "dest-branch")
|
self.assertEqual(env["REPO_DEST_BRANCH"], "dest-branch")
|
||||||
|
self.assertEqual(
|
||||||
|
env["REPO_PROJECT_FETCH_URL"], "http://example.com/repo"
|
||||||
|
)
|
||||||
|
|
||||||
def test_get_env_vars_non_local(self):
|
def test_get_env_vars_non_local(self):
|
||||||
"""Test environment variables generation with local=False."""
|
"""Test environment variables generation with local=False."""
|
||||||
|
|||||||
Reference in New Issue
Block a user