mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-08-04 01:36:11 +08:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
48d37c1ffb | ||
|
4c05e3d58e | ||
|
3053f48bdd | ||
|
cfd366418e | ||
|
be370eccae | ||
|
f4f9aedbee | ||
|
e610a5104b | ||
|
be7095c202 | ||
|
ae9ae1b5b8 | ||
|
e944668910 | ||
|
9bb0fd2324 | ||
|
175c2cd836 |
14
CHANGELOG.md
14
CHANGELOG.md
@@ -4,11 +4,23 @@ 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.9.1...HEAD)
|
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.10.0...HEAD)
|
||||||
|
|
||||||
> TBD
|
> TBD
|
||||||
|
|
||||||
|
|
||||||
|
## [v4.10.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.2...v4.10.0) - 2021-04-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add `disable_globbing` option [#153](https://github.com/stefanzweifel/git-auto-commit-action/issues/153), [#154](https://github.com/stefanzweifel/git-auto-commit-action/pull/154)
|
||||||
|
|
||||||
|
|
||||||
|
## [v4.9.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.1...v4.9.2) - 2021-03-04
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Push created annotated tags to remote by using `--follow-tags` and `--atomic` instead of just `--tags` [#146](https://github.com/stefanzweifel/git-auto-commit-action/pull/146)
|
||||||
|
|
||||||
|
|
||||||
## [v4.9.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.0...v4.9.1) - 2021-02-23
|
## [v4.9.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.9.0...v4.9.1) - 2021-02-23
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@@ -70,6 +70,9 @@ This is a more extended example with all possible options.
|
|||||||
|
|
||||||
# Optional: Skip internal call to `git fetch`
|
# Optional: Skip internal call to `git fetch`
|
||||||
skip_fetch: true
|
skip_fetch: true
|
||||||
|
|
||||||
|
# Optional: Prevents the shell from expanding filenames. Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
|
||||||
|
disable_globbing: true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
@@ -52,6 +52,9 @@ inputs:
|
|||||||
description: Skip the call to git-fetch.
|
description: Skip the call to git-fetch.
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
disable_globbing:
|
||||||
|
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
|
||||||
|
default: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
changes_detected:
|
changes_detected:
|
||||||
|
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
if "$INPUT_DISABLE_GLOBBING"; then
|
||||||
|
set -o noglob;
|
||||||
|
fi
|
||||||
|
|
||||||
_main() {
|
_main() {
|
||||||
_switch_to_repository
|
_switch_to_repository
|
||||||
|
|
||||||
@@ -104,7 +108,7 @@ _push_to_github() {
|
|||||||
if [ -n "$INPUT_TAGGING_MESSAGE" ]
|
if [ -n "$INPUT_TAGGING_MESSAGE" ]
|
||||||
then
|
then
|
||||||
echo "::debug::git push origin --tags";
|
echo "::debug::git push origin --tags";
|
||||||
git push origin --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
git push origin --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||||
else
|
else
|
||||||
echo "::debug::git push origin";
|
echo "::debug::git push origin";
|
||||||
git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||||
@@ -112,7 +116,7 @@ _push_to_github() {
|
|||||||
|
|
||||||
else
|
else
|
||||||
echo "::debug::Push commit to remote branch $INPUT_BRANCH";
|
echo "::debug::Push commit to remote branch $INPUT_BRANCH";
|
||||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --follow-tags --atomic ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,7 @@ setup() {
|
|||||||
export INPUT_PUSH_OPTIONS=""
|
export INPUT_PUSH_OPTIONS=""
|
||||||
export INPUT_SKIP_DIRTY_CHECK=false
|
export INPUT_SKIP_DIRTY_CHECK=false
|
||||||
export INPUT_SKIP_FETCH=false
|
export INPUT_SKIP_FETCH=false
|
||||||
|
export INPUT_DISABLE_GLOBBING=false
|
||||||
|
|
||||||
# Configure Git
|
# Configure Git
|
||||||
if [[ -z $(git config user.name) ]]; then
|
if [[ -z $(git config user.name) ]]; then
|
||||||
@@ -225,6 +226,13 @@ git_auto_commit() {
|
|||||||
|
|
||||||
run git ls-remote --tags --refs
|
run git ls-remote --tags --refs
|
||||||
assert_output --partial refs/tags/v1.0.0
|
assert_output --partial refs/tags/v1.0.0
|
||||||
|
|
||||||
|
# Assert that the commit has been pushed with --force and
|
||||||
|
# sha values are equal on local and remote
|
||||||
|
current_sha="$(git rev-parse --verify --short master)"
|
||||||
|
remote_sha="$(git rev-parse --verify --short origin/master)"
|
||||||
|
|
||||||
|
assert_equal $current_sha $remote_sha
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" {
|
@test "It applies INPUT_PUSH_OPTIONS when pushing commit to remote" {
|
||||||
@@ -331,3 +339,100 @@ git_auto_commit() {
|
|||||||
|
|
||||||
assert_line "::debug::git-fetch has not been executed"
|
assert_line "::debug::git-fetch has not been executed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "It pushes generated commit and tag to remote and actually updates the commit shas" {
|
||||||
|
INPUT_BRANCH=""
|
||||||
|
INPUT_TAGGING_MESSAGE="v2.0.0"
|
||||||
|
|
||||||
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_line "INPUT_TAGGING_MESSAGE: v2.0.0"
|
||||||
|
assert_line "::debug::Create tag v2.0.0"
|
||||||
|
assert_line "::debug::git push origin --tags"
|
||||||
|
|
||||||
|
# Assert a tag v2.0.0 has been created
|
||||||
|
run git tag
|
||||||
|
assert_output v2.0.0
|
||||||
|
|
||||||
|
# Assert tag v2.0.0 has been pushed to remote
|
||||||
|
run git ls-remote --tags --refs
|
||||||
|
assert_output --partial refs/tags/v2.0.0
|
||||||
|
|
||||||
|
# Assert that branch "master" was updated on remote
|
||||||
|
current_sha="$(git rev-parse --verify --short master)"
|
||||||
|
remote_sha="$(git rev-parse --verify --short origin/master)"
|
||||||
|
|
||||||
|
assert_equal $current_sha $remote_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
|
||||||
|
git checkout -b a-new-branch
|
||||||
|
git checkout master
|
||||||
|
|
||||||
|
INPUT_BRANCH="a-new-branch"
|
||||||
|
INPUT_TAGGING_MESSAGE="v2.0.0"
|
||||||
|
|
||||||
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-{1,2,3}.txt
|
||||||
|
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_line "INPUT_TAGGING_MESSAGE: v2.0.0"
|
||||||
|
assert_line "::debug::Create tag v2.0.0"
|
||||||
|
assert_line "::debug::Push commit to remote branch a-new-branch"
|
||||||
|
|
||||||
|
# Assert a tag v2.0.0 has been created
|
||||||
|
run git tag
|
||||||
|
assert_output v2.0.0
|
||||||
|
|
||||||
|
# Assert tag v2.0.0 has been pushed to remote
|
||||||
|
run git ls-remote --tags --refs
|
||||||
|
assert_output --partial refs/tags/v2.0.0
|
||||||
|
|
||||||
|
# Assert that branch "a-new-branch" was updated on remote
|
||||||
|
current_sha="$(git rev-parse --verify --short a-new-branch)"
|
||||||
|
remote_sha="$(git rev-parse --verify --short origin/a-new-branch)"
|
||||||
|
|
||||||
|
assert_equal $current_sha $remote_sha
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
echo "Create Additional files";
|
||||||
|
touch "${FAKE_LOCAL_REPOSITORY}"/new-file-a.py
|
||||||
|
mkdir "${FAKE_LOCAL_REPOSITORY}"/nested
|
||||||
|
touch "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py
|
||||||
|
|
||||||
|
# Commit changes
|
||||||
|
echo "Commit changes before running git_auto_commit";
|
||||||
|
cd "${FAKE_LOCAL_REPOSITORY}";
|
||||||
|
git add . > /dev/null;
|
||||||
|
git commit --quiet -m "Init Remote Repository";
|
||||||
|
git push origin master > /dev/null;
|
||||||
|
|
||||||
|
# Make nested file dirty
|
||||||
|
echo "foo-bar" > "${FAKE_LOCAL_REPOSITORY}"/nested/new-file-b.py;
|
||||||
|
|
||||||
|
# ---
|
||||||
|
|
||||||
|
INPUT_FILE_PATTERN="*.py"
|
||||||
|
INPUT_DISABLE_GLOBBING=true
|
||||||
|
|
||||||
|
run git_auto_commit
|
||||||
|
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
assert_line "INPUT_FILE_PATTERN: *.py"
|
||||||
|
assert_line "::debug::Push commit to remote branch master"
|
||||||
|
|
||||||
|
# Assert that the updated py file has been commited.
|
||||||
|
run git status
|
||||||
|
refute_output --partial 'nested/new-file-b.py'
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user