Skip to content

Commit b1613d7

Browse files
sokcevicGLUCI
authored andcommitted
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 <[email protected]> Tested-by: Josip Sokcevic <[email protected]> Commit-Queue: Josip Sokcevic <[email protected]>
1 parent ab2d321 commit b1613d7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

repo

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ if not REPO_REV:
124124
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
125125

126126
# increment this whenever we make important changes to this script
127-
VERSION = (2, 48)
127+
VERSION = (2, 50)
128128

129129
# increment this if the MAINTAINER_KEYS block is modified
130130
KEYRING_VERSION = (2, 3)
@@ -1335,10 +1335,11 @@ def _Help(args):
13351335

13361336
def _Version():
13371337
"""Show version information."""
1338+
git_version = ParseGitVersion()
13381339
print("<repo not installed>")
13391340
print(f"repo launcher version {'.'.join(str(x) for x in VERSION)}")
13401341
print(f" (from {__file__})")
1341-
print(f"git {ParseGitVersion().full}")
1342+
print(f"git {git_version.full}" if git_version else "git not installed")
13421343
print(f"Python {sys.version}")
13431344
uname = platform.uname()
13441345
print(f"OS {uname.system} {uname.release} ({uname.version})")
@@ -1371,11 +1372,11 @@ def _RunSelf(wrapper_path):
13711372
my_main = os.path.join(my_dir, "main.py")
13721373
my_git = os.path.join(my_dir, ".git")
13731374

1374-
if os.path.isfile(my_main) and os.path.isdir(my_git):
1375+
if os.path.isfile(my_main):
13751376
for name in ["git_config.py", "project.py", "subcmds"]:
13761377
if not os.path.exists(os.path.join(my_dir, name)):
13771378
return None, None
1378-
return my_main, my_git
1379+
return my_main, my_git if os.path.isdir(my_git) else None
13791380
return None, None
13801381

13811382

0 commit comments

Comments
 (0)