upgrade-zulip-from-git: init, then add remote.

30457ecd02 removed the `--mirror` from
initial clones, but did not add back `--bare`, which `--mirror`
implies.  This leads to `/srv/zulip.git` having a working tree in it,
with a `/srv/zulip.git/.git` directory.

This is mostly harmless, and since the bug was recent, not worth
introducing additional complexity into the upgrade process to handle.

Calling `git clone --bare`, however, would clone the refs into
`refs/heads/`, not the `refs/remotes/origin/` we want.  Instead, use
`git init --bare`, followed by `git remote add origin`.  The remote
will be fetched by the usual `git fetch --all --prune` which is below.
This commit is contained in:
Alex Vandiver 2022-06-08 19:25:20 -07:00 committed by Tim Abbott
parent 1639792e9e
commit 5bdc4b3562
1 changed files with 6 additions and 2 deletions

View File

@ -60,11 +60,15 @@ try:
# Populate LOCAL_GIT_CACHE_DIR with both the requested remote and zulip/zulip.
if not os.path.exists(LOCAL_GIT_CACHE_DIR):
logging.info("Cloning the repository")
logging.info("Making local repository cache")
subprocess.check_call(
["git", "clone", "-q", remote_url, LOCAL_GIT_CACHE_DIR],
["git", "init", "--bare", "-q", LOCAL_GIT_CACHE_DIR],
stdout=subprocess.DEVNULL,
)
subprocess.check_call(
["git", "remote", "add", "origin", remote_url],
cwd=LOCAL_GIT_CACHE_DIR,
)
if os.stat(LOCAL_GIT_CACHE_DIR).st_uid == 0:
subprocess.check_call(["chown", "-R", "zulip:zulip", LOCAL_GIT_CACHE_DIR])