Skip to content

Commit

Permalink
Add test for pulling to a pre-initialized castle
Browse files Browse the repository at this point in the history
  • Loading branch information
yut23 committed Sep 27, 2024
1 parent 22295d8 commit 30268ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/homeshick
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ case $cmd in
refresh)
(refresh $threshhold "$param") ;;
pull)
prev_hash=$(cd "$repos/$param" && git rev-parse HEAD --)
prev_hash=$(cd "$repos/$param" && git rev-parse HEAD -- 2>/dev/null)
(pull "$param")
result=$?
if [[ $result -eq 0 ]]; then
Expand Down
19 changes: 19 additions & 0 deletions test/suites/pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,22 @@ expect_no_new_files() {
assert_tag_points_to rc-files "$tag_before"
[ ! -e "$HOME/.gitignore" ]
}

@test 'pull a castle with no local commits' {
# note: pull should succeed, but doesn't currently try to link
fixture 'pull-test'
(cd "$HOME" && git init .homesick/repos/pull-test)
(
cd "$HOME/.homesick/repos/pull-test" &&
git remote add origin "$REPO_FIXTURES/pull-test" &&
printf '[branch "master"]\n remote = origin\n merge = refs/heads/master' >> .git/config
)

[ ! -e "$HOME/.bashrc" ]
[ ! -e "$HOME/.gitignore" ]
run homeshick pull --batch pull-test
assert_success
expect_no_new_files pull-test
[ ! -e "$HOME/.bashrc" ]
[ ! -e "$HOME/.gitignore" ]
}

0 comments on commit 30268ff

Please sign in to comment.