mirror of
https://git.planet-casio.com/Lephenixnoir/GiteaPC.git
synced 2024-12-28 04:23:40 +01:00
giteapc: automatically switch remotes when updating repos
This commit is contained in:
parent
2fcd9726a0
commit
4e00af20a3
1 changed files with 14 additions and 0 deletions
|
@ -101,10 +101,24 @@ class LocalRepo:
|
|||
return False
|
||||
raise e
|
||||
|
||||
def updateRemotes(self):
|
||||
# Automatically switch old gitea URLs to Forgejo
|
||||
for r in self._git(["remote"], stdout=PIPE).stdout.split():
|
||||
url = self._git(["remote", "get-url", r], stdout=PIPE).stdout.rstrip(b"\n")
|
||||
new = url
|
||||
if url.startswith(b"gitea@gitea.planet-casio.com:"):
|
||||
new = b"forgejo@git" + url[11:]
|
||||
if url.startswith(b"https://gitea.planet-casio.com/"):
|
||||
new = b"https://git." + url[14:]
|
||||
if new != url:
|
||||
self._git(["remote", "set-url", r, new])
|
||||
|
||||
def fetch(self):
|
||||
self.updateRemotes()
|
||||
self._git(["fetch"])
|
||||
|
||||
def pull(self):
|
||||
self.updateRemotes()
|
||||
if self.is_on_branch():
|
||||
self._git(["pull"])
|
||||
|
||||
|
|
Loading…
Reference in a new issue