Gentoo Archives: gentoo-commits

From: Chris Reffett <creffett@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/git/
Date: Sat, 08 Feb 2014 04:03:15
Message-Id: 1391829708.54c30b589b6807abc9985ab0baf9ab63c3e30bcd.creffett@gentoo
1 commit: 54c30b589b6807abc9985ab0baf9ab63c3e30bcd
2 Author: Chris Reffett <creffett <AT> gentoo <DOT> org>
3 AuthorDate: Fri Feb 7 22:46:22 2014 +0000
4 Commit: Chris Reffett <creffett <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 8 03:21:48 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=54c30b58
7
8 Add auto-clone support for git sync
9
10 Make the git sync module clone the upstream repository if the directory
11 specified in repos.conf isn't a git directory. Fixes bug 485402.
12
13 ---
14 pym/portage/sync/modules/git/git.py | 35 +++++++++++++++++++++++++++--------
15 1 file changed, 27 insertions(+), 8 deletions(-)
16
17 diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py
18 index 2f855bd..bce992e 100644
19 --- a/pym/portage/sync/modules/git/git.py
20 +++ b/pym/portage/sync/modules/git/git.py
21 @@ -57,17 +57,36 @@ class GitSync(object):
22 if not self.has_git:
23 return repo.location, 1, False
24
25 - msg = ">>> Starting git pull in %s..." % repo.location
26 - logger(xterm_titles, msg )
27 - writemsg_level(msg + "\n")
28 - exitcode = portage.process.spawn_bash("cd %s ; git pull" % \
29 + # Test if the directory is a valid git repo, and run
30 + # git clone if not
31 + exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\
32 (portage._shell_quote(repo.location),),
33 **portage._native_kwargs(spawn_kwargs))
34 - if exitcode != os.EX_OK:
35 - msg = "!!! git pull error in %s." % repo.location
36 + if exitcode == 128:
37 + msg = "!!! Git repo does not already exist, cloning from upstream..."
38 logger(xterm_titles, msg)
39 - writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
40 - return exitcode
41 + writemsg_level(msg + "\n")
42 + exitcode = portage.process.spawn_bash("cd %s ; git clone %s ." % \
43 + (portage._shell_quote(repo.location),
44 + portage._shell_quote(repo.sync_uri)),
45 + **portage._native_kwargs(spawn_kwargs))
46 + if exitcode != os.EX_OK:
47 + msg = "!!! git clone error in %s." % repo.location
48 + logger(xterm_titles, msg)
49 + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
50 + return (exitcode, False)
51 + else:
52 + msg = ">>> Starting git pull in %s..." % repo.location
53 + logger(xterm_titles, msg )
54 + writemsg_level(msg + "\n")
55 + exitcode = portage.process.spawn_bash("cd %s ; git pull" % \
56 + (portage._shell_quote(repo.location),),
57 + **portage._native_kwargs(spawn_kwargs))
58 + if exitcode != os.EX_OK:
59 + msg = "!!! git pull error in %s." % repo.location
60 + logger(xterm_titles, msg)
61 + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1)
62 + return (exitcode, False)
63 msg = ">>> Git pull in %s successful" % repo.location
64 logger(xterm_titles, msg)
65 writemsg_level(msg + "\n")