From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: /, lib/portage/sync/modules/git/
Date: Sun, 22 Oct 2023 19:03:33 +0000 (UTC) [thread overview]
Message-ID: <1698001137.3b8442d6683cad9debe9fce554e2bd958188ab7c.sam@gentoo> (raw)
commit: 3b8442d6683cad9debe9fce554e2bd958188ab7c
Author: Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 19 08:48:31 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> 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 <flow <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> 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,
)
next reply other threads:[~2023-10-22 19:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-22 19:03 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-02-22 17:33 [gentoo-commits] proj/portage:master commit in: /, lib/portage/sync/modules/git/ Sam James
2022-12-31 14:11 Sam James
2022-12-21 1:28 Sam James
2022-12-21 1:28 Sam James
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1698001137.3b8442d6683cad9debe9fce554e2bd958188ab7c.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox