Gentoo Archives: gentoo-commits

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