1
+ """Git-related utilities."""
1
2
import re
2
3
import logging
3
4
import csv
17
18
18
19
19
20
class Backend (BaseVCS ):
21
+
22
+ """Git VCS backend."""
23
+
20
24
supports_tags = True
21
25
supports_branches = True
22
26
fallback_branch = 'master' # default branch
@@ -48,11 +52,11 @@ def update(self):
48
52
self .checkout ()
49
53
50
54
def repo_exists (self ):
51
- code , out , err = self .run ('git' , 'status' )
55
+ code , _ , _ = self .run ('git' , 'status' )
52
56
return code == 0
53
57
54
58
def fetch (self ):
55
- code , out , err = self .run ('git' , 'fetch' , '--tags' , '--prune' )
59
+ code , _ , err = self .run ('git' , 'fetch' , '--tags' , '--prune' )
56
60
if code != 0 :
57
61
raise ProjectImportError (
58
62
"Failed to get code from '%s' (git fetch): %s\n \n Stderr:\n \n %s\n \n " % (
@@ -67,13 +71,13 @@ def checkout_revision(self, revision=None):
67
71
code , out , err = self .run ('git' , 'checkout' ,
68
72
'--force' , '--quiet' , revision )
69
73
if code != 0 :
70
- log .warning ("Failed to checkout revision '%s': %s" % (
71
- revision , code ) )
74
+ log .warning ("Failed to checkout revision '%s': %s" ,
75
+ revision , code )
72
76
return [code , out , err ]
73
77
74
78
def clone (self ):
75
- code , out , err = self .run ('git' , 'clone' , '--recursive' , '--quiet' ,
76
- self .repo_url , '.' )
79
+ code , _ , err = self .run ('git' , 'clone' , '--recursive' , '--quiet' ,
80
+ self .repo_url , '.' )
77
81
if code != 0 :
78
82
raise ProjectImportError (
79
83
(
@@ -88,7 +92,7 @@ def clone(self):
88
92
89
93
@property
90
94
def tags (self ):
91
- retcode , stdout , err = self .run ('git' , 'show-ref' , '--tags' )
95
+ retcode , stdout , _ = self .run ('git' , 'show-ref' , '--tags' )
92
96
# error (or no tags found)
93
97
if retcode != 0 :
94
98
return []
@@ -123,7 +127,7 @@ def parse_tags(self, data):
123
127
@property
124
128
def branches (self ):
125
129
# Only show remote branches
126
- retcode , stdout , err = self .run ('git' , 'branch' , '-r' )
130
+ retcode , stdout , _ = self .run ('git' , 'branch' , '-r' )
127
131
# error (or no tags found)
128
132
if retcode != 0 :
129
133
return []
@@ -163,7 +167,7 @@ def parse_branches(self, data):
163
167
164
168
@property
165
169
def commit (self ):
166
- retcode , stdout , err = self .run ('git' , 'rev-parse' , 'HEAD' )
170
+ _ , stdout , _ = self .run ('git' , 'rev-parse' , 'HEAD' )
167
171
return stdout .strip ()
168
172
169
173
def checkout (self , identifier = None ):
@@ -210,7 +214,7 @@ def find_ref(self, ref):
210
214
return ref
211
215
212
216
def ref_exists (self , ref ):
213
- code , out , err = self .run ('git' , 'show-ref' , ref )
217
+ code , _ , _ = self .run ('git' , 'show-ref' , ref )
214
218
return code == 0
215
219
216
220
@property
0 commit comments