1 |
Fix updates to respect sync-depth (previously it was only respected |
2 |
for clone operations). Since the default merge strategy typically |
3 |
fails when the the depth is not unlimited, use `git fetch` followed |
4 |
by `git reset --hard`. |
5 |
|
6 |
X-Gentoo-Bug: 552814 |
7 |
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=552814 |
8 |
--- |
9 |
[PATCH v2] fixes the git reset call to use --quiet when appropriate |
10 |
|
11 |
pym/portage/sync/modules/git/git.py | 27 +++++++++++++++++++++++++-- |
12 |
1 file changed, 25 insertions(+), 2 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py |
15 |
index 02eeb16..09257f3 100644 |
16 |
--- a/pym/portage/sync/modules/git/git.py |
17 |
+++ b/pym/portage/sync/modules/git/git.py |
18 |
@@ -79,11 +79,26 @@ class GitSync(NewBase): |
19 |
''' |
20 |
|
21 |
git_cmd_opts = "" |
22 |
- if self.settings.get("PORTAGE_QUIET") == "1": |
23 |
+ quiet = self.settings.get("PORTAGE_QUIET") == "1" |
24 |
+ if quiet: |
25 |
git_cmd_opts += " --quiet" |
26 |
if self.repo.module_specific_options.get('sync-git-pull-extra-opts'): |
27 |
git_cmd_opts += " %s" % self.repo.module_specific_options['sync-git-pull-extra-opts'] |
28 |
- git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts) |
29 |
+ if self.repo.sync_depth is None: |
30 |
+ git_cmd = "%s pull%s" % (self.bin_command, git_cmd_opts) |
31 |
+ else: |
32 |
+ # Since the default merge strategy typically fails when |
33 |
+ # the depth is not unlimited, use `git fetch` followed by |
34 |
+ # `git reset --hard`. |
35 |
+ remote_branch = portage._unicode_decode( |
36 |
+ subprocess.check_output([self.bin_command, 'rev-parse', |
37 |
+ '--abbrev-ref', '--symbolic-full-name', '@{upstream}'], |
38 |
+ cwd=portage._unicode_encode(self.repo.location))).rstrip('\n') |
39 |
+ |
40 |
+ git_cmd_opts += " --depth %d" % self.repo.sync_depth |
41 |
+ git_cmd = "%s fetch %s%s" % (self.bin_command, |
42 |
+ remote_branch.partition('/')[0], git_cmd_opts) |
43 |
+ |
44 |
writemsg_level(git_cmd + "\n") |
45 |
|
46 |
rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"] |
47 |
@@ -93,6 +108,14 @@ class GitSync(NewBase): |
48 |
exitcode = portage.process.spawn_bash("cd %s ; exec %s" % ( |
49 |
portage._shell_quote(self.repo.location), git_cmd), |
50 |
**self.spawn_kwargs) |
51 |
+ |
52 |
+ if exitcode == os.EX_OK and self.repo.sync_depth is not None: |
53 |
+ reset_cmd = [self.bin_command, 'reset', '--hard', remote_branch] |
54 |
+ if quiet: |
55 |
+ reset_cmd.append('--quiet') |
56 |
+ exitcode = subprocess.call(reset_cmd, |
57 |
+ cwd=portage._unicode_encode(self.repo.location)) |
58 |
+ |
59 |
if exitcode != os.EX_OK: |
60 |
msg = "!!! git pull error in %s" % self.repo.location |
61 |
self.logger(self.xterm_titles, msg) |
62 |
-- |
63 |
2.7.4 |