commit:     9921cfeb51ab8d9dc128aa5e927d29fc675b28b4
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  7 20:43:59 2015 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Nov  7 21:27:01 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9921cfeb

GitSync: skip metadata-transfer when appropriate (bug 564988)

Set updatecache_flg to False if the git revision is unchanged.

X-Gentoo-Bug: 564988
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=564988
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/pym/portage/sync/modules/git/git.py 
b/pym/portage/sync/modules/git/git.py
index c14782c..179c0de 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -2,6 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import logging
+import subprocess
 
 import portage
 from portage import os
@@ -81,6 +82,10 @@ class GitSync(NewBase):
                git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts)
                writemsg_level(git_cmd + "\n")
 
+               rev_cmd = [self.bin_command, "rev-list", "--max-count=1", 
"HEAD"]
+               previous_rev = subprocess.check_output(rev_cmd,
+                       cwd=portage._unicode_encode(self.repo.location))
+
                exitcode = portage.process.spawn_bash("cd %s ; exec %s" % (
                                portage._shell_quote(self.repo.location), 
git_cmd),
                        **portage._native_kwargs(self.spawn_kwargs))
@@ -89,4 +94,8 @@ class GitSync(NewBase):
                        self.logger(self.xterm_titles, msg)
                        writemsg_level(msg + "\n", level=logging.ERROR, 
noiselevel=-1)
                        return (exitcode, False)
-               return (os.EX_OK, True)
+
+               current_rev = subprocess.check_output(rev_cmd,
+                       cwd=portage._unicode_encode(self.repo.location))
+
+               return (os.EX_OK, current_rev != previous_rev)

Reply via email to