From 14cc1756fd22b195704b5528d58240473ecb8b83 Mon Sep 17 00:00:00 2001 From: hparfr Date: Tue, 9 Apr 2024 15:16:02 +0200 Subject: [PATCH] fix: git remote: change url instead of rm / add With some repos, there is an issue when the origin url is changed to a fork in repo.yml. Errors look like `unable to read sha1 file of`, `index-pack failed` It's occuring when the remote is removed (git remote rm origin) then added back with another url (git remote add origin ). With this fix, we change the url inplace. `git remote set-url origin ` --- git_aggregator/repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git_aggregator/repo.py b/git_aggregator/repo.py index 677334c..625e5ba 100644 --- a/git_aggregator/repo.py +++ b/git_aggregator/repo.py @@ -350,8 +350,8 @@ def _set_remote(self, name, url): else: logger.info('Updating remote %s <%s> -> <%s>', name, exising_url, url) - self.log_call(['git', 'remote', 'rm', name], cwd=self.cwd) - self.log_call(['git', 'remote', 'add', name, url], cwd=self.cwd) + self.log_call( + ['git', 'remote', 'set-url', name, url], cwd=self.cwd) def _github_api_get(self, path): url = 'https://api.github.com' + path