public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2018-07-23 18:52 Zac Medico
  0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2018-07-23 18:52 UTC (permalink / raw
  To: gentoo-commits

commit:     dc1ba7729c42cbe738ae7ec34e2f13f79c48d41c
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 23 18:46:08 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 23 18:51:02 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=dc1ba772

git: fix key refresh failure to trigger abort (bug 661906)

Fix the verify_head method to appropriately return a bool
value instead of a tuple.

Fixes: d30191b887bb ("git: Support running the verification against sync-openpgp-key-path")
Bug: https://bugs.gentoo.org/661906

 lib/portage/sync/modules/git/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 2fb82c600..33f71b510 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -227,7 +227,7 @@ class GitSync(NewBase):
 					writemsg_level("!!! Verification impossible due to keyring problem:\n%s\n"
 							% (e,),
 							level=logging.ERROR, noiselevel=-1)
-					return (1, False)
+					False
 
 				env = os.environ.copy()
 				env['GNUPGHOME'] = openpgp_env.home


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2018-07-23 19:58 Zac Medico
  0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2018-07-23 19:58 UTC (permalink / raw
  To: gentoo-commits

commit:     de9801740fcbdb80c582308d7a4f2fef6b2b6aed
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 23 19:58:03 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 23 19:58:03 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=de980174

git: add missing return statement in fix for bug 661906

Fixes: dc1ba7729c42 ("git: fix key refresh failure to trigger abort (bug 661906)")
Bug: https://bugs.gentoo.org/661906

 lib/portage/sync/modules/git/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 33f71b510..e41af313e 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -227,7 +227,7 @@ class GitSync(NewBase):
 					writemsg_level("!!! Verification impossible due to keyring problem:\n%s\n"
 							% (e,),
 							level=logging.ERROR, noiselevel=-1)
-					False
+					return False
 
 				env = os.environ.copy()
 				env['GNUPGHOME'] = openpgp_env.home


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2020-07-02 22:08 Zac Medico
  0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2020-07-02 22:08 UTC (permalink / raw
  To: gentoo-commits

commit:     33b08baff4825bf84f639cf213de92ed36f76771
Author:     Wynn Wolf Arbor <wolf <AT> oriole <DOT> systems>
AuthorDate: Thu Jul  2 15:50:18 2020 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jul  2 21:39:39 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=33b08baf

git: Verify boolean values passed to sync-git-verify-commit-signature

Currently, if 'sync-git-verify-commit-signature' is set to anything
other than 'yes', 'no', 'true', or 'false', its value is ignored
silently and nothing is verified because the option defaults to 'false'.

Introduce a check to CheckGitConfig that warns the user if their input
is invalid.

Bug: https://bugs.gentoo.org/703698
Signed-off-by: Wynn Wolf Arbor <wolf <AT> oriole.systems>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/sync/modules/git/__init__.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/__init__.py b/lib/portage/sync/modules/git/__init__.py
index 270d97186..2081d0d25 100644
--- a/lib/portage/sync/modules/git/__init__.py
+++ b/lib/portage/sync/modules/git/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2014-2018 Gentoo Foundation
+# Copyright 2014-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 doc = """Git plug-in module for portage.
@@ -14,6 +14,7 @@ class CheckGitConfig(CheckSyncConfig):
 	def __init__(self, repo, logger):
 		CheckSyncConfig.__init__(self, repo, logger)
 		self.checks.append('check_depth')
+		self.checks.append('check_verify_commit_signature')
 
 	def check_depth(self):
 		for attr in ('clone_depth', 'sync_depth'):
@@ -33,6 +34,16 @@ class CheckGitConfig(CheckSyncConfig):
 			else:
 				setattr(self.repo, attr, d)
 
+	def check_verify_commit_signature(self):
+		v = self.repo.module_specific_options.get(
+			'sync-git-verify-commit-signature', 'false').lower()
+
+		if v not in ('yes', 'no', 'true', 'false'):
+			writemsg_level("!!! %s\n" %
+				_("sync-git-verify-commit-signature not one of: %s")
+				% ('{yes, no, true, false}'),
+				level=self.logger.ERROR, noiselevel=-1)
+
 
 module_spec = {
 	'name': 'git',


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2022-07-03  0:56 Mike Gilbert
  0 siblings, 0 replies; 21+ messages in thread
From: Mike Gilbert @ 2022-07-03  0:56 UTC (permalink / raw
  To: gentoo-commits

commit:     28d8d469ed8db68225fd50755655dcda61bd9a78
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Fri Jul  1 18:53:30 2022 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Fri Jul  1 19:01:18 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=28d8d469

git: mark repository as safe for newer gits

While this doesn't solve the odd permissions issue for communication
b/t gemato & git & portage, it does stop it manifesting.

This fixes compatibility with >=dev-vcs/git-2.35.2.

Bug: https://bugs.gentoo.org/838223
Bug: https://bugs.gentoo.org/838271
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 43 ++++++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 5 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 98670e1f9..381e31700 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -1,8 +1,9 @@
-# Copyright 2005-2020 Gentoo Authors
+# Copyright 2005-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 import io
 import logging
+import re
 import subprocess
 
 import portage
@@ -104,15 +105,19 @@ class GitSync(NewBase):
 
         exitcode = portage.process.spawn_bash(
             "cd %s ; exec %s" % (portage._shell_quote(self.repo.location), git_cmd),
-            **self.spawn_kwargs
+            **self.spawn_kwargs,
         )
         if exitcode != os.EX_OK:
             msg = "!!! git clone error in %s" % self.repo.location
             self.logger(self.xterm_titles, msg)
             writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
             return (exitcode, False)
+
+        self.add_safe_directory()
+
         if not self.verify_head():
             return (1, False)
+
         return (os.EX_OK, True)
 
     def update(self):
@@ -152,6 +157,8 @@ class GitSync(NewBase):
                 " %s" % self.repo.module_specific_options["sync-git-pull-extra-opts"]
             )
 
+        self.add_safe_directory()
+
         try:
             remote_branch = portage._unicode_decode(
                 subprocess.check_output(
@@ -184,7 +191,7 @@ class GitSync(NewBase):
             exitcode = portage.process.spawn(
                 gc_cmd,
                 cwd=portage._unicode_encode(self.repo.location),
-                **self.spawn_kwargs
+                **self.spawn_kwargs,
             )
             if exitcode != os.EX_OK:
                 msg = "!!! git gc error in %s" % self.repo.location
@@ -207,7 +214,7 @@ class GitSync(NewBase):
 
         exitcode = portage.process.spawn_bash(
             "cd %s ; exec %s" % (portage._shell_quote(self.repo.location), git_cmd),
-            **self.spawn_kwargs
+            **self.spawn_kwargs,
         )
 
         if exitcode != os.EX_OK:
@@ -231,7 +238,7 @@ class GitSync(NewBase):
         exitcode = portage.process.spawn(
             merge_cmd,
             cwd=portage._unicode_encode(self.repo.location),
-            **self.spawn_kwargs
+            **self.spawn_kwargs,
         )
 
         if exitcode != os.EX_OK:
@@ -341,3 +348,29 @@ class GitSync(NewBase):
         except subprocess.CalledProcessError:
             ret = (1, False)
         return ret
+
+    def add_safe_directory(self):
+        # Add safe.directory to system gitconfig if not already configured.
+        # Workaround for bug #838271 and bug #838223.
+        location_escaped = re.escape(self.repo.location)
+        result = subprocess.run(
+            [
+                self.bin_command,
+                "config",
+                "--get",
+                "safe.directory",
+                f"^{location_escaped}$",
+            ]
+        )
+        if result.returncode == 1:
+            result = subprocess.run(
+                [
+                    self.bin_command,
+                    "config",
+                    "--system",
+                    "--add",
+                    "safe.directory",
+                    self.repo.location,
+                ]
+            )
+        return result.returncode == 0


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2022-11-20  3:12 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2022-11-20  3:12 UTC (permalink / raw
  To: gentoo-commits

commit:     7a336e85052530c62acf25b5df10e2d02a17e779
Author:     John Helmert III <ajak <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 30 02:33:44 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Nov 20 03:12:47 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7a336e85

GitSync.update: clobber changes to git repo as rsync does

Check `git diff --quiet` and if tree is dirty, do a hard reset to the
upstream HEAD instead of simply merging. Thanks to a limitation in
git, also `git reset --hard` if the merge fails.

Closes: https://github.com/gentoo/portage/pull/931
Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index b4c470160..8bc5a3811 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -228,7 +228,21 @@ class GitSync(NewBase):
         if not self.verify_head(revision="refs/remotes/%s" % remote_branch):
             return (1, False)
 
-        if shallow:
+        # `git diff --quiet` returns 0 on a clean tree and 1 otherwise
+        is_clean = (
+            portage.process.spawn(
+                f"{self.bin_command} diff --quiet",
+                cwd=portage._unicode_encode(self.repo.location),
+                **self.spawn_kwargs,
+            )
+            == 0
+        )
+
+        if not is_clean:
+            # If the repo isn't clean, clobber any changes for parity
+            # with rsync
+            merge_cmd = [self.bin_command, "reset", "--hard"]
+        elif shallow:
             # Since the default merge strategy typically fails when
             # the depth is not unlimited, `git reset --merge`.
             merge_cmd = [self.bin_command, "reset", "--merge"]
@@ -244,10 +258,20 @@ class GitSync(NewBase):
         )
 
         if exitcode != os.EX_OK:
-            msg = "!!! git merge error in %s" % self.repo.location
-            self.logger(self.xterm_titles, msg)
-            writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
-            return (exitcode, False)
+            # HACK - sometimes merging results in a tree diverged from
+            # upstream, so try to hack around it
+            # https://stackoverflow.com/questions/41075972/how-to-update-a-git-shallow-clone/41081908#41081908
+            exitcode = portage.process.spawn(
+                f"{self.bin_command} reset --hard refs/remotes/{remote_branch}",
+                cwd=portage._unicode_encode(self.repo.location),
+                **self.spawn_kwargs,
+            )
+
+            if exitcode != os.EX_OK:
+                msg = "!!! git merge error in %s" % self.repo.location
+                self.logger(self.xterm_titles, msg)
+                writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+                return (exitcode, False)
 
         current_rev = subprocess.check_output(
             rev_cmd, cwd=portage._unicode_encode(self.repo.location)


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2022-12-21  1:28 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2022-12-21  1:28 UTC (permalink / raw
  To: gentoo-commits

commit:     cc20629da347393e6987fa58231e4b773ca0a5e7
Author:     John Helmert III <ajak <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 20 04:47:13 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec 21 01:28:03 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cc20629d

sync: git: add GIT_CEILING_DIRECTORIES for update operations

Bug: https://bugs.gentoo.org/887025
Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/939
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index e768e6861..7af665e5f 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -116,6 +116,22 @@ class GitSync(NewBase):
 
         return (os.EX_OK, True)
 
+    def _gen_ceiling_string(self, path):
+        """
+        Iteratively generate a colon delimited string of all of the
+        given path's parents, for use with GIT_CEILING_DIRECTORIES
+        """
+        path = self.repo.location
+        directories = []
+
+        while True:
+            if path == "/":
+                break
+            path = os.path.dirname(path)
+            directories.append(path)
+
+        return ":".join(directories)
+
     def update(self):
         """Update existing git repository, and ignore the syncuri. We are
         going to trust the user and assume that the user is in the branch
@@ -126,6 +142,13 @@ class GitSync(NewBase):
             return (1, False)
         git_cmd_opts = ""
         quiet = self.settings.get("PORTAGE_QUIET") == "1"
+
+        # We don't want to operate with a .git outside of the given
+        # repo in any circumstances.
+        self.spawn_kwargs["env"].update(
+            {"GIT_CEILING_DIRECTORIES": self._gen_ceiling_string(self.repo.location)}
+        )
+
         if self.repo.module_specific_options.get("sync-git-env"):
             shlexed_env = shlex_split(self.repo.module_specific_options["sync-git-env"])
             env = {


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2022-12-21  1:28 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2022-12-21  1:28 UTC (permalink / raw
  To: gentoo-commits

commit:     1696966564510e8359e3e29681dc1326c37c6e0b
Author:     John Helmert III <ajak <AT> gentoo <DOT> org>
AuthorDate: Thu Nov  3 02:48:59 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec 21 01:28:03 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=16969665

sync: git: `git clean` the repo before updating

With a shallow clone, git may leave orphaned files if the remote
moves from state X -> X-1. If on pulling again, state X is returned,
git will then abort to avoid clobbering untracked files.

Bug: https://bugs.gentoo.org/887025
Signed-off-by: John Helmert III <ajak <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 8602fecba..e768e6861 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -250,6 +250,24 @@ class GitSync(NewBase):
         if not self.verify_head(revision="refs/remotes/%s" % remote_branch):
             return (1, False)
 
+        # Clean up the repo before trying to sync to upstream's
+        clean_cmd = [self.bin_command, "clean", "--force", "-d", "-x"]
+
+        if quiet:
+            clean_cmd.append("--quiet")
+
+        portage.process.spawn(
+            clean_cmd,
+            cwd=portage._unicode_encode(self.repo.location),
+            **self.spawn_kwargs,
+        )
+
+        if exitcode != os.EX_OK:
+            msg = "!!! git clean error in %s" % self.repo.location
+            self.logger(self.xterm_titles, msg)
+            writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+            return (exitcode, False)
+
         # `git diff --quiet` returns 0 on a clean tree and 1 otherwise
         is_clean = (
             portage.process.spawn(


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2022-12-21  1:28 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2022-12-21  1:28 UTC (permalink / raw
  To: gentoo-commits

commit:     ac405c994a0cce67e11c1bc7fb37fc02bba627ae
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 17 05:19:32 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec 21 01:28:03 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=ac405c99

sync: git: allow truncating history if repository is marked volatile

See 54a08c9f71dc37851fdb0364576581ca19df6580 for an explanation
of the context here.

If the repository is marked as volatile, it's assumed that
Portage has complete control of it, and for Portage's purposes,
there's no use in having extended history (in fact, if anything,
it's deterimental, as it makes a sync more likely to fail due
to the large disk space requirements over time).

Bug: https://bugs.gentoo.org/824782
Bug: https://bugs.gentoo.org/887025
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index f16af0622..8602fecba 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -155,19 +155,24 @@ class GitSync(NewBase):
         if self.repo.sync_depth is not None:
             sync_depth = self.repo.sync_depth
         else:
-            # If sync-depth is not explicitly set by the user,
-            # then check if the target repository is already a
-            # shallow one. And do not perform a shallow update if
-            # the target repository is not shallow.
-            is_shallow_cmd = ["git", "rev-parse", "--is-shallow-repository"]
-            is_shallow_res = portage._unicode_decode(
-                subprocess.check_output(
-                    is_shallow_cmd,
-                    cwd=portage._unicode_encode(self.repo.location),
+            if self.repo.volatile:
+                # If sync-depth is not explicitly set by the user,
+                # then check if the target repository is already a
+                # shallow one. And do not perform a shallow update if
+                # the target repository is not shallow.
+                is_shallow_cmd = ["git", "rev-parse", "--is-shallow-repository"]
+                is_shallow_res = portage._unicode_decode(
+                    subprocess.check_output(
+                        is_shallow_cmd,
+                        cwd=portage._unicode_encode(self.repo.location),
+                    )
                 )
-            )
-            if is_shallow_res == "false":
-                sync_depth = 0
+                if is_shallow_res == "false":
+                    sync_depth = 0
+            else:
+                # If the repository is marked as non-volatile, we assume
+                # it's fine to Portage to do what it wishes to it.
+                sync_depth = 1
 
         shallow = False
         if sync_depth > 0:


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-02-24  9:22 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-02-24  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     d982bc7fec13b16098a90e55b5d535cb166e5e70
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 24 07:10:12 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 24 09:22:13 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d982bc7f

sync: git: replace self.settings.get("PORTAGE_QUIET") with 'quiet'

Let use the local 'quiet' variable when it is available.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/994
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 630f6e594..ce30be4cd 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -169,7 +169,7 @@ class GitSync(NewBase):
             }
             self.spawn_kwargs["env"].update(pull_env)
 
-        if self.settings.get("PORTAGE_QUIET") == "1":
+        if quiet:
             git_cmd_opts += " --quiet"
 
         # The logic here is a bit delicate. We need to balance two things:


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-02-24  9:22 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-02-24  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     e81a8ba91fb7574eabe3acc0dd5aef2e22e5eaf6
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 22 17:25:49 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 24 09:22:13 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=e81a8ba9

sync: git: also print merge_cmd

It felt strange that the sync operation would print the "git fetch"
command, but not the command used to merge the remote's changes into
the local working tree.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 353f9af07..ec13968f6 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -370,6 +370,9 @@ class GitSync(NewBase):
         if quiet:
             merge_cmd.append("--quiet")
 
+        if not quiet:
+            writemsg_level(' '.join(merge_cmd) + "\n")
+
         exitcode = portage.process.spawn(
             merge_cmd,
             cwd=portage._unicode_encode(self.repo.location),


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-02-24  9:22 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-02-24  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     8bee84ca27c6f2aebcc326d78c534725e5915e94
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 24 07:08:55 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Feb 24 09:22:13 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8bee84ca

sync: git: only print git_cmd if not quiet

For parity with how we print merge_cmd, which is also only printed if
we should not be quiet, we do the same for git_cmd.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index ec13968f6..630f6e594 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -301,7 +301,8 @@ class GitSync(NewBase):
             git_cmd_opts,
         )
 
-        writemsg_level(git_cmd + "\n")
+        if not quiet:
+            writemsg_level(git_cmd + "\n")
 
         rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
         previous_rev = subprocess.check_output(


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-02-25 23:22 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-02-25 23:22 UTC (permalink / raw
  To: gentoo-commits

commit:     76106cf613d08ae486082cc5f993572b3e8b0d39
Author:     Oskari Pirhonen <xxc3ncoredxx <AT> gmail <DOT> com>
AuthorDate: Sat Feb 25 03:11:06 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Feb 25 23:19:44 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=76106cf6

Make CI happy

Signed-off-by: Oskari Pirhonen <xxc3ncoredxx <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/996
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index ce30be4cd..3c2f9bdb4 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -372,7 +372,7 @@ class GitSync(NewBase):
             merge_cmd.append("--quiet")
 
         if not quiet:
-            writemsg_level(' '.join(merge_cmd) + "\n")
+            writemsg_level(" ".join(merge_cmd) + "\n")
 
         exitcode = portage.process.spawn(
             merge_cmd,


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-02-27  6:15 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-02-27  6:15 UTC (permalink / raw
  To: gentoo-commits

commit:     8924a8e3b3b4732b7792899141cc0ce76fee72ca
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 27 05:43:42 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Feb 27 06:15:41 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8924a8e3

sync: git: add trivial type annotations

Signed-off-by: Sam James <sam <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1000
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 3c2f9bdb4..9f70ea7ea 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -5,6 +5,8 @@ import logging
 import re
 import subprocess
 
+from typing import Tuple
+
 import portage
 from portage import os
 from portage.util import writemsg_level, shlex_split
@@ -35,11 +37,11 @@ class GitSync(NewBase):
     def __init__(self):
         NewBase.__init__(self, "git", portage.const.GIT_PACKAGE_ATOM)
 
-    def exists(self, **kwargs):
+    def exists(self, **kwargs) -> bool:
         """Tests whether the repo actually exists"""
         return os.path.exists(os.path.join(self.repo.location, ".git"))
 
-    def new(self, **kwargs):
+    def new(self, **kwargs) -> Tuple[int, bool]:
         """Do the initial clone of the repository"""
         if kwargs:
             self._kwargs(kwargs)
@@ -116,12 +118,11 @@ class GitSync(NewBase):
 
         return (os.EX_OK, True)
 
-    def _gen_ceiling_string(self, path):
+    def _gen_ceiling_string(self, path: str) -> str:
         """
         Iteratively generate a colon delimited string of all of the
         given path's parents, for use with GIT_CEILING_DIRECTORIES
         """
-        path = self.repo.location
         directories = []
 
         while True:
@@ -132,7 +133,7 @@ class GitSync(NewBase):
 
         return ":".join(directories)
 
-    def update(self):
+    def update(self) -> Tuple[int, bool]:
         """Update existing git repository, and ignore the syncuri. We are
         going to trust the user and assume that the user is in the branch
         that he/she wants updated. We'll let the user manage branches with
@@ -403,7 +404,7 @@ class GitSync(NewBase):
 
         return (os.EX_OK, current_rev != previous_rev)
 
-    def verify_head(self, revision="-1"):
+    def verify_head(self, revision="-1") -> bool:
         if self.repo.module_specific_options.get(
             "sync-git-verify-commit-signature", "false"
         ).lower() not in ("true", "yes"):
@@ -477,7 +478,7 @@ class GitSync(NewBase):
             if openpgp_env is not None:
                 openpgp_env.close()
 
-    def retrieve_head(self, **kwargs):
+    def retrieve_head(self, **kwargs) -> Tuple[int, bool]:
         """Get information about the head commit"""
         if kwargs:
             self._kwargs(kwargs)
@@ -498,7 +499,7 @@ class GitSync(NewBase):
             ret = (1, False)
         return ret
 
-    def add_safe_directory(self):
+    def add_safe_directory(self) -> bool:
         # Add safe.directory to system gitconfig if not already configured.
         # Workaround for bug #838271 and bug #838223.
         location_escaped = re.escape(self.repo.location)


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-08-17  6:53 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-08-17  6:53 UTC (permalink / raw
  To: gentoo-commits

commit:     1055d09fa6111106bb169159e051e3f82809e52a
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 13 04:40:11 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 17 06:52:55 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1055d09f

sync: git: dump gpg output if verification fails with --debug

Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 0b46bd9238..478e816370 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -480,6 +480,14 @@ class GitSync(NewBase):
             else:
                 expl = "unknown issue"
             out.eerror(f"No valid signature found: {expl}")
+
+            if debug:
+                writemsg_level(
+                    f"!!! Got following output from gpg: {status}\n",
+                    level=logging.DEBUG,
+                    noiselevel=-1,
+                )
+
             return False
         finally:
             if openpgp_env is not None:


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-08-17  6:59 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-08-17  6:59 UTC (permalink / raw
  To: gentoo-commits

commit:     89deda23ff5bd3feec45f5a6d70aa3b36e326068
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 17 06:59:48 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Aug 17 06:59:48 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=89deda23

sync: git: fix debugging line leftover

Fixes: 9268a92b9666eaaf263999b18220c0d56d8c476c
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 478e816370..b73b07e32a 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -420,7 +420,6 @@ class GitSync(NewBase):
         debug = "--debug" in opts
 
         openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path, debug)
-        logging.getLogger("gemato").setLevel(logging.DEBUG)
 
         if debug:
             old_level = logging.getLogger().getEffectiveLevel()


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-10-22 19:03 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-10-22 19:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c1977b8672d3af2abc5d7034fd30f35bfad76d38
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 22 08:58:42 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 22 18:59:32 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c1977b86

sync: git: fetch/clone with --verbose if verbose is enabled

Invoking git fetch/clone with --verbose shows the URL of the remote,
which is viable information. Otherwise the user may believe that they
are using a different remote then they are actually using.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1143
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 1914122d9d..24389ca02a 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -139,8 +139,12 @@ class GitSync(NewBase):
         """
         if not self.has_bin:
             return (1, False)
+
+        opts = self.options.get("emerge_config").opts
+
         git_cmd_opts = ""
         quiet = self.settings.get("PORTAGE_QUIET") == "1"
+        verbose = "--verbose" in opts
 
         # We don't want to operate with a .git outside of the given
         # repo in any circumstances.
@@ -170,6 +174,8 @@ class GitSync(NewBase):
 
         if quiet:
             git_cmd_opts += " --quiet"
+        elif verbose:
+            git_cmd_opts += " --verbose"
 
         # The logic here is a bit delicate. We need to balance two things:
         # 1. Having a robust sync mechanism which works unattended.


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-10-22 19:03 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-10-22 19:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c46fd4e6669ed49593abe4a4b3d16cbf6fc8814e
Author:     Jernej Jakob <jernej.jakob <AT> gmail <DOT> com>
AuthorDate: Sat Oct 21 22:35:26 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Oct 22 18:58:38 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=c46fd4e6

sync: git: Fix error with repositories with git config "log.showSignature" enabled

For example, emaint sync will show "No valid signature found: unknown issue".
This can be because the user has set "log.showSignature" in their git
config, which produces output that portage doesn't expect.
To prevent this, explicitly disable "log.showSignature" when calling
git.

Signed-off-by: Jernej Jakob <jernej.jakob <AT> gmail.com>
Closes: https://github.com/gentoo/portage/pull/1140
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index ead276a98d..4b11e3fa85 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -447,7 +447,15 @@ class GitSync(NewBase):
                 env = os.environ.copy()
                 env["GNUPGHOME"] = openpgp_env.home
 
-            rev_cmd = [self.bin_command, "log", "-n1", "--pretty=format:%G?", revision]
+            rev_cmd = [
+                self.bin_command,
+                "-c",
+                "log.showsignature=0",
+                "log",
+                "-n1",
+                "--pretty=format:%G?",
+                revision,
+            ]
             try:
                 status = portage._unicode_decode(
                     subprocess.check_output(


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-10-22 19:03 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-10-22 19:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c87cd3213723459e1b2957cbf0f35f3a753d11b6
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 19 09:02:49 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=c87cd321

sync/git: refactor fetch git_cmd into f-string

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1135
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index a2c96e8098..1914122d9d 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -325,11 +325,7 @@ class GitSync(NewBase):
                 elif not quiet:
                     writemsg_level(" ".join(git_set_remote_url_cmd) + "\n")
 
-        git_cmd = "{} fetch {}{}".format(
-            self.bin_command,
-            git_remote,
-            git_cmd_opts,
-        )
+        git_cmd = f"{self.bin_command} fetch {git_remote}{git_cmd_opts}"
 
         if not quiet:
             writemsg_level(git_cmd + "\n")


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-10-31  0:35 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-10-31  0:35 UTC (permalink / raw
  To: gentoo-commits

commit:     34b619eb646e8de4041268f05b04c44db9485243
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 30 18:21:45 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Oct 31 00:34:49 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=34b619eb

sync/git: invoke add_safe_directory() earlier when updating a repo

Otherwise "git rev-parse --is-shallow-repository" may fail

fatal: detected dubious ownership in repository at '/home/flo/data/repos/gentoo/tex-overlay'
To add an exception for this directory, call:
        git config --global --add safe.directory /home/flo/data/repos/gentoo/tex-overlay
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/portage/util/_async/AsyncFunction.py", line 41, in _target_wrapper
    result = target(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/portage/sync/controller.py", line 172, in sync
    taskmaster.run_tasks(tasks, func, status, options=task_opts)
  File "/usr/lib/python3.12/site-packages/portage/sync/controller.py", line 65, in run_tasks
    result = getattr(inst, func)(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/portage/sync/syncbase.py", line 370, in sync
    return self.update()
           ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/portage/sync/modules/git/git.py", line 242, in update
    subprocess.check_output(
  File "/usr/lib/python3.12/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'rev-parse', '--is-shallow-repository']' returned non-zero exit status 128.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1171
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 24389ca02a..48109b7844 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -152,6 +152,8 @@ class GitSync(NewBase):
             {"GIT_CEILING_DIRECTORIES": self._gen_ceiling_string(self.repo.location)}
         )
 
+        self.add_safe_directory()
+
         if self.repo.module_specific_options.get("sync-git-env"):
             shlexed_env = shlex_split(self.repo.module_specific_options["sync-git-env"])
             env = {
@@ -261,8 +263,6 @@ class GitSync(NewBase):
                 f" {self.repo.module_specific_options['sync-git-pull-extra-opts']}"
             )
 
-        self.add_safe_directory()
-
         try:
             remote_branch = portage._unicode_decode(
                 subprocess.check_output(


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2023-12-14  4:30 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2023-12-14  4:30 UTC (permalink / raw
  To: gentoo-commits

commit:     1339a02103f57c456851d69d427bc130bcb671bc
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 11 09:07:45 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 14 04:30:53 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=1339a021

sync: git: include signing key and git revision in log output

Include the signing key and the git revision on verficiation if
verbose output is requested or on verification error.

Before
 * Trusted signature found on top commit

After:
 * Trusted signature found on top commit (git revision: refs/remotes/origin/master, signing key: F748E9B3C47E393CC24C8FAF7C2AC09CD98F2EDF)

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1206
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 44d739ce6b..8fdbf97de0 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -500,6 +500,7 @@ class GitSync(NewBase):
         opts = self.options.get("emerge_config").opts
         debug = "--debug" in opts
         quiet = self.settings.get("PORTAGE_QUIET") == "1"
+        verbose = "--verbose" in opts
 
         openpgp_env = self._get_openpgp_env(self.repo.sync_openpgp_key_path, debug)
 
@@ -534,35 +535,48 @@ class GitSync(NewBase):
                 "log.showsignature=0",
                 "log",
                 "-n1",
-                "--pretty=format:%G?",
+                "--pretty=format:%G?%n%GF",
                 revision,
             ]
             try:
-                status = portage._unicode_decode(
+                lines = portage._unicode_decode(
                     subprocess.check_output(
                         rev_cmd,
                         cwd=portage._unicode_encode(self.repo.location),
                         env=env,
                     )
-                ).strip()
+                ).splitlines()
             except subprocess.CalledProcessError:
                 return False
 
+            status = lines[0].strip()
+            if len(lines) > 1:
+                signing_key = lines[1].strip()
+
             if status == "G":  # good signature is good
                 if not quiet:
-                    out.einfo("Trusted signature found on top commit")
+                    message = "Trusted signature found on top commit"
+                    if verbose:
+                        message += (
+                            f" (git revision: {revision}, signing key: {signing_key})"
+                        )
+                    out.einfo(message)
                 return True
             if status == "U":  # untrusted
-                out.ewarn("Top commit signature is valid but not trusted")
+                out.ewarn(
+                    f"Top commit signature is valid but not trusted (git revision: {revision}, signing key: {signing_key})"
+                )
                 return True
             if status == "B":
-                expl = "bad signature"
+                expl = (
+                    f"bad signature using key {signing_key} on git revision {revision}"
+                )
             elif status == "X":
-                expl = "expired signature"
+                expl = f"expired signature using key {signing_key} on git revision {revision}"
             elif status == "Y":
-                expl = "expired key"
+                expl = f"expired key using key {signing_key} on git revision {revision}"
             elif status == "R":
-                expl = "revoked key"
+                expl = f"revoked key using key {signing_key} on git revision {revision}"
             elif status == "E":
                 expl = "unable to verify signature (missing key?)"
             elif status == "N":


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
@ 2024-05-12 16:20 Sam James
  0 siblings, 0 replies; 21+ messages in thread
From: Sam James @ 2024-05-12 16:20 UTC (permalink / raw
  To: gentoo-commits

commit:     95b4337d376a146db8fda7717393366175cbd285
Author:     Alex Xu (Hello71) <alex_y_xu <AT> yahoo <DOT> ca>
AuthorDate: Sun May  5 20:24:52 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun May 12 16:20:02 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=95b4337d

sync: git: add safe.directory for get head commit

Closes: https://bugs.gentoo.org/930992
Fixes: 1339a02103 ("sync: git: include signing key and git revision in log output")
Signed-off-by: Alex Xu (Hello71) <alex_y_xu <AT> yahoo.ca>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/sync/modules/git/git.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
index 8fdbf97de0..a2830280fb 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -606,6 +606,7 @@ class GitSync(NewBase):
         if self.bin_command is None:
             # return quietly so that we don't pollute emerge --info output
             return (1, False)
+        self.add_safe_directory()
         rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
         try:
             ret = (


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-05-12 16:20 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-23 19:58 [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/ Zac Medico
  -- strict thread matches above, loose matches on Subject: below --
2024-05-12 16:20 Sam James
2023-12-14  4:30 Sam James
2023-10-31  0:35 Sam James
2023-10-22 19:03 Sam James
2023-10-22 19:03 Sam James
2023-10-22 19:03 Sam James
2023-08-17  6:59 Sam James
2023-08-17  6:53 Sam James
2023-02-27  6:15 Sam James
2023-02-25 23:22 Sam James
2023-02-24  9:22 Sam James
2023-02-24  9:22 Sam James
2023-02-24  9:22 Sam James
2022-12-21  1:28 Sam James
2022-12-21  1:28 Sam James
2022-12-21  1:28 Sam James
2022-11-20  3:12 Sam James
2022-07-03  0:56 Mike Gilbert
2020-07-02 22:08 Zac Medico
2018-07-23 18:52 Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox