mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-08-02 16:52:51 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3ea6ae190b | ||
|
976f22029f | ||
|
ebb5756042 | ||
|
3dce995a13 | ||
|
0b007fbd11 | ||
|
7106b2184a | ||
|
f166130208 | ||
|
021a6363fa | ||
|
38864a638f | ||
|
393fea59ef | ||
|
0049e3fa40 | ||
|
f6f7a9c351 | ||
|
2fde6fc18d | ||
|
faf78595b8 | ||
|
a0873a0795 |
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
2
.github/workflows/git-auto-commit.yml
vendored
2
.github/workflows/git-auto-commit.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Use git-auto-commit-action
|
- name: Use git-auto-commit-action
|
||||||
id: "auto-commit-action"
|
id: "auto-commit-action"
|
||||||
|
4
.github/workflows/linter.yml
vendored
4
.github/workflows/linter.yml
vendored
@@ -9,10 +9,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Lint Code Base
|
- name: Lint Code Base
|
||||||
uses: github/super-linter@v3
|
uses: github/super-linter@v4
|
||||||
env:
|
env:
|
||||||
VALIDATE_ALL_CODEBASE: false
|
VALIDATE_ALL_CODEBASE: false
|
||||||
VALIDATE_MARKDOWN: false
|
VALIDATE_MARKDOWN: false
|
||||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install testing dependencies
|
- name: Install testing dependencies
|
||||||
run: yarn install
|
run: yarn install
|
||||||
|
2
.github/workflows/update-changelog.yaml
vendored
2
.github/workflows/update-changelog.yaml
vendored
@@ -10,7 +10,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: master
|
ref: master
|
||||||
|
|
||||||
|
32
CHANGELOG.md
32
CHANGELOG.md
@@ -5,10 +5,40 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.0...HEAD)
|
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.4...HEAD)
|
||||||
|
|
||||||
> TBD
|
> TBD
|
||||||
|
|
||||||
|
## [v4.15.4](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.3...v4.15.4) - 2022-11-05
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Let Action fail if git binary can't be located ([#261](https://github.com/stefanzweifel/git-auto-commit-action/pull/261)) [@stefanzweifel](https://github.com/@stefanzweifel)
|
||||||
|
|
||||||
|
### Dependency Updates
|
||||||
|
|
||||||
|
- Bump github/super-linter from 3 to 4 ([#258](https://github.com/stefanzweifel/git-auto-commit-action/pull/258)) [@dependabot](https://github.com/@dependabot)
|
||||||
|
- Bump bats from 1.7.0 to 1.8.2 ([#259](https://github.com/stefanzweifel/git-auto-commit-action/pull/259)) [@dependabot](https://github.com/@dependabot)
|
||||||
|
- Bump actions/checkout from 2 to 3 ([#257](https://github.com/stefanzweifel/git-auto-commit-action/pull/257)) [@dependabot](https://github.com/@dependabot)
|
||||||
|
|
||||||
|
## [v4.15.3](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.2...v4.15.3) - 2022-10-26
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Use deprecated set-output syntax if GITHUB_OUTPUT environment is not available ([#255](https://github.com/stefanzweifel/git-auto-commit-action/pull/255)) [@stefanzweifel](https://github.com/@stefanzweifel)
|
||||||
|
|
||||||
|
## [v4.15.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.1...v4.15.2) - 2022-10-22
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Replace set-output usage with GITHUB_OUTPUT ([#252](https://github.com/stefanzweifel/git-auto-commit-action/pull/252)) [@amonshiz](https://github.com/amonshiz)
|
||||||
|
|
||||||
|
## [v4.15.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.15.0...v4.15.1) - 2022-10-10
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Run Action on Node16 ([#247](https://github.com/stefanzweifel/git-auto-commit-action/pull/247)) [@stefanzweifel](https://github.com/@stefanzweifel)
|
||||||
|
|
||||||
## [v4.15.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.14.1...v4.15.0) - 2022-09-24
|
## [v4.15.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.14.1...v4.15.0) - 2022-09-24
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@@ -53,7 +53,7 @@ The following is an extended example with all available options.
|
|||||||
|
|
||||||
# Optional commit user and author settings
|
# Optional commit user and author settings
|
||||||
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
|
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
|
||||||
commit_user_email: my-github-actions-bot@example.org # defaults to "github-actions[bot]@users.noreply.github.com"
|
commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
|
||||||
commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run
|
commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run
|
||||||
|
|
||||||
# Optional. Tag name being created in the local repository and
|
# Optional. Tag name being created in the local repository and
|
||||||
@@ -159,7 +159,7 @@ The following is a list of edge cases the Action knowingly does not support:
|
|||||||
|
|
||||||
**No support for `git rebase` or `git merge`**. There are many strategies on how to integrate remote upstream changes to a local repository. `git-auto-commit` does not want to be responsible for doing that.
|
**No support for `git rebase` or `git merge`**. There are many strategies on how to integrate remote upstream changes to a local repository. `git-auto-commit` does not want to be responsible for doing that.
|
||||||
|
|
||||||
**No support for detecting line break changes between CR (Carriage Return) and LF (Line Feed)**. This is a lovel level issue, you have to resolve differently in your project. Sorry.
|
**No support for detecting line break changes between CR (Carriage Return) and LF (Line Feed)**. This is a low level issue, you have to resolve differently in your project. Sorry.
|
||||||
|
|
||||||
If this Action doesn't work for your workflow, check out [EndBug/add-and-commit](https://github.com/EndBug/add-and-commit).
|
If this Action doesn't work for your workflow, check out [EndBug/add-and-commit](https://github.com/EndBug/add-and-commit).
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ The steps in your workflow might look like this:
|
|||||||
- name: Get last commit message
|
- name: Get last commit message
|
||||||
id: last-commit-message
|
id: last-commit-message
|
||||||
run: |
|
run: |
|
||||||
echo "::set-output name=msg::$(git log -1 --pretty=%s)"
|
echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4
|
- uses: stefanzweifel/git-auto-commit-action@v4
|
||||||
with:
|
with:
|
||||||
@@ -399,7 +399,7 @@ If you go the "force pushes" route, you have to enable force pushes to a protect
|
|||||||
|
|
||||||
### No new workflows are triggered by the commit of this action
|
### No new workflows are triggered by the commit of this action
|
||||||
|
|
||||||
This is due to limitations set up by GitHub, [commits of this Action do not trigger new Workflow runs](#commits-of-this-action-do-not-trigger-new-workflow-runs).
|
This is due to limitations set up by GitHub, [commits made by this Action do not trigger new Workflow runs](#commits-made-by-this-action-do-not-trigger-new-workflow-runs).
|
||||||
|
|
||||||
### Pathspec 'x' did not match any files
|
### Pathspec 'x' did not match any files
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ inputs:
|
|||||||
commit_user_email:
|
commit_user_email:
|
||||||
description: Email address used for the commit user
|
description: Email address used for the commit user
|
||||||
required: false
|
required: false
|
||||||
default: github-actions[bot]@users.noreply.github.com
|
default: 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
commit_author:
|
commit_author:
|
||||||
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
|
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
|
||||||
required: false
|
required: false
|
||||||
@@ -70,6 +70,9 @@ inputs:
|
|||||||
create_branch:
|
create_branch:
|
||||||
description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
|
description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
|
||||||
default: false
|
default: false
|
||||||
|
internal_git_binary:
|
||||||
|
description: Internal use only! Path to git binary used to check if git is available. (Don't change this!)
|
||||||
|
default: git
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
changes_detected:
|
changes_detected:
|
||||||
|
@@ -7,29 +7,68 @@ if "$INPUT_DISABLE_GLOBBING"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_main() {
|
_main() {
|
||||||
|
_check_if_git_is_available
|
||||||
|
|
||||||
_switch_to_repository
|
_switch_to_repository
|
||||||
|
|
||||||
if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
|
if _git_is_dirty || "$INPUT_SKIP_DIRTY_CHECK"; then
|
||||||
|
|
||||||
echo "::set-output name=changes_detected::true";
|
# Check if $GITHUB_OUTPUT is available
|
||||||
|
# (Feature detection will be removed in late December 2022)
|
||||||
|
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||||
|
echo "::set-output name=changes_detected::true";
|
||||||
|
else
|
||||||
|
echo "changes_detected=true" >> $GITHUB_OUTPUT;
|
||||||
|
fi
|
||||||
|
|
||||||
_switch_to_branch
|
_switch_to_branch
|
||||||
|
|
||||||
_add_files
|
_add_files
|
||||||
|
|
||||||
_local_commit
|
# Check dirty state of repo again using git-diff.
|
||||||
|
# (git-diff detects beter if CRLF of files changes and does NOT
|
||||||
|
# proceed, if only CRLF changes are detected. See #241 and #265
|
||||||
|
# for more details.)
|
||||||
|
if [ -n "$(git diff --staged)" ] || "$INPUT_SKIP_DIRTY_CHECK"; then
|
||||||
|
_local_commit
|
||||||
|
|
||||||
_tag_commit
|
_tag_commit
|
||||||
|
|
||||||
_push_to_github
|
_push_to_github
|
||||||
|
else
|
||||||
|
|
||||||
|
# Check if $GITHUB_OUTPUT is available
|
||||||
|
# (Feature detection will be removed in late December 2022)
|
||||||
|
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||||
|
echo "::set-output name=changes_detected::false";
|
||||||
|
else
|
||||||
|
echo "changes_detected=false" >> $GITHUB_OUTPUT;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Working tree clean. Nothing to commit.";
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "::set-output name=changes_detected::false";
|
# Check if $GITHUB_OUTPUT is available
|
||||||
|
# (Feature detection will be removed in late December 2022)
|
||||||
|
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||||
|
echo "::set-output name=changes_detected::false";
|
||||||
|
else
|
||||||
|
echo "changes_detected=false" >> $GITHUB_OUTPUT;
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Working tree clean. Nothing to commit.";
|
echo "Working tree clean. Nothing to commit.";
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_check_if_git_is_available() {
|
||||||
|
if hash -- "$INPUT_INTERNAL_GIT_BINARY" 2> /dev/null; then
|
||||||
|
echo "::debug::git binary found.";
|
||||||
|
else
|
||||||
|
echo "::error ::git-auto-commit could not find git binary. Please make sure git is available."
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_switch_to_repository() {
|
_switch_to_repository() {
|
||||||
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
|
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
|
||||||
@@ -101,7 +140,14 @@ _local_commit() {
|
|||||||
--author="$INPUT_COMMIT_AUTHOR" \
|
--author="$INPUT_COMMIT_AUTHOR" \
|
||||||
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
|
${INPUT_COMMIT_OPTIONS:+"${INPUT_COMMIT_OPTIONS_ARRAY[@]}"};
|
||||||
|
|
||||||
echo "::set-output name=commit_hash::$(git rev-parse HEAD)";
|
|
||||||
|
# Check if $GITHUB_OUTPUT is available
|
||||||
|
# (Feature detection will be removed in late December 2022)
|
||||||
|
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||||
|
echo "::set-output name=commit_hash::$(git rev-parse HEAD)";
|
||||||
|
else
|
||||||
|
echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT;
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_tag_commit() {
|
_tag_commit() {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bats": "^1.1.0",
|
"bats": "^1.8.2",
|
||||||
"bats-assert": "ztombol/bats-assert",
|
"bats-assert": "ztombol/bats-assert",
|
||||||
"bats-support": "ztombol/bats-support"
|
"bats-support": "ztombol/bats-support"
|
||||||
},
|
},
|
||||||
|
@@ -9,10 +9,20 @@ setup() {
|
|||||||
export FAKE_REMOTE="${BATS_TEST_DIRNAME}/tests_remote_repository"
|
export FAKE_REMOTE="${BATS_TEST_DIRNAME}/tests_remote_repository"
|
||||||
export FAKE_TEMP_LOCAL_REPOSITORY="${BATS_TEST_DIRNAME}/tests_clone_of_remote_repository"
|
export FAKE_TEMP_LOCAL_REPOSITORY="${BATS_TEST_DIRNAME}/tests_clone_of_remote_repository"
|
||||||
|
|
||||||
|
# While it is likely the GitHub hosted runners will use master as the default branch,
|
||||||
|
# locally anyone may change that. So for tests lets grab whatever is currently set
|
||||||
|
# globally. This should also ensure that changes to the GitHub hosted runners'
|
||||||
|
# config do not break tests in the future.
|
||||||
|
if [[ -z $(git config init.defaultBranch) ]]; then
|
||||||
|
git config --global init.defaultBranch "main"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export FAKE_DEFAULT_BRANCH=$(git config init.defaultBranch)
|
||||||
|
|
||||||
# Set default INPUT variables used by the GitHub Action
|
# Set default INPUT variables used by the GitHub Action
|
||||||
export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}"
|
export INPUT_REPOSITORY="${FAKE_LOCAL_REPOSITORY}"
|
||||||
export INPUT_COMMIT_MESSAGE="Commit Message"
|
export INPUT_COMMIT_MESSAGE="Commit Message"
|
||||||
export INPUT_BRANCH="master"
|
export INPUT_BRANCH="${FAKE_DEFAULT_BRANCH}"
|
||||||
export INPUT_COMMIT_OPTIONS=""
|
export INPUT_COMMIT_OPTIONS=""
|
||||||
export INPUT_ADD_OPTIONS=""
|
export INPUT_ADD_OPTIONS=""
|
||||||
export INPUT_STATUS_OPTIONS=""
|
export INPUT_STATUS_OPTIONS=""
|
||||||
@@ -27,6 +37,11 @@ setup() {
|
|||||||
export INPUT_SKIP_CHECKOUT=false
|
export INPUT_SKIP_CHECKOUT=false
|
||||||
export INPUT_DISABLE_GLOBBING=false
|
export INPUT_DISABLE_GLOBBING=false
|
||||||
export INPUT_CREATE_BRANCH=false
|
export INPUT_CREATE_BRANCH=false
|
||||||
|
export INPUT_INTERNAL_GIT_BINARY=git
|
||||||
|
|
||||||
|
# Set GitHub environment variables used by the GitHub Action
|
||||||
|
temp_github_output_file=$(mktemp -t github_output_test.XXXXX)
|
||||||
|
export GITHUB_OUTPUT="${temp_github_output_file}"
|
||||||
|
|
||||||
# Configure Git
|
# Configure Git
|
||||||
if [[ -z $(git config user.name) ]]; then
|
if [[ -z $(git config user.name) ]]; then
|
||||||
@@ -43,15 +58,21 @@ teardown() {
|
|||||||
rm -rf "${FAKE_LOCAL_REPOSITORY}"
|
rm -rf "${FAKE_LOCAL_REPOSITORY}"
|
||||||
rm -rf "${FAKE_REMOTE}"
|
rm -rf "${FAKE_REMOTE}"
|
||||||
rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
||||||
|
|
||||||
|
if [ -z ${GITHUB_OUTPUT+x} ]; then
|
||||||
|
echo "GITHUB_OUTPUT is not set"
|
||||||
|
else
|
||||||
|
rm "${GITHUB_OUTPUT}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a fake remote repository which tests can push against
|
# Create a fake remote repository which tests can push against
|
||||||
_setup_fake_remote_repository() {
|
_setup_fake_remote_repository() {
|
||||||
# Create the bare repository, which will act as our remote/origin
|
# Create the bare repository, which will act as our remote/origin
|
||||||
rm -rf "${FAKE_REMOTE}";
|
rm -rf "${FAKE_REMOTE}"
|
||||||
mkdir "${FAKE_REMOTE}";
|
mkdir "${FAKE_REMOTE}"
|
||||||
cd "${FAKE_REMOTE}";
|
cd "${FAKE_REMOTE}"
|
||||||
git init --bare;
|
git init --bare
|
||||||
|
|
||||||
# Clone the remote repository to a temporary location.
|
# Clone the remote repository to a temporary location.
|
||||||
rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
rm -rf "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
||||||
@@ -59,10 +80,10 @@ _setup_fake_remote_repository() {
|
|||||||
|
|
||||||
# Create some files, commit them and push them to the remote repository
|
# Create some files, commit them and push them to the remote repository
|
||||||
touch "${FAKE_TEMP_LOCAL_REPOSITORY}"/remote-files{1,2,3}.txt
|
touch "${FAKE_TEMP_LOCAL_REPOSITORY}"/remote-files{1,2,3}.txt
|
||||||
cd "${FAKE_TEMP_LOCAL_REPOSITORY}";
|
cd "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
||||||
git add .;
|
git add .
|
||||||
git commit --quiet -m "Init Remote Repository";
|
git commit --quiet -m "Init Remote Repository"
|
||||||
git push origin master;
|
git push origin "${FAKE_DEFAULT_BRANCH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clone our fake remote repository and set it up for testing
|
# Clone our fake remote repository and set it up for testing
|
||||||
@@ -71,7 +92,7 @@ _setup_local_repository() {
|
|||||||
rm -rf "${FAKE_LOCAL_REPOSITORY}"
|
rm -rf "${FAKE_LOCAL_REPOSITORY}"
|
||||||
git clone "${FAKE_REMOTE}" "${FAKE_LOCAL_REPOSITORY}"
|
git clone "${FAKE_REMOTE}" "${FAKE_LOCAL_REPOSITORY}"
|
||||||
|
|
||||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
cd "${FAKE_LOCAL_REPOSITORY}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the main code related to this GitHub Action
|
# Run the main code related to this GitHub Action
|
||||||
@@ -79,6 +100,12 @@ git_auto_commit() {
|
|||||||
bash "${BATS_TEST_DIRNAME}"/../entrypoint.sh
|
bash "${BATS_TEST_DIRNAME}"/../entrypoint.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cat_github_output() {
|
||||||
|
# Be sure to dump anything we spit out to the environment file is
|
||||||
|
# also available for asserting
|
||||||
|
cat "${GITHUB_OUTPUT}"
|
||||||
|
}
|
||||||
|
|
||||||
@test "It detects changes, commits them and pushes them to the remote repository" {
|
@test "It detects changes, commits them and pushes them to the remote repository" {
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
@@ -87,9 +114,7 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
assert_line "INPUT_BRANCH value: ${FAKE_DEFAULT_BRANCH}"
|
||||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "INPUT_BRANCH value: master"
|
|
||||||
assert_line "INPUT_FILE_PATTERN: ."
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
assert_line "::debug::Apply commit options "
|
assert_line "::debug::Apply commit options "
|
||||||
@@ -97,7 +122,11 @@ git_auto_commit() {
|
|||||||
assert_line "No tagging message supplied. No tag will be added."
|
assert_line "No tagging message supplied. No tag will be added."
|
||||||
assert_line "INPUT_PUSH_OPTIONS: "
|
assert_line "INPUT_PUSH_OPTIONS: "
|
||||||
assert_line "::debug::Apply push options "
|
assert_line "::debug::Apply push options "
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
assert_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It detects when files have been deleted, commits changes and pushes them to the remote repository" {
|
@test "It detects when files have been deleted, commits changes and pushes them to the remote repository" {
|
||||||
@@ -108,9 +137,7 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
assert_line "INPUT_BRANCH value: ${FAKE_DEFAULT_BRANCH}"
|
||||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "INPUT_BRANCH value: master"
|
|
||||||
assert_line "INPUT_FILE_PATTERN: ."
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
assert_line "::debug::Apply commit options "
|
assert_line "::debug::Apply commit options "
|
||||||
@@ -118,7 +145,11 @@ git_auto_commit() {
|
|||||||
assert_line "No tagging message supplied. No tag will be added."
|
assert_line "No tagging message supplied. No tag will be added."
|
||||||
assert_line "INPUT_PUSH_OPTIONS: "
|
assert_line "INPUT_PUSH_OPTIONS: "
|
||||||
assert_line "::debug::Apply push options "
|
assert_line "::debug::Apply push options "
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
assert_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It applies INPUT_STATUS_OPTIONS when running dirty check" {
|
@test "It applies INPUT_STATUS_OPTIONS when running dirty check" {
|
||||||
@@ -131,9 +162,11 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::false"
|
|
||||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "Working tree clean. Nothing to commit."
|
assert_line "Working tree clean. Nothing to commit."
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=false"
|
||||||
|
refute_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It prints a 'Nothing to commit' message in a clean repository" {
|
@test "It prints a 'Nothing to commit' message in a clean repository" {
|
||||||
@@ -142,9 +175,11 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::false"
|
|
||||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "Working tree clean. Nothing to commit."
|
assert_line "Working tree clean. Nothing to commit."
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=false"
|
||||||
|
refute_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "If SKIP_DIRTY_CHECK is set to true on a clean repo it fails to push" {
|
@test "If SKIP_DIRTY_CHECK is set to true on a clean repo it fails to push" {
|
||||||
@@ -155,19 +190,21 @@ git_auto_commit() {
|
|||||||
assert_failure
|
assert_failure
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
assert_line "INPUT_BRANCH value: ${FAKE_DEFAULT_BRANCH}"
|
||||||
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "INPUT_BRANCH value: master"
|
|
||||||
assert_line "INPUT_FILE_PATTERN: ."
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
assert_line "::debug::Apply commit options "
|
assert_line "::debug::Apply commit options "
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
refute_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It applies INPUT_ADD_OPTIONS when adding files" {
|
@test "It applies INPUT_ADD_OPTIONS when adding files" {
|
||||||
INPUT_STATUS_OPTIONS="--untracked-files=no"
|
INPUT_STATUS_OPTIONS="--untracked-files=no"
|
||||||
INPUT_ADD_OPTIONS="-u"
|
INPUT_ADD_OPTIONS="-u"
|
||||||
|
|
||||||
date > "${FAKE_LOCAL_REPOSITORY}"/remote-files1.txt
|
date >"${FAKE_LOCAL_REPOSITORY}"/remote-files1.txt
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
||||||
|
|
||||||
run git_auto_commit
|
run git_auto_commit
|
||||||
@@ -176,7 +213,7 @@ git_auto_commit() {
|
|||||||
|
|
||||||
assert_line "INPUT_STATUS_OPTIONS: --untracked-files=no"
|
assert_line "INPUT_STATUS_OPTIONS: --untracked-files=no"
|
||||||
assert_line "INPUT_ADD_OPTIONS: -u"
|
assert_line "INPUT_ADD_OPTIONS: -u"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Assert that PHP files have not been added.
|
# Assert that PHP files have not been added.
|
||||||
run git status
|
run git status
|
||||||
@@ -186,8 +223,8 @@ git_auto_commit() {
|
|||||||
@test "It applies INPUT_FILE_PATTERN when creating commit" {
|
@test "It applies INPUT_FILE_PATTERN when creating commit" {
|
||||||
INPUT_FILE_PATTERN="src/*.js *.txt *.html"
|
INPUT_FILE_PATTERN="src/*.js *.txt *.html"
|
||||||
|
|
||||||
mkdir src;
|
mkdir src
|
||||||
touch src/new-file-{1,2}.js;
|
touch src/new-file-{1,2}.js
|
||||||
|
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.php
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.html
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2}.html
|
||||||
@@ -197,7 +234,7 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_FILE_PATTERN: src/*.js *.txt *.html"
|
assert_line "INPUT_FILE_PATTERN: src/*.js *.txt *.html"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Assert that PHP files have not been added.
|
# Assert that PHP files have not been added.
|
||||||
run git status
|
run git status
|
||||||
@@ -214,7 +251,7 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: --no-verify --signoff"
|
assert_line "INPUT_COMMIT_OPTIONS: --no-verify --signoff"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Assert last commit was signed off
|
# Assert last commit was signed off
|
||||||
run git log -n 1
|
run git log -n 1
|
||||||
@@ -232,10 +269,10 @@ git_auto_commit() {
|
|||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_COMMIT_USER_NAME: A Single Test";
|
assert_line "INPUT_COMMIT_USER_NAME: A Single Test"
|
||||||
assert_line "INPUT_COMMIT_USER_EMAIL: single-test@github.com";
|
assert_line "INPUT_COMMIT_USER_EMAIL: single-test@github.com"
|
||||||
assert_line "INPUT_COMMIT_AUTHOR: A Single Test <single@users.noreply.github.com>";
|
assert_line "INPUT_COMMIT_AUTHOR: A Single Test <single@users.noreply.github.com>"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Asser last commit was made by the defined user/author
|
# Asser last commit was made by the defined user/author
|
||||||
run git log -1 --pretty=format:'%ae'
|
run git log -1 --pretty=format:'%ae'
|
||||||
@@ -262,7 +299,7 @@ git_auto_commit() {
|
|||||||
|
|
||||||
assert_line "INPUT_TAGGING_MESSAGE: v1.0.0"
|
assert_line "INPUT_TAGGING_MESSAGE: v1.0.0"
|
||||||
assert_line "::debug::Create tag v1.0.0"
|
assert_line "::debug::Create tag v1.0.0"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Assert a tag v1.0.0 has been created
|
# Assert a tag v1.0.0 has been created
|
||||||
run git tag
|
run git tag
|
||||||
@@ -273,8 +310,8 @@ git_auto_commit() {
|
|||||||
|
|
||||||
# Assert that the commit has been pushed with --force and
|
# Assert that the commit has been pushed with --force and
|
||||||
# sha values are equal on local and remote
|
# sha values are equal on local and remote
|
||||||
current_sha="$(git rev-parse --verify --short master)"
|
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/master)"
|
remote_sha="$(git rev-parse --verify --short origin/${FAKE_DEFAULT_BRANCH})"
|
||||||
|
|
||||||
assert_equal $current_sha $remote_sha
|
assert_equal $current_sha $remote_sha
|
||||||
}
|
}
|
||||||
@@ -282,11 +319,10 @@ git_auto_commit() {
|
|||||||
@test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" {
|
@test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" {
|
||||||
|
|
||||||
touch "${FAKE_TEMP_LOCAL_REPOSITORY}"/newer-remote-files{1,2,3}.txt
|
touch "${FAKE_TEMP_LOCAL_REPOSITORY}"/newer-remote-files{1,2,3}.txt
|
||||||
cd "${FAKE_TEMP_LOCAL_REPOSITORY}";
|
cd "${FAKE_TEMP_LOCAL_REPOSITORY}"
|
||||||
git add .;
|
git add .
|
||||||
git commit --quiet -m "Add more remote files";
|
git commit --quiet -m "Add more remote files"
|
||||||
git push origin master;
|
git push origin ${FAKE_DEFAULT_BRANCH}
|
||||||
|
|
||||||
|
|
||||||
INPUT_PUSH_OPTIONS="--force"
|
INPUT_PUSH_OPTIONS="--force"
|
||||||
|
|
||||||
@@ -298,20 +334,20 @@ git_auto_commit() {
|
|||||||
|
|
||||||
assert_line "INPUT_PUSH_OPTIONS: --force"
|
assert_line "INPUT_PUSH_OPTIONS: --force"
|
||||||
assert_line "::debug::Apply push options --force"
|
assert_line "::debug::Apply push options --force"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Assert that the commit has been pushed with --force and
|
# Assert that the commit has been pushed with --force and
|
||||||
# sha values are equal on local and remote
|
# sha values are equal on local and remote
|
||||||
current_sha="$(git rev-parse --verify --short master)"
|
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/master)"
|
remote_sha="$(git rev-parse --verify --short origin/${FAKE_DEFAULT_BRANCH})"
|
||||||
|
|
||||||
assert_equal $current_sha $remote_sha
|
assert_equal $current_sha $remote_sha
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It can checkout a different branch" {
|
@test "It can checkout a different branch" {
|
||||||
# Create foo-branch and then immediately switch back to master
|
# Create foo-branch and then immediately switch back to ${FAKE_DEFAULT_BRANCH}
|
||||||
git checkout -b foo
|
git checkout -b foo
|
||||||
git checkout master
|
git checkout ${FAKE_DEFAULT_BRANCH}
|
||||||
|
|
||||||
INPUT_BRANCH="foo"
|
INPUT_BRANCH="foo"
|
||||||
|
|
||||||
@@ -341,9 +377,9 @@ git_auto_commit() {
|
|||||||
assert_line "INPUT_BRANCH value: "
|
assert_line "INPUT_BRANCH value: "
|
||||||
assert_line --partial "::debug::git push origin"
|
assert_line --partial "::debug::git push origin"
|
||||||
|
|
||||||
# Assert that branch "master" was updated on remote
|
# Assert that branch "${FAKE_DEFAULT_BRANCH}" was updated on remote
|
||||||
current_sha="$(git rev-parse --verify --short master)"
|
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/master)"
|
remote_sha="$(git rev-parse --verify --short origin/${FAKE_DEFAULT_BRANCH})"
|
||||||
|
|
||||||
assert_equal $current_sha $remote_sha
|
assert_equal $current_sha $remote_sha
|
||||||
}
|
}
|
||||||
@@ -419,17 +455,17 @@ git_auto_commit() {
|
|||||||
run git ls-remote --tags --refs
|
run git ls-remote --tags --refs
|
||||||
assert_output --partial refs/tags/v2.0.0
|
assert_output --partial refs/tags/v2.0.0
|
||||||
|
|
||||||
# Assert that branch "master" was updated on remote
|
# Assert that branch "${FAKE_DEFAULT_BRANCH}" was updated on remote
|
||||||
current_sha="$(git rev-parse --verify --short master)"
|
current_sha="$(git rev-parse --verify --short ${FAKE_DEFAULT_BRANCH})"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/master)"
|
remote_sha="$(git rev-parse --verify --short origin/${FAKE_DEFAULT_BRANCH})"
|
||||||
|
|
||||||
assert_equal $current_sha $remote_sha
|
assert_equal $current_sha $remote_sha
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It pushes generated commit and tag to remote branch and updates commit sha" {
|
@test "It pushes generated commit and tag to remote branch and updates commit sha" {
|
||||||
# Create "a-new-branch"-branch and then immediately switch back to master
|
# Create "a-new-branch"-branch and then immediately switch back to ${FAKE_DEFAULT_BRANCH}
|
||||||
git checkout -b a-new-branch
|
git checkout -b a-new-branch
|
||||||
git checkout master
|
git checkout ${FAKE_DEFAULT_BRANCH}
|
||||||
|
|
||||||
INPUT_BRANCH="a-new-branch"
|
INPUT_BRANCH="a-new-branch"
|
||||||
INPUT_TAGGING_MESSAGE="v2.0.0"
|
INPUT_TAGGING_MESSAGE="v2.0.0"
|
||||||
@@ -462,20 +498,20 @@ git_auto_commit() {
|
|||||||
@test "It does not expand wildcard glob when using INPUT_PATTERN and INPUT_DISABLE_GLOBBING in git-status and git-add" {
|
@test "It does not expand wildcard glob when using INPUT_PATTERN and INPUT_DISABLE_GLOBBING in git-status and git-add" {
|
||||||
|
|
||||||
# Create additional files in a nested directory structure
|
# Create additional files in a nested directory structure
|
||||||
echo "Create Additional files";
|
echo "Create Additional files"
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-a.py
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-a.py
|
||||||
mkdir "${FAKE_LOCAL_REPOSITORY}"/nested
|
mkdir "${FAKE_LOCAL_REPOSITORY}"/nested
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py
|
touch "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py
|
||||||
|
|
||||||
# Commit changes
|
# Commit changes
|
||||||
echo "Commit changes before running git_auto_commit";
|
echo "Commit changes before running git_auto_commit"
|
||||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
cd "${FAKE_LOCAL_REPOSITORY}"
|
||||||
git add . > /dev/null;
|
git add . >/dev/null
|
||||||
git commit --quiet -m "Init Remote Repository";
|
git commit --quiet -m "Init Remote Repository"
|
||||||
git push origin master > /dev/null;
|
git push origin ${FAKE_DEFAULT_BRANCH} >/dev/null
|
||||||
|
|
||||||
# Make nested file dirty
|
# Make nested file dirty
|
||||||
echo "foo-bar" > "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py;
|
echo "foo-bar" >"${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
@@ -487,7 +523,7 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_FILE_PATTERN: *.py"
|
assert_line "INPUT_FILE_PATTERN: *.py"
|
||||||
assert_line "::debug::Push commit to remote branch master"
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
# Assert that the updated py file has been commited.
|
# Assert that the updated py file has been commited.
|
||||||
run git status
|
run git status
|
||||||
@@ -504,22 +540,24 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::false"
|
|
||||||
|
|
||||||
run git status
|
run git status
|
||||||
assert_output --partial 'nothing to commit, working tree clean'
|
assert_output --partial 'nothing to commit, working tree clean'
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=false"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It does not throw an error if branch is checked out with same name as a file or folder in the repo" {
|
@test "It does not throw an error if branch is checked out with same name as a file or folder in the repo" {
|
||||||
|
|
||||||
# Add File called dev and commit/push
|
# Add File called dev and commit/push
|
||||||
echo "Create dev file";
|
echo "Create dev file"
|
||||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
cd "${FAKE_LOCAL_REPOSITORY}"
|
||||||
echo this is a file named dev > dev
|
echo this is a file named dev >dev
|
||||||
git add dev
|
git add dev
|
||||||
git commit -m 'add file named dev'
|
git commit -m 'add file named dev'
|
||||||
git update-ref refs/remotes/origin/master master
|
git update-ref refs/remotes/origin/${FAKE_DEFAULT_BRANCH} ${FAKE_DEFAULT_BRANCH}
|
||||||
git update-ref refs/remotes/origin/dev master
|
git update-ref refs/remotes/origin/dev ${FAKE_DEFAULT_BRANCH}
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
@@ -532,8 +570,10 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
|
||||||
assert_line "::debug::Push commit to remote branch dev"
|
assert_line "::debug::Push commit to remote branch dev"
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "script fails to push commit to new branch that does not exist yet" {
|
@test "script fails to push commit to new branch that does not exist yet" {
|
||||||
@@ -553,7 +593,6 @@ git_auto_commit() {
|
|||||||
assert_failure
|
assert_failure
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
|
||||||
assert_line "INPUT_BRANCH value: not-existend-branch"
|
assert_line "INPUT_BRANCH value: not-existend-branch"
|
||||||
assert_line "fatal: invalid reference: not-existend-branch"
|
assert_line "fatal: invalid reference: not-existend-branch"
|
||||||
|
|
||||||
@@ -562,6 +601,9 @@ git_auto_commit() {
|
|||||||
|
|
||||||
run git branch -r
|
run git branch -r
|
||||||
refute_line --partial "origin/not-existend-branch"
|
refute_line --partial "origin/not-existend-branch"
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It creates new local branch and pushes the new branch to remote" {
|
@test "It creates new local branch and pushes the new branch to remote" {
|
||||||
@@ -581,8 +623,6 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
|
||||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "INPUT_BRANCH value: not-existend-branch"
|
assert_line "INPUT_BRANCH value: not-existend-branch"
|
||||||
assert_line "INPUT_FILE_PATTERN: ."
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
@@ -598,12 +638,16 @@ git_auto_commit() {
|
|||||||
|
|
||||||
run git branch -r
|
run git branch -r
|
||||||
assert_line --partial "origin/not-existend-branch"
|
assert_line --partial "origin/not-existend-branch"
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
assert_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "it does not create new local branch if local branch already exists" {
|
@test "it does not create new local branch if local branch already exists" {
|
||||||
|
|
||||||
git checkout -b not-existend-remote-branch
|
git checkout -b not-existend-remote-branch
|
||||||
git checkout master
|
git checkout ${FAKE_DEFAULT_BRANCH}
|
||||||
|
|
||||||
INPUT_BRANCH="not-existend-remote-branch"
|
INPUT_BRANCH="not-existend-remote-branch"
|
||||||
INPUT_CREATE_BRANCH=true
|
INPUT_CREATE_BRANCH=true
|
||||||
@@ -621,8 +665,6 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
|
||||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "INPUT_BRANCH value: not-existend-remote-branch"
|
assert_line "INPUT_BRANCH value: not-existend-remote-branch"
|
||||||
assert_line "INPUT_FILE_PATTERN: ."
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
@@ -638,24 +680,28 @@ git_auto_commit() {
|
|||||||
|
|
||||||
run git branch -r
|
run git branch -r
|
||||||
assert_line --partial "origin/not-existend-remote-branch"
|
assert_line --partial "origin/not-existend-remote-branch"
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
assert_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "it creates new local branch and pushes branch to remote even if the remote branch already exists" {
|
@test "it creates new local branch and pushes branch to remote even if the remote branch already exists" {
|
||||||
|
|
||||||
# Create `existing-remote-branch` on remote with changes the local repository does not yet have
|
# Create `existing-remote-branch` on remote with changes the local repository does not yet have
|
||||||
cd $FAKE_TEMP_LOCAL_REPOSITORY;
|
cd $FAKE_TEMP_LOCAL_REPOSITORY
|
||||||
git checkout -b "existing-remote-branch"
|
git checkout -b "existing-remote-branch"
|
||||||
touch new-branch-file.txt
|
touch new-branch-file.txt
|
||||||
git add new-branch-file.txt
|
git add new-branch-file.txt
|
||||||
git commit -m "Add additional file";
|
git commit -m "Add additional file"
|
||||||
git push origin existing-remote-branch;
|
git push origin existing-remote-branch
|
||||||
|
|
||||||
run git branch;
|
run git branch
|
||||||
assert_line --partial "existing-remote-branch"
|
assert_line --partial "existing-remote-branch"
|
||||||
|
|
||||||
# ---------
|
# ---------
|
||||||
# Switch to our regular local repository and run `git-auto-commit`
|
# Switch to our regular local repository and run `git-auto-commit`
|
||||||
cd $FAKE_LOCAL_REPOSITORY;
|
cd $FAKE_LOCAL_REPOSITORY
|
||||||
|
|
||||||
INPUT_BRANCH="existing-remote-branch"
|
INPUT_BRANCH="existing-remote-branch"
|
||||||
INPUT_CREATE_BRANCH=true
|
INPUT_CREATE_BRANCH=true
|
||||||
@@ -663,9 +709,9 @@ git_auto_commit() {
|
|||||||
run git branch
|
run git branch
|
||||||
refute_line --partial "existing-remote-branch"
|
refute_line --partial "existing-remote-branch"
|
||||||
|
|
||||||
run git fetch --all;
|
run git fetch --all
|
||||||
run git pull origin existing-remote-branch;
|
run git pull origin existing-remote-branch
|
||||||
run git branch -r;
|
run git branch -r
|
||||||
assert_line --partial "origin/existing-remote-branch"
|
assert_line --partial "origin/existing-remote-branch"
|
||||||
|
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
@@ -675,8 +721,6 @@ git_auto_commit() {
|
|||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
assert_line "::set-output name=changes_detected::true"
|
|
||||||
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
|
||||||
assert_line "INPUT_BRANCH value: existing-remote-branch"
|
assert_line "INPUT_BRANCH value: existing-remote-branch"
|
||||||
assert_line "INPUT_FILE_PATTERN: ."
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
assert_line "INPUT_COMMIT_OPTIONS: "
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
@@ -697,24 +741,28 @@ git_auto_commit() {
|
|||||||
current_sha="$(git rev-parse --verify --short existing-remote-branch)"
|
current_sha="$(git rev-parse --verify --short existing-remote-branch)"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/existing-remote-branch)"
|
remote_sha="$(git rev-parse --verify --short origin/existing-remote-branch)"
|
||||||
|
|
||||||
assert_equal $current_sha $remote_sha;
|
assert_equal $current_sha $remote_sha
|
||||||
|
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
assert_line -e "commit_hash=[0-9a-f]{40}$"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "script fails if new local branch is checked out and push fails as remote has newer commits than local" {
|
@test "script fails if new local branch is checked out and push fails as remote has newer commits than local" {
|
||||||
# Create `existing-remote-branch` on remote with changes the local repository does not yet have
|
# Create `existing-remote-branch` on remote with changes the local repository does not yet have
|
||||||
cd $FAKE_TEMP_LOCAL_REPOSITORY;
|
cd $FAKE_TEMP_LOCAL_REPOSITORY
|
||||||
git checkout -b "existing-remote-branch"
|
git checkout -b "existing-remote-branch"
|
||||||
touch new-branch-file.txt
|
touch new-branch-file.txt
|
||||||
git add new-branch-file.txt
|
git add new-branch-file.txt
|
||||||
git commit -m "Add additional file";
|
git commit -m "Add additional file"
|
||||||
git push origin existing-remote-branch;
|
git push origin existing-remote-branch
|
||||||
|
|
||||||
run git branch;
|
run git branch
|
||||||
assert_line --partial "existing-remote-branch"
|
assert_line --partial "existing-remote-branch"
|
||||||
|
|
||||||
# ---------
|
# ---------
|
||||||
# Switch to our regular local repository and run `git-auto-commit`
|
# Switch to our regular local repository and run `git-auto-commit`
|
||||||
cd $FAKE_LOCAL_REPOSITORY;
|
cd $FAKE_LOCAL_REPOSITORY
|
||||||
|
|
||||||
INPUT_BRANCH="existing-remote-branch"
|
INPUT_BRANCH="existing-remote-branch"
|
||||||
INPUT_CREATE_BRANCH=true
|
INPUT_CREATE_BRANCH=true
|
||||||
@@ -722,8 +770,8 @@ git_auto_commit() {
|
|||||||
run git branch
|
run git branch
|
||||||
refute_line --partial "existing-remote-branch"
|
refute_line --partial "existing-remote-branch"
|
||||||
|
|
||||||
run git fetch --all;
|
run git fetch --all
|
||||||
run git branch -r;
|
run git branch -r
|
||||||
assert_line --partial "origin/existing-remote-branch"
|
assert_line --partial "origin/existing-remote-branch"
|
||||||
|
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
@@ -745,26 +793,26 @@ git_auto_commit() {
|
|||||||
current_sha="$(git rev-parse --verify --short existing-remote-branch)"
|
current_sha="$(git rev-parse --verify --short existing-remote-branch)"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/existing-remote-branch)"
|
remote_sha="$(git rev-parse --verify --short origin/existing-remote-branch)"
|
||||||
|
|
||||||
refute [assert_equal $current_sha $remote_sha];
|
refute [assert_equal $current_sha $remote_sha]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It pushes commit to remote if branch already exists and local repo is behind its remote counterpart" {
|
@test "It pushes 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
|
# Create `new-branch` on remote with changes the local repository does not yet have
|
||||||
cd $FAKE_TEMP_LOCAL_REPOSITORY;
|
cd $FAKE_TEMP_LOCAL_REPOSITORY
|
||||||
|
|
||||||
git checkout -b "new-branch"
|
git checkout -b "new-branch"
|
||||||
touch new-branch-file.txt
|
touch new-branch-file.txt
|
||||||
git add new-branch-file.txt
|
git add new-branch-file.txt
|
||||||
|
|
||||||
git commit --quiet -m "Add additional file";
|
git commit --quiet -m "Add additional file"
|
||||||
git push origin new-branch;
|
git push origin new-branch
|
||||||
|
|
||||||
run git branch -r
|
run git branch -r
|
||||||
assert_line --partial "origin/new-branch"
|
assert_line --partial "origin/new-branch"
|
||||||
|
|
||||||
# ---------
|
# ---------
|
||||||
# Switch to our regular local repository and run `git-auto-commit`
|
# Switch to our regular local repository and run `git-auto-commit`
|
||||||
cd $FAKE_LOCAL_REPOSITORY;
|
cd $FAKE_LOCAL_REPOSITORY
|
||||||
|
|
||||||
INPUT_BRANCH="new-branch"
|
INPUT_BRANCH="new-branch"
|
||||||
|
|
||||||
@@ -789,7 +837,7 @@ git_auto_commit() {
|
|||||||
current_sha="$(git rev-parse --verify --short new-branch)"
|
current_sha="$(git rev-parse --verify --short new-branch)"
|
||||||
remote_sha="$(git rev-parse --verify --short origin/new-branch)"
|
remote_sha="$(git rev-parse --verify --short origin/new-branch)"
|
||||||
|
|
||||||
assert_equal $current_sha $remote_sha;
|
assert_equal $current_sha $remote_sha
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "throws fatal error if file pattern includes files that do not exist" {
|
@test "throws fatal error if file pattern includes files that do not exist" {
|
||||||
@@ -825,7 +873,7 @@ git_auto_commit() {
|
|||||||
@test "detects and commits changed files based on pattern in root and subfolders" {
|
@test "detects and commits changed files based on pattern in root and subfolders" {
|
||||||
# Add some .neon files
|
# Add some .neon files
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-1.neon
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-1.neon
|
||||||
mkdir foo;
|
mkdir foo
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/foo/new-file-2.neon
|
touch "${FAKE_LOCAL_REPOSITORY}"/foo/new-file-2.neon
|
||||||
|
|
||||||
INPUT_FILE_PATTERN="**/*.neon *.neon"
|
INPUT_FILE_PATTERN="**/*.neon *.neon"
|
||||||
@@ -847,8 +895,8 @@ git_auto_commit() {
|
|||||||
run git_auto_commit
|
run git_auto_commit
|
||||||
|
|
||||||
# Add our txt files to gitignore
|
# Add our txt files to gitignore
|
||||||
echo "ignored-file.txt" >> "${FAKE_LOCAL_REPOSITORY}"/.gitignore
|
echo "ignored-file.txt" >>"${FAKE_LOCAL_REPOSITORY}"/.gitignore
|
||||||
echo "another-ignored-file.txt" >> "${FAKE_LOCAL_REPOSITORY}"/.gitignore
|
echo "another-ignored-file.txt" >>"${FAKE_LOCAL_REPOSITORY}"/.gitignore
|
||||||
|
|
||||||
# Commit & push .gitignore changes
|
# Commit & push .gitignore changes
|
||||||
run git_auto_commit
|
run git_auto_commit
|
||||||
@@ -856,7 +904,7 @@ git_auto_commit() {
|
|||||||
# Sanity check that txt files are ignored
|
# Sanity check that txt files are ignored
|
||||||
run cat "${FAKE_LOCAL_REPOSITORY}"/.gitignore
|
run cat "${FAKE_LOCAL_REPOSITORY}"/.gitignore
|
||||||
assert_output --partial "ignored-file.txt"
|
assert_output --partial "ignored-file.txt"
|
||||||
assert_output --partial "another-ignored-file.txt";
|
assert_output --partial "another-ignored-file.txt"
|
||||||
|
|
||||||
# Configure git-auto-commit
|
# Configure git-auto-commit
|
||||||
INPUT_SKIP_DIRTY_CHECK=true
|
INPUT_SKIP_DIRTY_CHECK=true
|
||||||
@@ -866,9 +914,9 @@ git_auto_commit() {
|
|||||||
# Run git-auto-commit with special configuration
|
# Run git-auto-commit with special configuration
|
||||||
run git_auto_commit
|
run git_auto_commit
|
||||||
|
|
||||||
assert_output --partial "nothing to commit, working tree clean";
|
assert_output --partial "nothing to commit, working tree clean"
|
||||||
|
|
||||||
assert_failure;
|
assert_failure
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "expands file patterns correctly and commits all changed files" {
|
@test "expands file patterns correctly and commits all changed files" {
|
||||||
@@ -926,33 +974,121 @@ git_auto_commit() {
|
|||||||
assert_line --partial "another-subdirectory/new-file-3.txt"
|
assert_line --partial "another-subdirectory/new-file-3.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "fails to detect crlf change in files and does not detect change or commit changes" {
|
@test "detects if crlf in files change and does not create commit" {
|
||||||
# Set autocrlf to true
|
# Set autocrlf to true
|
||||||
cd "${FAKE_LOCAL_REPOSITORY}";
|
cd "${FAKE_LOCAL_REPOSITORY}"
|
||||||
git config core.autocrlf true
|
git config core.autocrlf true
|
||||||
run git config --get-all core.autocrlf
|
run git config --get-all core.autocrlf
|
||||||
assert_line "true"
|
assert_line "true"
|
||||||
|
|
||||||
# Add more .txt files
|
# Add more .txt files
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt
|
echo -ne "crlf test1\r\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt
|
||||||
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt
|
echo -ne "crlf test1\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt
|
||||||
|
|
||||||
# Run git-auto-commit to add new files to repository
|
# Run git-auto-commit to add new files to repository
|
||||||
run git_auto_commit
|
run git_auto_commit
|
||||||
|
|
||||||
# Change control characters in files
|
# Change control characters in files
|
||||||
sed 's/^M$//' "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt
|
echo -ne "crlf test1\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt
|
||||||
sed 's/$/^M/' "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt
|
echo -ne "crlf test1\r\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt
|
||||||
|
|
||||||
# Run git-auto-commit to commit the 2 changes files
|
# Run git-auto-commit to commit the 2 changes files
|
||||||
run git_auto_commit
|
run git_auto_commit
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
# Changes are not detected
|
refute_line --partial "2 files changed, 2 insertions(+), 2 deletions(-)"
|
||||||
assert_line --partial "Working tree clean. Nothing to commit."
|
assert_line --partial "warning: in the working copy of 'new-file-2.txt', LF will be replaced by CRLF the next time Git touches it"
|
||||||
|
|
||||||
refute_line --partial "new-file-2.txt"
|
assert_line --partial "Working tree clean. Nothing to commit."
|
||||||
refute_line --partial "new-file-3.txt"
|
assert_line --partial "new-file-2.txt"
|
||||||
|
assert_line --partial "new-file-3.txt"
|
||||||
|
|
||||||
|
# Changes are not detected
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=false"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "detects if crlf in files change and creates commit if the actual content of the files change" {
|
||||||
|
# Set autocrlf to true
|
||||||
|
cd "${FAKE_LOCAL_REPOSITORY}"
|
||||||
|
git config core.autocrlf true
|
||||||
|
run git config --get-all core.autocrlf
|
||||||
|
assert_line "true"
|
||||||
|
|
||||||
|
# Add more .txt files
|
||||||
|
echo -ne "crlf test1\r\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt
|
||||||
|
echo -ne "crlf test1\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt
|
||||||
|
|
||||||
|
# Run git-auto-commit to add new files to repository
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
# Change control characters in files
|
||||||
|
echo -ne "crlf test2\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-2.txt
|
||||||
|
echo -ne "crlf test2\r\n" > "${FAKE_LOCAL_REPOSITORY}"/new-file-3.txt
|
||||||
|
|
||||||
|
# Run git-auto-commit to commit the 2 changes files
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_line --partial "2 files changed, 2 insertions(+), 2 deletions(-)"
|
||||||
|
assert_line --partial "warning: in the working copy of 'new-file-2.txt', LF will be replaced by CRLF the next time Git touches it"
|
||||||
|
|
||||||
|
assert_line --partial "new-file-2.txt"
|
||||||
|
assert_line --partial "new-file-3.txt"
|
||||||
|
|
||||||
|
# Changes are detected
|
||||||
|
run cat_github_output
|
||||||
|
assert_line "changes_detected=true"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "It uses old set-output syntax if GITHUB_OUTPUT environment is not available when changes are committed" {
|
||||||
|
unset GITHUB_OUTPUT
|
||||||
|
|
||||||
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
|
assert_line "INPUT_BRANCH value: ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
assert_line "INPUT_FILE_PATTERN: ."
|
||||||
|
assert_line "INPUT_COMMIT_OPTIONS: "
|
||||||
|
assert_line "::debug::Apply commit options "
|
||||||
|
assert_line "INPUT_TAGGING_MESSAGE: "
|
||||||
|
assert_line "No tagging message supplied. No tag will be added."
|
||||||
|
assert_line "INPUT_PUSH_OPTIONS: "
|
||||||
|
assert_line "::debug::Apply push options "
|
||||||
|
assert_line "::debug::Push commit to remote branch ${FAKE_DEFAULT_BRANCH}"
|
||||||
|
|
||||||
|
assert_line "::set-output name=changes_detected::true"
|
||||||
|
assert_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "It uses old set-output syntax if GITHUB_OUTPUT environment is not available when no changes have been detected" {
|
||||||
|
unset GITHUB_OUTPUT
|
||||||
|
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_line "INPUT_REPOSITORY value: ${INPUT_REPOSITORY}"
|
||||||
|
assert_line "Working tree clean. Nothing to commit."
|
||||||
|
|
||||||
|
assert_line "::set-output name=changes_detected::false"
|
||||||
|
refute_line -e "::set-output name=commit_hash::[0-9a-f]{40}$"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "It fails hard if git is not available" {
|
||||||
|
INPUT_INTERNAL_GIT_BINARY=binary-does-not-exist
|
||||||
|
|
||||||
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_failure;
|
||||||
|
assert_line "::error ::git-auto-commit could not find git binary. Please make sure git is available."
|
||||||
|
}
|
||||||
|
@@ -10,7 +10,7 @@ bats-support@ztombol/bats-support:
|
|||||||
version "0.3.0"
|
version "0.3.0"
|
||||||
resolved "https://codeload.github.com/ztombol/bats-support/tar.gz/004e707638eedd62e0481e8cdc9223ad471f12ee"
|
resolved "https://codeload.github.com/ztombol/bats-support/tar.gz/004e707638eedd62e0481e8cdc9223ad471f12ee"
|
||||||
|
|
||||||
bats@^1.1.0:
|
bats@^1.8.2:
|
||||||
version "1.7.0"
|
version "1.8.2"
|
||||||
resolved "https://registry.yarnpkg.com/bats/-/bats-1.7.0.tgz#caae958b1d211eda6b1322ac7792515de40165a2"
|
resolved "https://registry.yarnpkg.com/bats/-/bats-1.8.2.tgz#bdbaa7690a18f04291b35144a8ce5435cffb8dc5"
|
||||||
integrity sha512-pt5zjJQUB4+JI8Si+z/IAWc8yhMyhdZs6IXMCKgzF768dUIyW5xyBstWtDI5uGSa80v7UQOhh+w0GA4p4+01Bg==
|
integrity sha512-KLUIaPYuIMjqui8MbZmK84+CiwhjFVFAhFy5PXP0prLbkovc5faVzc+Qaowbz76F97zP573JrF31ODFAH7vzhg==
|
||||||
|
Reference in New Issue
Block a user