mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-07-21 23:56:09 +08:00
Add options for add/status commands
This commit is contained in:
@@ -14,6 +14,8 @@ setup() {
|
||||
export INPUT_COMMIT_MESSAGE="Commit Message"
|
||||
export INPUT_BRANCH="master"
|
||||
export INPUT_COMMIT_OPTIONS=""
|
||||
export INPUT_ADD_OPTIONS=""
|
||||
export INPUT_STATUS_OPTIONS=""
|
||||
export INPUT_FILE_PATTERN="."
|
||||
export INPUT_COMMIT_USER_NAME="Test Suite"
|
||||
export INPUT_COMMIT_USER_EMAIL="test@github.com"
|
||||
@@ -115,6 +117,20 @@ git_auto_commit() {
|
||||
assert_line "::debug::Push commit to remote branch master"
|
||||
}
|
||||
|
||||
@test "It applies INPUT_STATUS_OPTIONS when running dirty check" {
|
||||
INPUT_STATUS_OPTIONS="--untracked-files=no"
|
||||
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||
assert_line "::set-output name=changes_detected::false"
|
||||
assert_line "Working tree clean. Nothing to commit."
|
||||
}
|
||||
|
||||
@test "It prints a 'Nothing to commit' message in a clean repository" {
|
||||
run git_auto_commit
|
||||
|
||||
@@ -142,6 +158,28 @@ git_auto_commit() {
|
||||
assert_line "::debug::Apply commit options "
|
||||
}
|
||||
|
||||
@test "It applies INPUT_ADD_OPTIONS when adding files" {
|
||||
INPUT_FILE_PATTERN=""
|
||||
INPUT_STATUS_OPTIONS="--untracked-files=no"
|
||||
INPUT_ADD_OPTIONS="-u"
|
||||
|
||||
date > "${FAKE_LOCAL_REPOSITORY}"/remote-files1.txt
|
||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
||||
|
||||
run git_auto_commit
|
||||
|
||||
assert_success
|
||||
|
||||
assert_line "INPUT_STATUS_OPTIONS: --untracked-files=no"
|
||||
assert_line "INPUT_ADD_OPTIONS: -u"
|
||||
assert_line "INPUT_FILE_PATTERN: "
|
||||
assert_line "::debug::Push commit to remote branch master"
|
||||
|
||||
# Assert that PHP files have not been added.
|
||||
run git status
|
||||
assert_output --partial 'new-file-1.php'
|
||||
}
|
||||
|
||||
@test "It applies INPUT_FILE_PATTERN when creating commit" {
|
||||
INPUT_FILE_PATTERN="*.txt *.html"
|
||||
|
||||
|
Reference in New Issue
Block a user