Skip to content

Commit

Permalink
Merge branch 'feature/fargo' of github.com-personal:ianhomer/dotfiles…
Browse files Browse the repository at this point in the history
… into feature/fargo
  • Loading branch information
ianhomer committed Sep 24, 2023
2 parents 8a871fc + f850b44 commit e2082df
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions bin/git-synk
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def get_branch_name():
match = re.search("heads/(.*)", heads)
if match:
return match.group(1)
raise Exception(
f"heads of git repository is {heads} and does not match 'heads/*"
)
raise Exception(f"heads of git repository is {heads} and does not match 'heads/*")


def synk(path):
Expand All @@ -38,16 +36,19 @@ def synk(path):
)
os.chdir(path)
repository_name = os.path.basename(path)
branch = get_branch_name()
branch_name = get_branch_name()
changes = int(getoutput("git status --porcelain | wc -l"))
auto_commit = getoutput("git config core.autocommit") == "true"
original_url = getoutput("git config --get remote.origin.url")
remote_name = getoutput(f"git config --get branch.{branch_name}.remote")

if changes > 0:
if auto_commit:
os.system("git add -A ; git commit --quiet -m sync")
else:
print(f"∷ ◉ {repository_name} - set autocommit with git synk -a to commit local")
print(
f"∷ ◉ {repository_name} - set autocommit with git synk -a to commit local"
)
return
print("▻ ", end="")

Expand All @@ -63,6 +64,27 @@ def synk(path):
else:
print("∷ ", end="")

if remote_name != "":
left_right_as_string = getoutput(
f"git rev-list --count --left-right {remote_name}/{branch_name}...HEAD"
)
[left, right] = list(map(lambda a: int(a), left_right_as_string.split()))
print(f"LR {left_right_as_string}")
# Determine action about to take place
if left > 0:
if right > 0:
action = f"↓ {left}{right}"
else:
action = f"↓ {left}"
elif right > 0:
action = f"↑ {right}"
else:
action = "≡"
else:
action = "✧"

print(f"{action}", end="")

print("")


Expand Down

0 comments on commit e2082df

Please sign in to comment.