Преглед на файлове

Proper up-to-date-check; fix when branches are empty.

tags/v0.2
Ben Kurtovic преди 10 години
родител
ревизия
fbf29b4688
променени са 1 файла, в които са добавени 11 реда и са изтрити 1 реда
  1. +11
    -1
      gitup/update.py

+ 11
- 1
gitup/update.py Целия файл

@@ -56,6 +56,11 @@ def _fetch_remote(remote):
remote.fetch() ### TODO: show progress remote.fetch() ### TODO: show progress
print(" done.") print(" done.")


def _is_up_to_date(repo, branch, upstream):
"""Return whether *branch* is up-to-date with its *upstream*."""
base = repo.git.merge_base(branch.commit, upstream.commit)
return repo.commit(base) == upstream.commit

def _rebase(repo, name): def _rebase(repo, name):
"""Rebase the current HEAD of *repo* onto the branch *name*.""" """Rebase the current HEAD of *repo* onto the branch *name*."""
print(" rebasing...", end="") print(" rebasing...", end="")
@@ -101,7 +106,12 @@ def _update_branch(repo, branch, merge, rebase, stasher=None):
if not upstream: if not upstream:
print(" skipped: no upstream is tracked.") print(" skipped: no upstream is tracked.")
return return
if branch.commit == upstream.commit: ### TODO: a better check is possible
try:
branch.commit, upstream.commit
except ValueError:
print(" skipped: branch contains no revisions.")
return
if _is_up_to_date(repo, branch, upstream):
print(" up to date.") print(" up to date.")
return return
if stasher: if stasher:


Зареждане…
Отказ
Запис