mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
upgrade-zulip-from-git: Check fetch refspecs, not mirror flag.
While the `remote.origin.mirror` boolean being set is a very good
proxy for having been cloned with `--mirror`, is technically only used
when pushing into the remote[1]. What we care about is if fetches
from this remote will overwrite `refs/heads/`, or all of `refs/` --
the latter of which is most likely, from having run `git clone
--bare`.
Detect either of these fetch refspecs, and not the mirror flag. We
let the upgrade process error out if `remote.origin.fetch` is unset,
as that represents an unexpected state. We ignore failures to unset
the `remote.origin.mirror` flag, in case it is not set already.
[1]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-remoteltnamegtmirror
(cherry picked from commit 1639792e9e)
This commit is contained in:
@@ -74,14 +74,18 @@ try:
|
|||||||
["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip
|
["git", "remote", "set-url", "origin", remote_url], preexec_fn=su_to_zulip
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check to see if it's the old "mirror" configuration
|
fetch_spec = subprocess.check_output(
|
||||||
is_mirror = subprocess.check_output(
|
["git", "config", "remote.origin.fetch"],
|
||||||
["git", "config", "--bool", "--default=false", "remote.origin.mirror"],
|
|
||||||
preexec_fn=su_to_zulip,
|
preexec_fn=su_to_zulip,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
).strip()
|
||||||
if is_mirror.strip() == "true":
|
if fetch_spec in ("+refs/*:refs/*", "+refs/heads/*:refs/heads/*"):
|
||||||
subprocess.check_call(
|
# The refspec impinges on refs/heads/ -- this is an old mirror
|
||||||
|
# configuration.
|
||||||
|
logging.info("Cleaning up mirrored repository")
|
||||||
|
# remotes.origin.mirror may not be set -- we do not use
|
||||||
|
# check_call to ignore errors if it's already missing
|
||||||
|
subprocess.call(
|
||||||
["git", "config", "--unset", "remote.origin.mirror"],
|
["git", "config", "--unset", "remote.origin.mirror"],
|
||||||
preexec_fn=su_to_zulip,
|
preexec_fn=su_to_zulip,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user