Fix #151: git ambiguous argument error (#531)

We check if origin/HEAD is present. In case that reference is
missing, we show a meaningful error message now, with an explanation
on how to add it. Also moved find_out_of_sync_files_tracked() to
pmb.helpers.git
This commit is contained in:
Oliver Smith 2017-09-25 22:05:29 +00:00 committed by GitHub
parent 1416ce241d
commit e60eee7dfa
3 changed files with 53 additions and 6 deletions

View file

@ -117,3 +117,20 @@ def test_aport_in_sync_with_git(args):
# TODO:
# - reinstall git, but rm .git, check again
# - remove temporary folder
def test_ambigious_argument(args):
"""
Testcase for #151, forces "fatal: ambiguous argument" in git.
See also: https://stackoverflow.com/a/17639471
"""
# Delete origin/HEAD
aports = temp_aports_repo(args)
pmb.chroot.user(args, ["git", "update-ref", "-d", "refs/remotes/origin/HEAD"],
working_dir=aports)
# Check for exception
with pytest.raises(RuntimeError) as e:
out_of_sync_files(args)
assert "'origin/HEAD' reference" in str(e.value)