From b1613d741e47d4f2a1d4c184daec73c110425385 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Fri, 15 Nov 2024 22:41:30 +0000 Subject: [PATCH] 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 Tested-by: Josip Sokcevic Commit-Queue: Josip Sokcevic --- repo | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/repo b/repo index 9cedcbf98..6cda13662 100755 --- a/repo +++ b/repo @@ -124,7 +124,7 @@ if not REPO_REV: BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" # increment this whenever we make important changes to this script -VERSION = (2, 48) +VERSION = (2, 50) # increment this if the MAINTAINER_KEYS block is modified KEYRING_VERSION = (2, 3) @@ -1335,10 +1335,11 @@ def _Help(args): def _Version(): """Show version information.""" + git_version = ParseGitVersion() print("") print(f"repo launcher version {'.'.join(str(x) for x in VERSION)}") print(f" (from {__file__})") - print(f"git {ParseGitVersion().full}") + print(f"git {git_version.full}" if git_version else "git not installed") print(f"Python {sys.version}") uname = platform.uname() print(f"OS {uname.system} {uname.release} ({uname.version})") @@ -1371,11 +1372,11 @@ def _RunSelf(wrapper_path): my_main = os.path.join(my_dir, "main.py") my_git = os.path.join(my_dir, ".git") - if os.path.isfile(my_main) and os.path.isdir(my_git): + if os.path.isfile(my_main): for name in ["git_config.py", "project.py", "subcmds"]: if not os.path.exists(os.path.join(my_dir, name)): return None, None - return my_main, my_git + return my_main, my_git if os.path.isdir(my_git) else None return None, None