summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosip Sokcevic <sokcevic@google.com>2024-11-15 22:41:30 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-11-18 19:36:14 +0000
commitb1613d741e47d4f2a1d4c184daec73c110425385 (patch)
tree5bf60141e1a5c3220bac760d7e454d0d007e3eae
parentab2d3211043e2cb42a55f56e5abf69d23103c105 (diff)
downloadgit-repo-b1613d741e47d4f2a1d4c184daec73c110425385.tar.gz
Make repo installation work without .git
Some tools like jj and cog will not have .git. This change makes it possible to run all repo commands in such setups. Change-Id: I7f3845dc970fbaa731c31e0aa48355a4b56ed3a6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/442821 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
-rwxr-xr-xrepo9
1 files changed, 5 insertions, 4 deletions
diff --git a/repo b/repo
index 9cedcbf9..6cda1366 100755
--- a/repo
+++ b/repo
@@ -124,7 +124,7 @@ if not REPO_REV:
124BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" 124BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
125 125
126# increment this whenever we make important changes to this script 126# increment this whenever we make important changes to this script
127VERSION = (2, 48) 127VERSION = (2, 50)
128 128
129# increment this if the MAINTAINER_KEYS block is modified 129# increment this if the MAINTAINER_KEYS block is modified
130KEYRING_VERSION = (2, 3) 130KEYRING_VERSION = (2, 3)
@@ -1335,10 +1335,11 @@ def _Help(args):
1335 1335
1336def _Version(): 1336def _Version():
1337 """Show version information.""" 1337 """Show version information."""
1338 git_version = ParseGitVersion()
1338 print("<repo not installed>") 1339 print("<repo not installed>")
1339 print(f"repo launcher version {'.'.join(str(x) for x in VERSION)}") 1340 print(f"repo launcher version {'.'.join(str(x) for x in VERSION)}")
1340 print(f" (from {__file__})") 1341 print(f" (from {__file__})")
1341 print(f"git {ParseGitVersion().full}") 1342 print(f"git {git_version.full}" if git_version else "git not installed")
1342 print(f"Python {sys.version}") 1343 print(f"Python {sys.version}")
1343 uname = platform.uname() 1344 uname = platform.uname()
1344 print(f"OS {uname.system} {uname.release} ({uname.version})") 1345 print(f"OS {uname.system} {uname.release} ({uname.version})")
@@ -1371,11 +1372,11 @@ def _RunSelf(wrapper_path):
1371 my_main = os.path.join(my_dir, "main.py") 1372 my_main = os.path.join(my_dir, "main.py")
1372 my_git = os.path.join(my_dir, ".git") 1373 my_git = os.path.join(my_dir, ".git")
1373 1374
1374 if os.path.isfile(my_main) and os.path.isdir(my_git): 1375 if os.path.isfile(my_main):
1375 for name in ["git_config.py", "project.py", "subcmds"]: 1376 for name in ["git_config.py", "project.py", "subcmds"]:
1376 if not os.path.exists(os.path.join(my_dir, name)): 1377 if not os.path.exists(os.path.join(my_dir, name)):
1377 return None, None 1378 return None, None
1378 return my_main, my_git 1379 return my_main, my_git if os.path.isdir(my_git) else None
1379 return None, None 1380 return None, None
1380 1381
1381 1382