From cd307a6089f136e8f4f0fe85ce0393782cf99af1 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Mon, 15 Jun 2026 23:22:53 +0000 Subject: [PATCH] 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 Reviewed-by: Mike Frysinger Commit-Queue: Gavin Mak --- man/repo-forall.1 | 2 ++ project.py | 1 + subcmds/forall.py | 2 ++ tests/test_project.py | 3 +++ 4 files changed, 8 insertions(+) diff --git a/man/repo-forall.1 b/man/repo-forall.1 index bbd83bd60..63ba210c5 100644 --- a/man/repo-forall.1 +++ b/man/repo-forall.1 @@ -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 specified in the manifest. .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. .PP REPO_I is the current (1\-based) iteration count. Can be used in conjunction with diff --git a/project.py b/project.py index 58366e90c..d87060929 100644 --- a/project.py +++ b/project.py @@ -680,6 +680,7 @@ class Project: setenv("REPO_INNERPATH", self.relpath) setenv("REPO_PATH", self.RelPath(local=local)) setenv("REPO_REMOTE", self.remote.name) + setenv("REPO_PROJECT_FETCH_URL", self.remote.url) try: lrev = "" if self.manifest.IsMirror else self.GetRevisionId() diff --git a/subcmds/forall.py b/subcmds/forall.py index 4560f0d27..03d12708d 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -107,6 +107,8 @@ manifest. REPO_DEST_BRANCH is the name of the destination branch for code review, 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_I is the current (1-based) iteration count. Can be used in diff --git a/tests/test_project.py b/tests/test_project.py index dd24afa04..7c4be48e6 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1060,6 +1060,9 @@ class GetEnvVarsTests(unittest.TestCase): self.assertEqual(env["REPO_RREV"], "main") self.assertEqual(env["REPO_UPSTREAM"], "upstream-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): """Test environment variables generation with local=False."""