tj.git-extras/tests/git-abort.bats
Edwin Kofler 18ecffef5e
Some checks failed
ci / lint (push) Has been cancelled
ci / typo (push) Has been cancelled
ci / test (push) Has been cancelled
ci / build (macos-latest) (push) Has been cancelled
ci / build (ubuntu-latest) (push) Has been cancelled
Implement half of tests in Bats (#1187)
* Initial scaffold

* Finish first half of Bats tests

* Add Bats to CI

* Fix CI

* Fix CI

* Fix configuration to set git name and email

* Fix `GIT_CONFIG_{KEY,VALUE}` indexing

* Fix Git config override precedence

* Remove unused and untested function
2025-03-12 18:15:37 +08:00

94 lines
1.5 KiB
Bash

# shellcheck shell=bash
source "$BATS_TEST_DIRNAME/test_util.sh"
setup_file() {
test_util.setup_file
}
setup() {
test_util.cd_test
git init
git commit --allow-empty -m "Initial commit"
git branch A
git branch B
git checkout A
printf '%s\n' 'a' > tmpfile
git add .
git commit -m A
git checkout B
printf '%s\n' 'b' > tmpfile
git add .
git commit -m B
git status
}
@test "cherry pick" {
run git cherry-pick A
assert_failure
run git status
assert_line -p 'You are currently cherry-picking commit'
assert_line -p 'Unmerged paths:'
assert_success
run git abort
assert_success
run git status
assert_line -p 'nothing to commit, working tree clean'
assert_success
}
@test "merge" {
run git merge A
assert_failure
run git status
assert_line -p 'You have unmerged paths'
assert_line -p 'Unmerged paths:'
assert_success
run git abort
assert_success
run git status
assert_line -p 'nothing to commit, working tree clean'
assert_success
}
@test "rebase" {
run git rebase A
assert_failure
run git status
assert_line -p 'You are currently rebasing branch'
assert_line -p 'Unmerged paths:'
assert_success
run git abort
assert_success
run git status
assert_line -p 'nothing to commit, working tree clean'
assert_success
}
@test "revert" {
run git revert A
assert_failure
run git status
assert_line -p 'You are currently reverting commit'
assert_line -p 'Unmerged paths:'
assert_success
run git abort
assert_success
run git status
assert_line -p 'nothing to commit, working tree clean'
assert_success
}