1 |
commit: 5b4ede32eb16add16c152f72cbf5fbb6b61dea67 |
2 |
Author: Chris Reffett <creffett <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Feb 8 03:20:40 2014 +0000 |
4 |
Commit: Chris Reffett <creffett <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Feb 8 03:21:49 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5b4ede32 |
7 |
|
8 |
Move several git vars to be part of the object like in rsync |
9 |
|
10 |
--- |
11 |
pym/portage/sync/modules/git/git.py | 53 ++++++++++++++++++++++--------------- |
12 |
1 file changed, 31 insertions(+), 22 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py |
15 |
index bce992e..0c75dc7 100644 |
16 |
--- a/pym/portage/sync/modules/git/git.py |
17 |
+++ b/pym/portage/sync/modules/git/git.py |
18 |
@@ -28,7 +28,12 @@ class GitSync(object): |
19 |
|
20 |
|
21 |
def __init__(self): |
22 |
+ self.options = None |
23 |
self.settings = None |
24 |
+ self.logger = None |
25 |
+ self.repo = None |
26 |
+ self.xterm_titles = None |
27 |
+ |
28 |
self.has_git = True |
29 |
if portage.process.find_binary("git") is None: |
30 |
msg = ["Command not found: git", |
31 |
@@ -39,6 +44,13 @@ class GitSync(object): |
32 |
self.has_git = False |
33 |
|
34 |
|
35 |
+ def _kwargs(self, kwargs): |
36 |
+ self.options = kwargs.get('options', {}) |
37 |
+ self.settings = self.options.get('settings', None) |
38 |
+ self.logger = self.options.get('logger', None) |
39 |
+ self.repo = self.options.get('repo', None) |
40 |
+ self.xterm_titles = self.options.get('xterm_titles', False) |
41 |
+ |
42 |
def sync(self, **kwargs): |
43 |
''' Update existing git repository, and ignore the syncuri. We are |
44 |
going to trust the user and assume that the user is in the branch |
45 |
@@ -46,51 +58,48 @@ class GitSync(object): |
46 |
git directly. |
47 |
''' |
48 |
if kwargs: |
49 |
- options = kwargs.get('options', {}) |
50 |
- emerge_config = options.get('emerge_config', None) |
51 |
- logger = options.get('logger', None) |
52 |
- repo = options.get('repo', None) |
53 |
- portdb = options.get('portdb', None) |
54 |
- spawn_kwargs = options.get('spawn_kwargs', None) |
55 |
- xterm_titles = options.get('xterm_titles', False) |
56 |
+ self._kwargs(kwargs) |
57 |
+ emerge_config = self.options.get('emerge_config', None) |
58 |
+ spawn_kwargs = self.options.get('spawn_kwargs', None) |
59 |
+ portdb = self.options.get('portdb', None) |
60 |
|
61 |
if not self.has_git: |
62 |
- return repo.location, 1, False |
63 |
+ return self.repo.location, 1, False |
64 |
|
65 |
# Test if the directory is a valid git repo, and run |
66 |
# git clone if not |
67 |
exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\ |
68 |
- (portage._shell_quote(repo.location),), |
69 |
+ (portage._shell_quote(self.repo.location),), |
70 |
**portage._native_kwargs(spawn_kwargs)) |
71 |
if exitcode == 128: |
72 |
msg = "!!! Git repo does not already exist, cloning from upstream..." |
73 |
- logger(xterm_titles, msg) |
74 |
+ self.logger(self.xterm_titles, msg) |
75 |
writemsg_level(msg + "\n") |
76 |
exitcode = portage.process.spawn_bash("cd %s ; git clone %s ." % \ |
77 |
- (portage._shell_quote(repo.location), |
78 |
- portage._shell_quote(repo.sync_uri)), |
79 |
+ (portage._shell_quote(self.repo.location), |
80 |
+ portage._shell_quote(self.repo.sync_uri)), |
81 |
**portage._native_kwargs(spawn_kwargs)) |
82 |
if exitcode != os.EX_OK: |
83 |
- msg = "!!! git clone error in %s." % repo.location |
84 |
- logger(xterm_titles, msg) |
85 |
+ msg = "!!! git clone error in %s." % self.repo.location |
86 |
+ self.logger(self.xterm_titles, msg) |
87 |
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) |
88 |
return (exitcode, False) |
89 |
else: |
90 |
- msg = ">>> Starting git pull in %s..." % repo.location |
91 |
- logger(xterm_titles, msg ) |
92 |
+ msg = ">>> Starting git pull in %s..." % self.repo.location |
93 |
+ self.logger(self.xterm_titles, msg ) |
94 |
writemsg_level(msg + "\n") |
95 |
exitcode = portage.process.spawn_bash("cd %s ; git pull" % \ |
96 |
- (portage._shell_quote(repo.location),), |
97 |
+ (portage._shell_quote(self.repo.location),), |
98 |
**portage._native_kwargs(spawn_kwargs)) |
99 |
if exitcode != os.EX_OK: |
100 |
- msg = "!!! git pull error in %s." % repo.location |
101 |
- logger(xterm_titles, msg) |
102 |
+ msg = "!!! git pull error in %s." % self.repo.location |
103 |
+ self.logger(self.xterm_titles, msg) |
104 |
writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) |
105 |
return (exitcode, False) |
106 |
- msg = ">>> Git pull in %s successful" % repo.location |
107 |
- logger(xterm_titles, msg) |
108 |
+ msg = ">>> Git pull in %s successful" % self.repo.location |
109 |
+ self.logger(self.xterm_titles, msg) |
110 |
writemsg_level(msg + "\n") |
111 |
- return self.post_sync(portdb, repo.location, emerge_config) |
112 |
+ return self.post_sync(portdb, self.repo.location, emerge_config) |
113 |
|
114 |
|
115 |
def post_sync(self, portdb, location, emerge_config): |