@@ -17,9 +17,7 @@ def _call(args):
17
17
try :
18
18
return check_output (args ).decode ("utf-8" )
19
19
except CalledProcessError :
20
- sys .exit (
21
- __name__ + ": none zero exit status executing: " + " " .join (args )
22
- ) # noqa
20
+ sys .exit (__name__ + ": none zero exit status executing: " + " " .join (args )) # noqa
23
21
24
22
25
23
def _get_branch_name (prefix , name ):
@@ -44,9 +42,7 @@ def new_feature(name, prefix):
44
42
new_branch = _get_branch_name (prefix , name )
45
43
46
44
if _branch_exists (new_branch ):
47
- sys .exit (
48
- __name__ + ": local or remote branch already exists: " + new_branch
49
- ) # noqa
45
+ sys .exit (__name__ + ": local or remote branch already exists: " + new_branch ) # noqa
50
46
51
47
_call (["git" , "checkout" , "-b" , new_branch ])
52
48
_call (["git" , "push" , "-u" , "origin" , new_branch + ":" + new_branch ])
@@ -63,15 +59,11 @@ def finish_feature(name, prefix):
63
59
branch = cur_branch
64
60
_call (["git" , "checkout" , master_branch ])
65
61
else :
66
- sys .exit (
67
- __name__ + ": please provide a branch name if on {}" .format (master_branch )
68
- )
62
+ sys .exit (__name__ + ": please provide a branch name if on {}" .format (master_branch ))
69
63
70
64
_call (["git" , "remote" , "update" , "origin" ])
71
65
72
- commits = _call (
73
- ["git" , "log" , "--oneline" , branch , "^origin/{}" .format (master_branch )]
74
- )
66
+ commits = _call (["git" , "log" , "--oneline" , branch , "^origin/{}" .format (master_branch )])
75
67
if commits :
76
68
sys .exit (
77
69
__name__
@@ -99,9 +91,7 @@ def _branch_func(branch_type, args):
99
91
100
92
branches = _get_branches (branch_type )
101
93
if len (branches ) > 3 :
102
- print (
103
- f"you have more than 3 { branch_type } branches, shall I delete the eldest one? [y/n]"
104
- ) # noqa
94
+ print (f"you have more than 3 { branch_type } branches, shall I delete the eldest one? [y/n]" ) # noqa
105
95
if input ().lower () == "y" :
106
96
branch = branches [0 ]
107
97
_call (["git" , "push" , "origin" , "--delete" , branch ])
@@ -135,14 +125,10 @@ def pullrequest(args):
135
125
136
126
# check its up to date with remote master if not pull
137
127
_call (["git" , "remote" , "update" , "origin" ])
138
- commits = _call (
139
- ["git" , "log" , "--oneline" , "^" + branch , "origin/{}" .format (master_branch )]
140
- )
128
+ commits = _call (["git" , "log" , "--oneline" , "^" + branch , "origin/{}" .format (master_branch )])
141
129
if commits :
142
130
print (
143
- "Your branch is behind origin/{} so cannot be automatically {}d." .format (
144
- merge_strategy , master_branch
145
- )
131
+ "Your branch is behind origin/{} so cannot be automatically {}d." .format (master_branch , merge_strategy )
146
132
) # noqa
147
133
print (commits )
148
134
print (
@@ -156,15 +142,9 @@ def pullrequest(args):
156
142
_call (["git" , "checkout" , branch ])
157
143
try :
158
144
print ("git {} {}" .format (merge_strategy , master_branch ))
159
- output = check_output (["git" , merge_strategy , master_branch ]).decode (
160
- "utf-8"
161
- )
145
+ output = check_output (["git" , merge_strategy , master_branch ]).decode ("utf-8" )
162
146
print (output )
163
- print (
164
- "Congratulations, successfully {}d {}" .format (
165
- merge_strategy , master_branch
166
- )
167
- )
147
+ print ("Congratulations, successfully {}d {}" .format (merge_strategy , master_branch ))
168
148
except CalledProcessError as e :
169
149
if "CONFLICT" in e .output :
170
150
err = (
@@ -187,9 +167,7 @@ def pullrequest(args):
187
167
origin = _call (["git" , "config" , "--get" , "remote.origin.url" ])
188
168
name = origin .split (":" )[1 ].replace (".git\n " , "" )
189
169
url = _get_pullrequest_url (name , branch )
190
- if (len (args ) > 0 and args [0 ] == "--dry-run" ) or os .environ .get (
191
- "CONSOLEONLY" , False
192
- ): # noqa
170
+ if (len (args ) > 0 and args [0 ] == "--dry-run" ) or os .environ .get ("CONSOLEONLY" , False ): # noqa
193
171
print (url )
194
172
else :
195
173
webbrowser .open_new_tab (url )
@@ -200,9 +178,7 @@ def _get_pullrequest_url(name, branch):
200
178
if repo == "github" :
201
179
url = "https://github.com/" + name + "/pull/new/" + branch
202
180
elif repo == "bitbucket" :
203
- url = (
204
- "https://bitbucket.org/" + name + "/pull-requests/new?t=1&source=" + branch
205
- ) # noqa
181
+ url = "https://bitbucket.org/" + name + "/pull-requests/new?t=1&source=" + branch # noqa
206
182
return url
207
183
208
184
0 commit comments