* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/git/
@ 2014-12-04 20:04 Brian Dolbec
2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec
0 siblings, 1 reply; 21+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:04 UTC (permalink / raw
To: gentoo-commits
commit: 932fa3f8295dcfb0bdbf3762161940d44d19d395
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 21 01:13:45 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=932fa3f8
Remove obsolete git_sync_timestamps function.
This function is no longer needed since we switched to the md5-cache
format which does not use timestamps.
---
pym/portage/sync/modules/git/git.py | 8 +-
pym/portage/sync/modules/git/timestamps.py | 154 -----------------------------
2 files changed, 1 insertion(+), 161 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 5e0e5df..d8c5a32 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -10,7 +10,6 @@ from portage.output import create_color_func
good = create_color_func("GOOD")
bad = create_color_func("BAD")
warn = create_color_func("WARN")
-from .timestamps import git_sync_timestamps
from portage.sync.syncbase import SyncBase
@@ -116,9 +115,4 @@ class GitSync(SyncBase):
# Reload the whole config from scratch.
settings, trees, mtimedb = load_emerge_config(emerge_config=emerge_config)
adjust_configs(emerge_config.opts, emerge_config.trees)
- portdb = trees[settings['EROOT']]['porttree'].dbapi
- updatecache_flg = False
- exitcode = git_sync_timestamps(portdb, location)
- if exitcode == os.EX_OK:
- updatecache_flg = True
- return (exitcode, updatecache_flg)
+ return (os.EX_OK, True)
diff --git a/pym/portage/sync/modules/git/timestamps.py b/pym/portage/sync/modules/git/timestamps.py
deleted file mode 100644
index 5e44845..0000000
--- a/pym/portage/sync/modules/git/timestamps.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-import logging
-import stat
-import subprocess
-
-
-import portage
-from portage import os
-from portage import _unicode_decode
-from portage.util import writemsg_level
-from portage.cache.cache_errors import CacheError
-
-
-def git_sync_timestamps(portdb, portdir):
- """
- Since git doesn't preserve timestamps, synchronize timestamps between
- entries and ebuilds/eclasses. Assume the cache has the correct timestamp
- for a given file as long as the file in the working tree is not modified
- (relative to HEAD).
- """
-
- cache_db = portdb._pregen_auxdb.get(portdir)
-
- try:
- if cache_db is None:
- # portdbapi does not populate _pregen_auxdb
- # when FEATURES=metadata-transfer is enabled
- cache_db = portdb._create_pregen_cache(portdir)
- except CacheError as e:
- writemsg_level("!!! Unable to instantiate cache: %s\n" % (e,),
- level=logging.ERROR, noiselevel=-1)
- return 1
-
- if cache_db is None:
- return os.EX_OK
-
- if cache_db.validation_chf != 'mtime':
- # newer formats like md5-dict do not require mtime sync
- return os.EX_OK
-
- writemsg_level(">>> Synchronizing timestamps...\n")
-
- ec_dir = os.path.join(portdir, "eclass")
- try:
- ec_names = set(f[:-7] for f in os.listdir(ec_dir) \
- if f.endswith(".eclass"))
- except OSError as e:
- writemsg_level("!!! Unable to list eclasses: %s\n" % (e,),
- level=logging.ERROR, noiselevel=-1)
- return 1
-
- args = [portage.const.BASH_BINARY, "-c",
- "cd %s && git diff-index --name-only --diff-filter=M HEAD" % \
- portage._shell_quote(portdir)]
- proc = subprocess.Popen(args, stdout=subprocess.PIPE)
- modified_files = set(_unicode_decode(l).rstrip("\n") for l in proc.stdout)
- rval = proc.wait()
- proc.stdout.close()
- if rval != os.EX_OK:
- return rval
-
- modified_eclasses = set(ec for ec in ec_names \
- if os.path.join("eclass", ec + ".eclass") in modified_files)
-
- updated_ec_mtimes = {}
-
- for cpv in cache_db:
- cpv_split = portage.catpkgsplit(cpv)
- if cpv_split is None:
- writemsg_level("!!! Invalid cache entry: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
-
- cat, pn, ver, rev = cpv_split
- cat, pf = portage.catsplit(cpv)
- relative_eb_path = os.path.join(cat, pn, pf + ".ebuild")
- if relative_eb_path in modified_files:
- continue
-
- try:
- cache_entry = cache_db[cpv]
- eb_mtime = cache_entry.get("_mtime_")
- ec_mtimes = cache_entry.get("_eclasses_")
- except KeyError:
- writemsg_level("!!! Missing cache entry: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
- except CacheError as e:
- writemsg_level("!!! Unable to access cache entry: %s %s\n" % \
- (cpv, e), level=logging.ERROR, noiselevel=-1)
- continue
-
- if eb_mtime is None:
- writemsg_level("!!! Missing ebuild mtime: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
-
- try:
- eb_mtime = long(eb_mtime)
- except ValueError:
- writemsg_level("!!! Invalid ebuild mtime: %s %s\n" % \
- (cpv, eb_mtime), level=logging.ERROR, noiselevel=-1)
- continue
-
- if ec_mtimes is None:
- writemsg_level("!!! Missing eclass mtimes: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
-
- if modified_eclasses.intersection(ec_mtimes):
- continue
-
- missing_eclasses = set(ec_mtimes).difference(ec_names)
- if missing_eclasses:
- writemsg_level("!!! Non-existent eclass(es): %s %s\n" % \
- (cpv, sorted(missing_eclasses)), level=logging.ERROR,
- noiselevel=-1)
- continue
-
- eb_path = os.path.join(portdir, relative_eb_path)
- try:
- current_eb_mtime = os.stat(eb_path)
- except OSError:
- writemsg_level("!!! Missing ebuild: %s\n" % \
- (cpv,), level=logging.ERROR, noiselevel=-1)
- continue
-
- inconsistent = False
- for ec, (ec_path, ec_mtime) in ec_mtimes.items():
- updated_mtime = updated_ec_mtimes.get(ec)
- if updated_mtime is not None and updated_mtime != ec_mtime:
- writemsg_level("!!! Inconsistent eclass mtime: %s %s\n" % \
- (cpv, ec), level=logging.ERROR, noiselevel=-1)
- inconsistent = True
- break
-
- if inconsistent:
- continue
-
- if current_eb_mtime != eb_mtime:
- os.utime(eb_path, (eb_mtime, eb_mtime))
-
- for ec, (ec_path, ec_mtime) in ec_mtimes.items():
- if ec in updated_ec_mtimes:
- continue
- ec_path = os.path.join(ec_dir, ec + ".eclass")
- current_mtime = os.stat(ec_path)[stat.ST_MTIME]
- if current_mtime != ec_mtime:
- os.utime(ec_path, (ec_mtime, ec_mtime))
- updated_ec_mtimes[ec] = ec_mtime
-
- return os.EX_OK
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/git/ Brian Dolbec
@ 2014-12-04 20:16 ` Brian Dolbec
0 siblings, 0 replies; 21+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:16 UTC (permalink / raw
To: gentoo-commits
commit: 932fa3f8295dcfb0bdbf3762161940d44d19d395
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 21 01:13:45 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=932fa3f8
Remove obsolete git_sync_timestamps function.
This function is no longer needed since we switched to the md5-cache
format which does not use timestamps.
---
pym/portage/sync/modules/git/git.py | 8 +-
pym/portage/sync/modules/git/timestamps.py | 154 -----------------------------
2 files changed, 1 insertion(+), 161 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 5e0e5df..d8c5a32 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -10,7 +10,6 @@ from portage.output import create_color_func
good = create_color_func("GOOD")
bad = create_color_func("BAD")
warn = create_color_func("WARN")
-from .timestamps import git_sync_timestamps
from portage.sync.syncbase import SyncBase
@@ -116,9 +115,4 @@ class GitSync(SyncBase):
# Reload the whole config from scratch.
settings, trees, mtimedb = load_emerge_config(emerge_config=emerge_config)
adjust_configs(emerge_config.opts, emerge_config.trees)
- portdb = trees[settings['EROOT']]['porttree'].dbapi
- updatecache_flg = False
- exitcode = git_sync_timestamps(portdb, location)
- if exitcode == os.EX_OK:
- updatecache_flg = True
- return (exitcode, updatecache_flg)
+ return (os.EX_OK, True)
diff --git a/pym/portage/sync/modules/git/timestamps.py b/pym/portage/sync/modules/git/timestamps.py
deleted file mode 100644
index 5e44845..0000000
--- a/pym/portage/sync/modules/git/timestamps.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-import logging
-import stat
-import subprocess
-
-
-import portage
-from portage import os
-from portage import _unicode_decode
-from portage.util import writemsg_level
-from portage.cache.cache_errors import CacheError
-
-
-def git_sync_timestamps(portdb, portdir):
- """
- Since git doesn't preserve timestamps, synchronize timestamps between
- entries and ebuilds/eclasses. Assume the cache has the correct timestamp
- for a given file as long as the file in the working tree is not modified
- (relative to HEAD).
- """
-
- cache_db = portdb._pregen_auxdb.get(portdir)
-
- try:
- if cache_db is None:
- # portdbapi does not populate _pregen_auxdb
- # when FEATURES=metadata-transfer is enabled
- cache_db = portdb._create_pregen_cache(portdir)
- except CacheError as e:
- writemsg_level("!!! Unable to instantiate cache: %s\n" % (e,),
- level=logging.ERROR, noiselevel=-1)
- return 1
-
- if cache_db is None:
- return os.EX_OK
-
- if cache_db.validation_chf != 'mtime':
- # newer formats like md5-dict do not require mtime sync
- return os.EX_OK
-
- writemsg_level(">>> Synchronizing timestamps...\n")
-
- ec_dir = os.path.join(portdir, "eclass")
- try:
- ec_names = set(f[:-7] for f in os.listdir(ec_dir) \
- if f.endswith(".eclass"))
- except OSError as e:
- writemsg_level("!!! Unable to list eclasses: %s\n" % (e,),
- level=logging.ERROR, noiselevel=-1)
- return 1
-
- args = [portage.const.BASH_BINARY, "-c",
- "cd %s && git diff-index --name-only --diff-filter=M HEAD" % \
- portage._shell_quote(portdir)]
- proc = subprocess.Popen(args, stdout=subprocess.PIPE)
- modified_files = set(_unicode_decode(l).rstrip("\n") for l in proc.stdout)
- rval = proc.wait()
- proc.stdout.close()
- if rval != os.EX_OK:
- return rval
-
- modified_eclasses = set(ec for ec in ec_names \
- if os.path.join("eclass", ec + ".eclass") in modified_files)
-
- updated_ec_mtimes = {}
-
- for cpv in cache_db:
- cpv_split = portage.catpkgsplit(cpv)
- if cpv_split is None:
- writemsg_level("!!! Invalid cache entry: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
-
- cat, pn, ver, rev = cpv_split
- cat, pf = portage.catsplit(cpv)
- relative_eb_path = os.path.join(cat, pn, pf + ".ebuild")
- if relative_eb_path in modified_files:
- continue
-
- try:
- cache_entry = cache_db[cpv]
- eb_mtime = cache_entry.get("_mtime_")
- ec_mtimes = cache_entry.get("_eclasses_")
- except KeyError:
- writemsg_level("!!! Missing cache entry: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
- except CacheError as e:
- writemsg_level("!!! Unable to access cache entry: %s %s\n" % \
- (cpv, e), level=logging.ERROR, noiselevel=-1)
- continue
-
- if eb_mtime is None:
- writemsg_level("!!! Missing ebuild mtime: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
-
- try:
- eb_mtime = long(eb_mtime)
- except ValueError:
- writemsg_level("!!! Invalid ebuild mtime: %s %s\n" % \
- (cpv, eb_mtime), level=logging.ERROR, noiselevel=-1)
- continue
-
- if ec_mtimes is None:
- writemsg_level("!!! Missing eclass mtimes: %s\n" % (cpv,),
- level=logging.ERROR, noiselevel=-1)
- continue
-
- if modified_eclasses.intersection(ec_mtimes):
- continue
-
- missing_eclasses = set(ec_mtimes).difference(ec_names)
- if missing_eclasses:
- writemsg_level("!!! Non-existent eclass(es): %s %s\n" % \
- (cpv, sorted(missing_eclasses)), level=logging.ERROR,
- noiselevel=-1)
- continue
-
- eb_path = os.path.join(portdir, relative_eb_path)
- try:
- current_eb_mtime = os.stat(eb_path)
- except OSError:
- writemsg_level("!!! Missing ebuild: %s\n" % \
- (cpv,), level=logging.ERROR, noiselevel=-1)
- continue
-
- inconsistent = False
- for ec, (ec_path, ec_mtime) in ec_mtimes.items():
- updated_mtime = updated_ec_mtimes.get(ec)
- if updated_mtime is not None and updated_mtime != ec_mtime:
- writemsg_level("!!! Inconsistent eclass mtime: %s %s\n" % \
- (cpv, ec), level=logging.ERROR, noiselevel=-1)
- inconsistent = True
- break
-
- if inconsistent:
- continue
-
- if current_eb_mtime != eb_mtime:
- os.utime(eb_path, (eb_mtime, eb_mtime))
-
- for ec, (ec_path, ec_mtime) in ec_mtimes.items():
- if ec in updated_ec_mtimes:
- continue
- ec_path = os.path.join(ec_dir, ec + ".eclass")
- current_mtime = os.stat(ec_path)[stat.ST_MTIME]
- if current_mtime != ec_mtime:
- os.utime(ec_path, (ec_mtime, ec_mtime))
- updated_ec_mtimes[ec] = ec_mtime
-
- return os.EX_OK
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2014-12-04 20:16 Brian Dolbec
0 siblings, 0 replies; 21+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:16 UTC (permalink / raw
To: gentoo-commits
commit: 4514e80a40525dd87d84381e8869a5cd78b3f454
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 21 01:49:35 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4514e80a
git sync: remove unneeded post_sync
None of the remaining post_sync code is really needed. Also, fix
indent of return near the end of the _sync method.
---
pym/portage/sync/modules/git/git.py | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index d8c5a32..7c28139 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -69,11 +69,11 @@ class GitSync(SyncBase):
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)
+ return (exitcode, False)
msg = ">>> Git clone successful"
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n")
- return self.post_sync(portdb, self.repo.location, emerge_config)
+ return (os.EX_OK, True)
def _sync(self):
@@ -101,18 +101,4 @@ class GitSync(SyncBase):
msg = ">>> Git pull successful: %s" % self.repo.location
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n")
- return self.post_sync(portdb, self.repo.location, emerge_config)
-
-
- def post_sync(self, portdb, location, emerge_config):
- '''repo.sync_type == "git":
- # NOTE: Do this after reloading the config, in case
- # it did not exist prior to sync, so that the config
- # and portdb properly account for its existence.
- '''
- # avoid circular import for now
- from _emerge.actions import load_emerge_config, adjust_configs
- # Reload the whole config from scratch.
- settings, trees, mtimedb = load_emerge_config(emerge_config=emerge_config)
- adjust_configs(emerge_config.opts, emerge_config.trees)
return (os.EX_OK, True)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec
@ 2014-12-04 20:16 ` Brian Dolbec
0 siblings, 0 replies; 21+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:16 UTC (permalink / raw
To: gentoo-commits
commit: 92c612d743907c89532247298f95cc64d956548a
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 22 11:01:03 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=92c612d7
GitSync: support file:// sync-uri
This will be useful for unit tests that will sync from a local
file:// sync-uri.
---
pym/portage/sync/modules/git/git.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 7c28139..35943dd 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -60,10 +60,13 @@ class GitSync(SyncBase):
msg = ">>> Cloning git repository from upstream into %s..." % self.repo.location
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n")
+ sync_uri = self.repo.sync_uri
+ if sync_uri.startswith("file://"):
+ sync_uri = sync_uri[6:]
exitcode = portage.process.spawn_bash("cd %s ; %s clone %s ." % \
(portage._shell_quote(self.repo.location),
self.bin_command,
- portage._shell_quote(self.repo.sync_uri)),
+ portage._shell_quote(sync_uri)),
**portage._native_kwargs(self.spawn_kwargs))
if exitcode != os.EX_OK:
msg = "!!! git clone error in %s" % self.repo.location
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2015-01-18 18:04 Michał Górny
0 siblings, 0 replies; 21+ messages in thread
From: Michał Górny @ 2015-01-18 18:04 UTC (permalink / raw
To: gentoo-commits
commit: 8c4e4facd64d48653d348749982615d78a2fbb77
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 17 12:24:11 2015 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jan 18 18:04:25 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8c4e4fac
git sync: replace 'git rev-parse' with safer '.git' check
The 'git rev-parse' could succeed if one of the parent directories
contained a git repository, and it also had unwanted error output.
Instead, just check whether the '.git' directory exists.
---
pym/portage/sync/modules/git/git.py | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index d4f2cc1..c5c569e 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -29,19 +29,7 @@ class GitSync(SyncBase):
def exists(self, **kwargs):
'''Tests whether the repo actually exists'''
- if kwargs:
- self._kwargs(kwargs)
- elif not self.repo:
- return False
-
- if not os.path.exists(self.repo.location):
- return False
- exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\
- (portage._shell_quote(self.repo.location),),
- **portage._native_kwargs(self.spawn_kwargs))
- if exitcode == 128:
- return False
- return True
+ return os.path.exists(os.path.join(self.repo.location, '.git'))
def new(self, **kwargs):
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2015-09-04 17:27 Brian Dolbec
0 siblings, 0 replies; 21+ messages in thread
From: Brian Dolbec @ 2015-09-04 17:27 UTC (permalink / raw
To: gentoo-commits
commit: 3346d3c1c1f6c2702d7d0d347370bee816a82c2f
Author: Consus <consus <AT> gmx <DOT> com>
AuthorDate: Fri Sep 4 10:20:27 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Sep 4 17:25:24 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3346d3c1
git sync: Respect PORTAGE_QUIET
Execute `git clone --quiet' and `git pull --quiet' when appropriate.
pym/portage/sync/modules/git/git.py | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 7a710ef..c14782c 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -1,4 +1,4 @@
-# Copyright 2005-2014 Gentoo Foundation
+# Copyright 2005-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
import logging
@@ -43,15 +43,18 @@ class GitSync(NewBase):
'Created new directory %s' % self.repo.location)
except IOError:
return (1, False)
+
sync_uri = self.repo.sync_uri
if sync_uri.startswith("file://"):
sync_uri = sync_uri[6:]
- depth_arg = ''
- if self.repo.sync_depth is not None:
- depth_arg = '--depth %d ' % self.repo.sync_depth
- git_cmd = "%s clone %s%s ." % (self.bin_command, depth_arg,
- portage._shell_quote(sync_uri))
+ git_cmd_opts = ""
+ if self.settings.get("PORTAGE_QUIET") == "1":
+ git_cmd_opts += " --quiet"
+ if self.repo.sync_depth is not None:
+ git_cmd_opts += " --depth %d" % self.repo.sync_depth
+ git_cmd = "%s clone%s %s ." % (self.bin_command, git_cmd_opts,
+ portage._shell_quote(sync_uri))
writemsg_level(git_cmd + "\n")
exitcode = portage.process.spawn_bash("cd %s ; exec %s" % (
@@ -72,7 +75,10 @@ class GitSync(NewBase):
git directly.
'''
- git_cmd = "%s pull" % self.bin_command
+ git_cmd_opts = ""
+ if self.settings.get("PORTAGE_QUIET") == "1":
+ git_cmd_opts += " --quiet"
+ git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts)
writemsg_level(git_cmd + "\n")
exitcode = portage.process.spawn_bash("cd %s ; exec %s" % (
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2015-11-07 21:28 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2015-11-07 21:28 UTC (permalink / raw
To: gentoo-commits
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)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2016-07-14 18:41 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2016-07-14 18:41 UTC (permalink / raw
To: gentoo-commits
commit: 84413bb1dd9df322568ce25efc5b7854a43d03c7
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 08:23:46 2016 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 18:31:34 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=84413bb1
GitSync.update: respect sync-depth (bug 552814)
Fix updates to respect sync-depth (previously it was only respected
for clone operations). Since the default merge strategy typically
fails when the the depth is not unlimited, use `git fetch` followed
by `git reset --hard`.
X-Gentoo-Bug: 552814
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=552814
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/portage/sync/modules/git/git.py | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 02eeb16..09257f3 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -79,11 +79,26 @@ class GitSync(NewBase):
'''
git_cmd_opts = ""
- if self.settings.get("PORTAGE_QUIET") == "1":
+ quiet = self.settings.get("PORTAGE_QUIET") == "1"
+ if quiet:
git_cmd_opts += " --quiet"
if self.repo.module_specific_options.get('sync-git-pull-extra-opts'):
git_cmd_opts += " %s" % self.repo.module_specific_options['sync-git-pull-extra-opts']
- git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts)
+ if self.repo.sync_depth is None:
+ git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts)
+ else:
+ # Since the default merge strategy typically fails when
+ # the depth is not unlimited, use `git fetch` followed by
+ # `git reset --hard`.
+ remote_branch = portage._unicode_decode(
+ subprocess.check_output([self.bin_command, 'rev-parse',
+ '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
+ cwd=portage._unicode_encode(self.repo.location))).rstrip('\n')
+
+ git_cmd_opts += " --depth %d" % self.repo.sync_depth
+ git_cmd = "%s fetch %s%s" % (self.bin_command,
+ remote_branch.partition('/')[0], git_cmd_opts)
+
writemsg_level(git_cmd + "\n")
rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
@@ -93,6 +108,14 @@ class GitSync(NewBase):
exitcode = portage.process.spawn_bash("cd %s ; exec %s" % (
portage._shell_quote(self.repo.location), git_cmd),
**self.spawn_kwargs)
+
+ if exitcode == os.EX_OK and self.repo.sync_depth is not None:
+ reset_cmd = [self.bin_command, 'reset', '--hard', remote_branch]
+ if quiet:
+ reset_cmd.append('--quiet')
+ exitcode = subprocess.call(reset_cmd,
+ cwd=portage._unicode_encode(self.repo.location))
+
if exitcode != os.EX_OK:
msg = "!!! git pull error in %s" % self.repo.location
self.logger(self.xterm_titles, msg)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2016-07-18 16:32 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2016-07-18 16:32 UTC (permalink / raw
To: gentoo-commits
commit: 55aef9bf297ef8cbf29921acb454449d01313818
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 18 15:48:35 2016 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jul 18 15:52:42 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=55aef9bf
GitSync.update: use git reset --merge instead of --hard (bug 552814)
Since `git reset --merge` gives the closest behavior to `git pull`,
use it instead of `-git reset --hard`. This will provide the following
advantages:
* git will not have to stat files that have not changed since the
previous sync, which will allow for optimal performance
* git will abort if there are unstaged local changes to any files that
have changed since the previous sync
Suggested-by: Michał Górny <mgorny <AT> gentoo.org>
Fixes 84413bb1dd9d ("GitSync.update: respect sync-depth (bug 552814)")
pym/portage/sync/modules/git/git.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 09257f3..c1028ab 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -89,7 +89,7 @@ class GitSync(NewBase):
else:
# Since the default merge strategy typically fails when
# the depth is not unlimited, use `git fetch` followed by
- # `git reset --hard`.
+ # `git reset --merge`.
remote_branch = portage._unicode_decode(
subprocess.check_output([self.bin_command, 'rev-parse',
'--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
@@ -110,7 +110,7 @@ class GitSync(NewBase):
**self.spawn_kwargs)
if exitcode == os.EX_OK and self.repo.sync_depth is not None:
- reset_cmd = [self.bin_command, 'reset', '--hard', remote_branch]
+ reset_cmd = [self.bin_command, 'reset', '--merge', remote_branch]
if quiet:
reset_cmd.append('--quiet')
exitcode = subprocess.call(reset_cmd,
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2016-09-22 21:45 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2016-09-22 21:45 UTC (permalink / raw
To: gentoo-commits
commit: f5d258656de3db54af06fbca9b8da5217d3802f4
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 22 21:11:35 2016 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Sep 22 21:45:10 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f5d25865
GitSync.update: handle git rev-list failure (bug 594822)
Fixes: 84413bb1dd9d ("GitSync.update: respect sync-depth (bug 552814)")
X-Gentoo-bug: 594822
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=594822
pym/portage/sync/modules/git/git.py | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index c1028ab..3734b80 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -90,10 +90,16 @@ class GitSync(NewBase):
# Since the default merge strategy typically fails when
# the depth is not unlimited, use `git fetch` followed by
# `git reset --merge`.
- remote_branch = portage._unicode_decode(
- subprocess.check_output([self.bin_command, 'rev-parse',
- '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
- cwd=portage._unicode_encode(self.repo.location))).rstrip('\n')
+ try:
+ remote_branch = portage._unicode_decode(
+ subprocess.check_output([self.bin_command, 'rev-parse',
+ '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
+ cwd=portage._unicode_encode(self.repo.location))).rstrip('\n')
+ except subprocess.CalledProcessError as e:
+ msg = "!!! git rev-parse error in %s" % self.repo.location
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+ return (e.returncode, False)
git_cmd_opts += " --depth %d" % self.repo.sync_depth
git_cmd = "%s fetch %s%s" % (self.bin_command,
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2016-10-30 21:23 Michał Górny
0 siblings, 0 replies; 21+ messages in thread
From: Michał Górny @ 2016-10-30 21:23 UTC (permalink / raw
To: gentoo-commits
commit: f77fcd6b0b4ebb49ca62f5767cd5c931127c3dbb
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 30 19:14:11 2016 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Oct 30 21:23:30 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f77fcd6b
[sync] Run `git update-index --refresh` when doing shallow pulls
Run `git update-index --refresh` to force proper index recheck before
running `git reset --merge` on a shallow pull. This fixes syncing on
some filesystem configurations including overlayfs on squashfs.
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
pym/portage/sync/modules/git/git.py | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 3734b80..dc94ec9 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -89,7 +89,7 @@ class GitSync(NewBase):
else:
# Since the default merge strategy typically fails when
# the depth is not unlimited, use `git fetch` followed by
- # `git reset --merge`.
+ # `git update-index --refresh`, then `git reset --merge`.
try:
remote_branch = portage._unicode_decode(
subprocess.check_output([self.bin_command, 'rev-parse',
@@ -116,12 +116,23 @@ class GitSync(NewBase):
**self.spawn_kwargs)
if exitcode == os.EX_OK and self.repo.sync_depth is not None:
- reset_cmd = [self.bin_command, 'reset', '--merge', remote_branch]
- if quiet:
- reset_cmd.append('--quiet')
- exitcode = subprocess.call(reset_cmd,
+ # update-index --refresh is needed on some filesystems
+ # (e.g. with overlayfs on squashfs)
+ update_index_cmd = [self.bin_command, 'update-index']
+ if quiet: # -q needs to go first
+ update_index_cmd.append('-q')
+ update_index_cmd.append('--refresh')
+
+ exitcode = subprocess.call(update_index_cmd,
cwd=portage._unicode_encode(self.repo.location))
+ if exitcode == os.EX_OK:
+ reset_cmd = [self.bin_command, 'reset', '--merge', remote_branch]
+ if quiet:
+ reset_cmd.append('--quiet')
+ exitcode = subprocess.call(reset_cmd,
+ cwd=portage._unicode_encode(self.repo.location))
+
if exitcode != os.EX_OK:
msg = "!!! git pull error in %s" % self.repo.location
self.logger(self.xterm_titles, msg)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2016-11-03 20:05 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2016-11-03 20:05 UTC (permalink / raw
To: gentoo-commits
commit: d075422a8902617833ec945d94beb0bb334d44c9
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 3 19:22:31 2016 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu Nov 3 20:04:35 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d075422a
sync: always pass -q --unmerged to git-update-index
Passing -q --unmerged prevents update-index from erroring out when local
file changes are present.
From git-update-index(1):
-q
Quiet. If --refresh finds that the index needs an update, the
default behavior is to error out. This option makes git
update-index continue anyway.
--unmerged
If --refresh finds unmerged changes in the index, the default
behavior is to error out. This option makes git update-index
continue anyway.
X-Gentoo-Bug-URL: https://bugs.gentoo.org/552814#c58
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
pym/portage/sync/modules/git/git.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index dc94ec9..f288733 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -118,10 +118,7 @@ class GitSync(NewBase):
if exitcode == os.EX_OK and self.repo.sync_depth is not None:
# update-index --refresh is needed on some filesystems
# (e.g. with overlayfs on squashfs)
- update_index_cmd = [self.bin_command, 'update-index']
- if quiet: # -q needs to go first
- update_index_cmd.append('-q')
- update_index_cmd.append('--refresh')
+ update_index_cmd = [self.bin_command, 'update-index', '-q', '--unmerged', '--refresh']
exitcode = subprocess.call(update_index_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: pym/portage/sync/modules/git/
@ 2016-11-07 22:16 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2016-11-07 22:16 UTC (permalink / raw
To: gentoo-commits
commit: ab840ac982d3c8b676b89f6bedd14e85dd06870f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 7 22:03:40 2016 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Nov 7 22:03:46 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ab840ac9
Revert "GitSync.update: respect sync-depth (bug 552814)"
This reverts commit 84413bb1dd9df322568ce25efc5b7854a43d03c7, and
all of the related commits that followed:
d075422a89 sync: always pass -q --unmerged to git-update-index
f77fcd6b0b [sync] Run `git update-index --refresh` when doing shallow pulls
f5d258656d GitSync.update: handle git rev-list failure (bug 594822)
55aef9bf29 GitSync.update: use git reset --merge instead of --hard (bug 552814)
Shallow fetch is not a practical default at this time, given performance
issues introduced by `git update-index` and `git prune` (see bug 599008).
X-Gentoo-Bug: 552814
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=552814
pym/portage/sync/modules/git/git.py | 41 ++-----------------------------------
1 file changed, 2 insertions(+), 39 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index f288733..02eeb16 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -79,32 +79,11 @@ class GitSync(NewBase):
'''
git_cmd_opts = ""
- quiet = self.settings.get("PORTAGE_QUIET") == "1"
- if quiet:
+ if self.settings.get("PORTAGE_QUIET") == "1":
git_cmd_opts += " --quiet"
if self.repo.module_specific_options.get('sync-git-pull-extra-opts'):
git_cmd_opts += " %s" % self.repo.module_specific_options['sync-git-pull-extra-opts']
- if self.repo.sync_depth is None:
- git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts)
- else:
- # Since the default merge strategy typically fails when
- # the depth is not unlimited, use `git fetch` followed by
- # `git update-index --refresh`, then `git reset --merge`.
- try:
- remote_branch = portage._unicode_decode(
- subprocess.check_output([self.bin_command, 'rev-parse',
- '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
- cwd=portage._unicode_encode(self.repo.location))).rstrip('\n')
- except subprocess.CalledProcessError as e:
- msg = "!!! git rev-parse error in %s" % self.repo.location
- self.logger(self.xterm_titles, msg)
- writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
- return (e.returncode, False)
-
- git_cmd_opts += " --depth %d" % self.repo.sync_depth
- git_cmd = "%s fetch %s%s" % (self.bin_command,
- remote_branch.partition('/')[0], git_cmd_opts)
-
+ 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"]
@@ -114,22 +93,6 @@ class GitSync(NewBase):
exitcode = portage.process.spawn_bash("cd %s ; exec %s" % (
portage._shell_quote(self.repo.location), git_cmd),
**self.spawn_kwargs)
-
- if exitcode == os.EX_OK and self.repo.sync_depth is not None:
- # update-index --refresh is needed on some filesystems
- # (e.g. with overlayfs on squashfs)
- update_index_cmd = [self.bin_command, 'update-index', '-q', '--unmerged', '--refresh']
-
- exitcode = subprocess.call(update_index_cmd,
- cwd=portage._unicode_encode(self.repo.location))
-
- if exitcode == os.EX_OK:
- reset_cmd = [self.bin_command, 'reset', '--merge', remote_branch]
- if quiet:
- reset_cmd.append('--quiet')
- exitcode = subprocess.call(reset_cmd,
- cwd=portage._unicode_encode(self.repo.location))
-
if exitcode != os.EX_OK:
msg = "!!! git pull error in %s" % self.repo.location
self.logger(self.xterm_titles, msg)
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2017-02-25 0:25 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2017-02-25 0:25 UTC (permalink / raw
To: gentoo-commits
commit: 58e8b280794af7396115ea76747f0cc5fc5ab013
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 24 23:56:32 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 25 00:01:10 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=58e8b280
GitSync: fix spurious "sync-depth is deprecated" messages (bug 610708)
The CheckGitConfig._check_depth method must not set the sync_depth
attribute, or else it will trigger "sync-depth is deprecated" messages.
Fixes: b3f6297a791a ("repos.conf: rename sync-depth option to clone-depth")
X-Gentoo-Bug: 610708
X-Gentoo-Bug-Url: https://bugs.gentoo.org/show_bug.cgi?id=610708
pym/portage/sync/modules/git/__init__.py | 4 ----
pym/portage/sync/modules/git/git.py | 9 +++++++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/pym/portage/sync/modules/git/__init__.py b/pym/portage/sync/modules/git/__init__.py
index 2df60e37f..60b7395b8 100644
--- a/pym/portage/sync/modules/git/__init__.py
+++ b/pym/portage/sync/modules/git/__init__.py
@@ -21,8 +21,6 @@ class CheckGitConfig(CheckSyncConfig):
def _check_depth(self, attr):
d = getattr(self.repo, attr)
- # default
- setattr(self.repo, attr, 1)
if d is not None:
try:
@@ -33,8 +31,6 @@ class CheckGitConfig(CheckSyncConfig):
% (attr.replace('_', '-'), d),
level=self.logger.ERROR, noiselevel=-1)
else:
- if d == 0:
- d = None
setattr(self.repo, attr, d)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index d5400d53a..d432886dd 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -53,9 +53,14 @@ class GitSync(NewBase):
if self.settings.get("PORTAGE_QUIET") == "1":
git_cmd_opts += " --quiet"
if self.repo.clone_depth is not None:
- git_cmd_opts += " --depth %d" % self.repo.clone_depth
+ if self.repo.clone_depth != 0:
+ git_cmd_opts += " --depth %d" % self.repo.clone_depth
elif self.repo.sync_depth is not None:
- git_cmd_opts += " --depth %d" % self.repo.sync_depth
+ if self.repo.sync_depth != 0:
+ git_cmd_opts += " --depth %d" % self.repo.sync_depth
+ else:
+ # default
+ git_cmd_opts += " --depth 1"
if self.repo.module_specific_options.get('sync-git-clone-extra-opts'):
git_cmd_opts += " %s" % self.repo.module_specific_options['sync-git-clone-extra-opts']
git_cmd = "%s clone%s %s ." % (self.bin_command, git_cmd_opts,
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2017-08-09 20:39 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2017-08-09 20:39 UTC (permalink / raw
To: gentoo-commits
commit: 540b97e416371c03e681625dd02a8f0eb371e9ab
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 9 20:38:08 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Aug 9 20:39:26 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=540b97e4
GitSync: fix subprocess.CalledProcessError reference (bug 627416)
Fixes: 0e1699ad6b3f ("emerge: Add head commit per repo to --info")
pym/portage/sync/modules/git/git.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 8df9ca612..19c167485 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -139,6 +139,6 @@ class GitSync(NewBase):
try:
ret = (os.EX_OK, subprocess.check_output(rev_cmd,
cwd=portage._unicode_encode(self.repo.location)))
- except CalledProcessError:
+ except subprocess.CalledProcessError:
ret = (1, False)
return ret
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2017-08-09 20:56 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2017-08-09 20:56 UTC (permalink / raw
To: gentoo-commits
commit: 2d0cefbcbf9612538171c581485c290f140b57ff
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 9 20:54:48 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Aug 9 20:56:24 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2d0cefbc
GitSync.retrieve_head: return str, not bytes (bug 625888)
Fixes: 0e1699ad6b3f ("emerge: Add head commit per repo to --info")
pym/portage/sync/modules/git/git.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 19c167485..8068149c7 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -137,8 +137,9 @@ class GitSync(NewBase):
self._kwargs(kwargs)
rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
try:
- ret = (os.EX_OK, subprocess.check_output(rev_cmd,
- cwd=portage._unicode_encode(self.repo.location)))
+ ret = (os.EX_OK,
+ portage._unicode_decode(subprocess.check_output(rev_cmd,
+ cwd=portage._unicode_encode(self.repo.location))))
except subprocess.CalledProcessError:
ret = (1, False)
return ret
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2018-02-05 18:44 Michał Górny
0 siblings, 0 replies; 21+ messages in thread
From: Michał Górny @ 2018-02-05 18:44 UTC (permalink / raw
To: gentoo-commits
commit: d30191b887bb3a3d896c2b8bbf57571e8821b413
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 1 13:30:46 2018 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Feb 5 18:43:35 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d30191b8
git: Support running the verification against sync-openpgp-key-path
Closes: https://github.com/gentoo/portage/pull/252
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
pym/portage/sync/modules/git/git.py | 101 +++++++++++++++++++++++++-----------
1 file changed, 70 insertions(+), 31 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 7e5ddf3b5..cec760d00 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -1,6 +1,7 @@
# Copyright 2005-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import io
import logging
import subprocess
@@ -13,6 +14,12 @@ bad = create_color_func("BAD")
warn = create_color_func("WARN")
from portage.sync.syncbase import NewBase
+try:
+ from gemato.exceptions import GematoException
+ import gemato.openpgp
+except ImportError:
+ gemato = None
+
class GitSync(NewBase):
'''Git sync class'''
@@ -141,39 +148,71 @@ class GitSync(NewBase):
'sync-git-verify-commit-signature', 'false') != 'true'):
return True
- rev_cmd = [self.bin_command, "log", "--pretty=format:%G?", "-1"]
- try:
- status = (portage._unicode_decode(
- subprocess.check_output(rev_cmd,
- cwd=portage._unicode_encode(self.repo.location)))
- .strip())
- except subprocess.CalledProcessError:
- return False
-
- out = EOutput()
- if status == 'G': # good signature is good
- out.einfo('Trusted signature found on top commit')
- return True
- elif status == 'U': # untrusted
- out.ewarn('Top commit signature is valid but not trusted')
- return True
+ if self.repo.sync_openpgp_key_path is not None:
+ if gemato is None:
+ writemsg_level("!!! Verifying against specified key requires gemato-11.0+ installed\n",
+ level=logging.ERROR, noiselevel=-1)
+ return False
+ openpgp_env = gemato.openpgp.OpenPGPEnvironment()
else:
- if status == 'B':
- expl = 'bad signature'
- elif status == 'X':
- expl = 'expired signature'
- elif status == 'Y':
- expl = 'expired key'
- elif status == 'R':
- expl = 'revoked key'
- elif status == 'E':
- expl = 'unable to verify signature (missing key?)'
- elif status == 'N':
- expl = 'no signature'
+ openpgp_env = None
+
+ try:
+ out = EOutput()
+ env = None
+ if openpgp_env is not None:
+ try:
+ out.einfo('Using keys from %s' % (self.repo.sync_openpgp_key_path,))
+ with io.open(self.repo.sync_openpgp_key_path, 'rb') as f:
+ openpgp_env.import_key(f)
+ out.ebegin('Refreshing keys from keyserver')
+ openpgp_env.refresh_keys()
+ out.eend(0)
+ except GematoException as e:
+ writemsg_level("!!! Verification impossible due to keyring problem:\n%s\n"
+ % (e,),
+ level=logging.ERROR, noiselevel=-1)
+ return (1, False)
+
+ env = os.environ.copy()
+ env['GNUPGHOME'] = openpgp_env.home
+
+ rev_cmd = [self.bin_command, "log", "--pretty=format:%G?", "-1"]
+ try:
+ status = (portage._unicode_decode(
+ subprocess.check_output(rev_cmd,
+ cwd=portage._unicode_encode(self.repo.location),
+ env=env))
+ .strip())
+ except subprocess.CalledProcessError:
+ return False
+
+ if status == 'G': # good signature is good
+ out.einfo('Trusted signature found on top commit')
+ return True
+ elif status == 'U': # untrusted
+ out.ewarn('Top commit signature is valid but not trusted')
+ return True
else:
- expl = 'unknown issue'
- out.eerror('No valid signature found: %s' % (expl,))
- return False
+ if status == 'B':
+ expl = 'bad signature'
+ elif status == 'X':
+ expl = 'expired signature'
+ elif status == 'Y':
+ expl = 'expired key'
+ elif status == 'R':
+ expl = 'revoked key'
+ elif status == 'E':
+ expl = 'unable to verify signature (missing key?)'
+ elif status == 'N':
+ expl = 'no signature'
+ else:
+ expl = 'unknown issue'
+ out.eerror('No valid signature found: %s' % (expl,))
+ return False
+ finally:
+ if openpgp_env is not None:
+ openpgp_env.close()
def retrieve_head(self, **kwargs):
'''Get information about the head commit'''
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2018-03-21 18:26 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2018-03-21 18:26 UTC (permalink / raw
To: gentoo-commits
commit: 1327daa7c32ee093b58b52bfa66c3ffdcaf1e1c6
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 17 21:23:52 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Mar 21 18:25:54 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1327daa7
GitSync: abort early for missing git command (bug 650754)
Bug: https://bugs.gentoo.org/650754
pym/portage/sync/modules/git/git.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index cec760d00..160137a6d 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -44,6 +44,8 @@ class GitSync(NewBase):
'''Do the initial clone of the repository'''
if kwargs:
self._kwargs(kwargs)
+ if not self.has_bin:
+ return (1, False)
try:
if not os.path.exists(self.repo.location):
os.makedirs(self.repo.location)
@@ -104,7 +106,8 @@ class GitSync(NewBase):
that he/she wants updated. We'll let the user manage branches with
git directly.
'''
-
+ if not self.has_bin:
+ return (1, False)
git_cmd_opts = ""
if self.repo.module_specific_options.get('sync-git-env'):
shlexed_env = shlex_split(self.repo.module_specific_options['sync-git-env'])
@@ -218,6 +221,9 @@ class GitSync(NewBase):
'''Get information about the head commit'''
if kwargs:
self._kwargs(kwargs)
+ if self.bin_command is None:
+ # return quietly so that we don't pollute emerge --info output
+ return (1, False)
rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
try:
ret = (os.EX_OK,
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2018-07-08 21:17 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2018-07-08 21:17 UTC (permalink / raw
To: gentoo-commits
commit: 3cd8cf93abb6410cc877381531bb662a704dffa7
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 5 10:10:36 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jul 8 21:16:31 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3cd8cf93
GitSync: abort checkout for signature problem (bug 660372)
Fetch the upstream remote and use git merge to update the checkout
only after successful verification of the upstream head.
Suggested-by: Richard Freeman <rich0 <AT> gentoo.org>
Reviewed-by: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache.Org>
Bug: https://bugs.gentoo.org/660372
pym/portage/sync/modules/git/git.py | 39 ++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 160137a6d..85a44289a 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -109,6 +109,7 @@ class GitSync(NewBase):
if not self.has_bin:
return (1, False)
git_cmd_opts = ""
+ quiet = self.settings.get("PORTAGE_QUIET") == "1"
if self.repo.module_specific_options.get('sync-git-env'):
shlexed_env = shlex_split(self.repo.module_specific_options['sync-git-env'])
env = dict((k, v) for k, _, v in (assignment.partition('=') for assignment in shlexed_env) if k)
@@ -123,7 +124,21 @@ class GitSync(NewBase):
git_cmd_opts += " --quiet"
if self.repo.module_specific_options.get('sync-git-pull-extra-opts'):
git_cmd_opts += " %s" % self.repo.module_specific_options['sync-git-pull-extra-opts']
- git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts)
+
+ try:
+ remote_branch = portage._unicode_decode(
+ subprocess.check_output([self.bin_command, 'rev-parse',
+ '--abbrev-ref', '--symbolic-full-name', '@{upstream}'],
+ cwd=portage._unicode_encode(self.repo.location))).rstrip('\n')
+ except subprocess.CalledProcessError as e:
+ msg = "!!! git rev-parse error in %s" % self.repo.location
+ self.logger(self.xterm_titles, msg)
+ writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
+ return (e.returncode, False)
+
+ git_cmd = "%s fetch %s%s" % (self.bin_command,
+ remote_branch.partition('/')[0], git_cmd_opts)
+
writemsg_level(git_cmd + "\n")
rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
@@ -133,20 +148,34 @@ class GitSync(NewBase):
exitcode = portage.process.spawn_bash("cd %s ; exec %s" % (
portage._shell_quote(self.repo.location), git_cmd),
**self.spawn_kwargs)
+
if exitcode != os.EX_OK:
- msg = "!!! git pull error in %s" % self.repo.location
+ msg = "!!! git fetch error in %s" % self.repo.location
self.logger(self.xterm_titles, msg)
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
return (exitcode, False)
- if not self.verify_head():
+
+ if not self.verify_head(revision='refs/remotes/%s^..' % remote_branch):
return (1, False)
+ merge_cmd = [self.bin_command, 'merge', 'refs/remotes/%s' % remote_branch]
+ if quiet:
+ merge_cmd.append('--quiet')
+ exitcode = subprocess.call(merge_cmd,
+ cwd=portage._unicode_encode(self.repo.location))
+
+ 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))
return (os.EX_OK, current_rev != previous_rev)
- def verify_head(self):
+ def verify_head(self, revision='-1'):
if (self.repo.module_specific_options.get(
'sync-git-verify-commit-signature', 'false') != 'true'):
return True
@@ -180,7 +209,7 @@ class GitSync(NewBase):
env = os.environ.copy()
env['GNUPGHOME'] = openpgp_env.home
- rev_cmd = [self.bin_command, "log", "--pretty=format:%G?", "-1"]
+ rev_cmd = [self.bin_command, "log", "--pretty=format:%G?", revision]
try:
status = (portage._unicode_decode(
subprocess.check_output(rev_cmd,
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2018-07-08 22:18 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2018-07-08 22:18 UTC (permalink / raw
To: gentoo-commits
commit: dac12abb20592b098163c87572f6e04416ef3996
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 8 22:15:09 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Jul 8 22:15:09 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=dac12abb
GitSync: fix verification of remote branch
Fixes: 3cd8cf93abb6 ("GitSync: abort checkout for signature problem (bug 660372)")
pym/portage/sync/modules/git/git.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 85a44289a..97c4c1de6 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -155,7 +155,7 @@ class GitSync(NewBase):
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
return (exitcode, False)
- if not self.verify_head(revision='refs/remotes/%s^..' % remote_branch):
+ if not self.verify_head(revision='refs/remotes/%s' % remote_branch):
return (1, False)
merge_cmd = [self.bin_command, 'merge', 'refs/remotes/%s' % remote_branch]
@@ -209,7 +209,7 @@ class GitSync(NewBase):
env = os.environ.copy()
env['GNUPGHOME'] = openpgp_env.home
- rev_cmd = [self.bin_command, "log", "--pretty=format:%G?", revision]
+ rev_cmd = [self.bin_command, "log", "-n1", "--pretty=format:%G?", revision]
try:
status = (portage._unicode_decode(
subprocess.check_output(rev_cmd,
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/sync/modules/git/
@ 2018-07-10 4:28 Zac Medico
0 siblings, 0 replies; 21+ messages in thread
From: Zac Medico @ 2018-07-10 4:28 UTC (permalink / raw
To: gentoo-commits
commit: 89b85e47d7ac0d5f36b182c36eb1e72db7187b36
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 8 20:29:40 2018 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Jul 10 04:25:54 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=89b85e47
GitSync: add key refresh retry (bug 660732)
Bug: https://bugs.gentoo.org/660732
pym/portage/sync/modules/git/git.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
index 97c4c1de6..68f8bd1fb 100644
--- a/pym/portage/sync/modules/git/git.py
+++ b/pym/portage/sync/modules/git/git.py
@@ -8,6 +8,7 @@ import subprocess
import portage
from portage import os
from portage.util import writemsg_level, shlex_split
+from portage.util.futures import asyncio
from portage.output import create_color_func, EOutput
good = create_color_func("GOOD")
bad = create_color_func("BAD")
@@ -197,10 +198,8 @@ class GitSync(NewBase):
out.einfo('Using keys from %s' % (self.repo.sync_openpgp_key_path,))
with io.open(self.repo.sync_openpgp_key_path, 'rb') as f:
openpgp_env.import_key(f)
- out.ebegin('Refreshing keys from keyserver')
- openpgp_env.refresh_keys()
- out.eend(0)
- except GematoException as e:
+ self._refresh_keys(openpgp_env)
+ except (GematoException, asyncio.TimeoutError) as e:
writemsg_level("!!! Verification impossible due to keyring problem:\n%s\n"
% (e,),
level=logging.ERROR, noiselevel=-1)
^ permalink raw reply related [flat|nested] 21+ messages in thread
end of thread, other threads:[~2018-07-10 4:28 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/git/ Brian Dolbec
2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2018-07-10 4:28 Zac Medico
2018-07-08 22:18 Zac Medico
2018-07-08 21:17 Zac Medico
2018-03-21 18:26 Zac Medico
2018-02-05 18:44 Michał Górny
2017-08-09 20:56 Zac Medico
2017-08-09 20:39 Zac Medico
2017-02-25 0:25 Zac Medico
2016-11-07 22:16 Zac Medico
2016-11-03 20:05 Zac Medico
2016-10-30 21:23 Michał Górny
2016-09-22 21:45 Zac Medico
2016-07-18 16:32 Zac Medico
2016-07-14 18:41 Zac Medico
2015-11-07 21:28 Zac Medico
2015-09-04 17:27 Brian Dolbec
2015-01-18 18:04 Michał Górny
2014-12-04 20:16 Brian Dolbec
2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec
2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox