Skip to content

Commit

Permalink
Make repo installation work without .git
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
sokcevicG authored and LUCI committed Nov 18, 2024
1 parent ab2d321 commit b1613d7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions repo
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1335,10 +1335,11 @@ def _Help(args):

def _Version():
"""Show version information."""
git_version = ParseGitVersion()
print("<repo not installed>")
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})")
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit b1613d7

Please sign in to comment.