Reduce number of unnecessary subprocesses with better conditions.
The code is a little uglier with more ifs and elses but saving some subprocess calls is worth it.
This commit is contained in:
parent
4652f9b745
commit
37093aebe6
1 changed files with 13 additions and 6 deletions
|
@ -50,12 +50,19 @@ def checkup_pushed():
|
|||
output = check_output(command)
|
||||
(my_head, remote_head) = output.strip().decode().splitlines()
|
||||
|
||||
if my_head == remote_head:
|
||||
to_push = 0
|
||||
to_pull = 0
|
||||
else:
|
||||
command = [GIT, 'merge-base', '@', '@{u}']
|
||||
merge_base = check_output(command)
|
||||
merge_base = merge_base.strip().decode()
|
||||
|
||||
if my_head == remote_head:
|
||||
if my_head == merge_base:
|
||||
to_push = 0
|
||||
to_pull = len(git_commits_between(merge_base, remote_head))
|
||||
elif remote_head == merge_base:
|
||||
to_push = len(git_commits_between(merge_base, my_head))
|
||||
to_pull = 0
|
||||
else:
|
||||
to_push = len(git_commits_between(merge_base, my_head))
|
||||
|
|
Loading…
Reference in a new issue