From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6FC54158089 for ; Sun, 22 Oct 2023 19:03:36 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B08872BC014; Sun, 22 Oct 2023 19:03:35 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9A71C2BC014 for ; Sun, 22 Oct 2023 19:03:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E05C7335C52 for ; Sun, 22 Oct 2023 19:03:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7FFD311E6 for ; Sun, 22 Oct 2023 19:03:33 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1698001137.3b8442d6683cad9debe9fce554e2bd958188ab7c.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: /, lib/portage/sync/modules/git/ X-VCS-Repository: proj/portage X-VCS-Files: NEWS lib/portage/sync/modules/git/git.py X-VCS-Directories: / lib/portage/sync/modules/git/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 3b8442d6683cad9debe9fce554e2bd958188ab7c X-VCS-Branch: master Date: Sun, 22 Oct 2023 19:03:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 908f814c-80fb-4c05-ae9d-e60424ea470b X-Archives-Hash: 69c9995fa37a659dbe9948e5960fe9cc commit: 3b8442d6683cad9debe9fce554e2bd958188ab7c Author: Florian Schmaus gentoo org> AuthorDate: Thu Oct 19 08:48:31 2023 +0000 Commit: Sam James gentoo org> CommitDate: Sun Oct 22 18:58:57 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3b8442d6 sync/git: update git remote url with sync-uri when necessary If the repo is not volatile, update the URL of the git remote if it is not equal to the configured sync-uri. Closes: https://bugs.gentoo.org/905869 Signed-off-by: Florian Schmaus gentoo.org> Signed-off-by: Sam James gentoo.org> NEWS | 3 +++ lib/portage/sync/modules/git/git.py | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ee33b0eb57..63b072f7ba 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,9 @@ Bug fixes: * Eliminate unnecessary package reinstalls (bug #915494). +* Update the git remote URL of an overlay with its configured sync-uri + when necessary (bug #905869). + portage-3.0.52 (2023-10-03) -------------- diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py index 4b11e3fa85..a2c96e8098 100644 --- a/lib/portage/sync/modules/git/git.py +++ b/lib/portage/sync/modules/git/git.py @@ -294,9 +294,40 @@ class GitSync(NewBase): writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) return (exitcode, False) + git_remote = remote_branch.partition("/")[0] + + if not self.repo.volatile: + git_get_remote_url_cmd = ["git", "ls-remote", "--get-url", git_remote] + git_remote_url = portage._unicode_decode( + subprocess.check_output( + git_get_remote_url_cmd, + cwd=portage._unicode_encode(self.repo.location), + ) + ).strip() + if git_remote_url != self.repo.sync_uri: + git_set_remote_url_cmd = [ + "git", + "remote", + "set-url", + git_remote, + self.repo.sync_uri, + ] + exitcode = portage.process.spawn( + git_set_remote_url_cmd, + cwd=portage._unicode_encode(self.repo.location), + **self.spawn_kwargs, + ) + if exitcode != os.EX_OK: + msg = f"!!! could not update git remote {git_remote}'s url to {self.repo.sync_uri}" + self.logger(self.xterm_titles, msg) + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) + return (exitcode, False) + elif not quiet: + writemsg_level(" ".join(git_set_remote_url_cmd) + "\n") + git_cmd = "{} fetch {}{}".format( self.bin_command, - remote_branch.partition("/")[0], + git_remote, git_cmd_opts, )