Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] GitSync: abort early for missing git command (bug 650754)
Date: Sat, 17 Mar 2018 21:28:33
Message-Id: 20180317212520.20420-1-zmedico@gentoo.org
1 Bug: https://bugs.gentoo.org/650754
2 ---
3 pym/portage/sync/modules/git/git.py | 8 +++++++-
4 1 file changed, 7 insertions(+), 1 deletion(-)
5
6 diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
7 index cec760d00..160137a6d 100644
8 --- a/pym/portage/sync/modules/git/git.py
9 +++ b/pym/portage/sync/modules/git/git.py
10 @@ -44,6 +44,8 @@ class GitSync(NewBase):
11 '''Do the initial clone of the repository'''
12 if kwargs:
13 self._kwargs(kwargs)
14 + if not self.has_bin:
15 + return (1, False)
16 try:
17 if not os.path.exists(self.repo.location):
18 os.makedirs(self.repo.location)
19 @@ -104,7 +106,8 @@ class GitSync(NewBase):
20 that he/she wants updated. We'll let the user manage branches with
21 git directly.
22 '''
23 -
24 + if not self.has_bin:
25 + return (1, False)
26 git_cmd_opts = ""
27 if self.repo.module_specific_options.get('sync-git-env'):
28 shlexed_env = shlex_split(self.repo.module_specific_options['sync-git-env'])
29 @@ -218,6 +221,9 @@ class GitSync(NewBase):
30 '''Get information about the head commit'''
31 if kwargs:
32 self._kwargs(kwargs)
33 + if self.bin_command is None:
34 + # return quietly so that we don't pollute emerge --info output
35 + return (1, False)
36 rev_cmd = [self.bin_command, "rev-list", "--max-count=1", "HEAD"]
37 try:
38 ret = (os.EX_OK,
39 --
40 2.13.6