Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test for #142 #143

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/git-auto-commit.bats
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,47 @@ git_auto_commit() {

assert_equal $current_sha $remote_sha
}


@test "It fails to push commit to remote if branch already exists and local repo is behind its remote counterpart" {

# Create `new-branch` on Remote with changes the local repository does not yet have
cd $FAKE_TEMP_LOCAL_REPOSITORY;

git checkout -b "new-branch"
touch new-branch-file.txt
git add new-branch-file.txt

git commit --quiet -m "Add additional file";
git push origin new-branch;

run git branch -r
assert_line --partial "origin/new-branch"

# ---------
# Switch to our regular local repository and run `git-auto-commit`
cd $FAKE_LOCAL_REPOSITORY;

INPUT_BRANCH="new-branch"

run git branch
refute_line --partial "new-branch"

run git branch -r
refute_line --partial "origin/new-branch"

touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt

run git_auto_commit

assert_success

assert_line "INPUT_BRANCH value: new-branch"
assert_line --partial "::debug::Push commit to remote branch new-branch"

# Assert that branch "new-branch" was updated on remote
current_sha="$(git rev-parse --verify --short new-branch)"
remote_sha="$(git rev-parse --verify --short origin/new-branch)"

assert_equal $current_sha $remote_sha
}