Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: stefanzweifel/git-auto-commit-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.9.1
Choose a base ref
...
head repository: stefanzweifel/git-auto-commit-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.9.2
Choose a head ref
  • 5 commits
  • 3 files changed
  • 2 contributors

Commits on Feb 26, 2021

  1. Add failing tests

    stefanzweifel committed Feb 26, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    175c2cd View commit details
  2. Push tags by using —follow-tags and —atomic

    By using —follow-tags we push all annotated tags alongside the commit to the remote repository.
    In addition, we’re using —atomic. This ensures that all refs are updated.
    
    - https://github.blog/2015-04-30-git-2-4-atomic-pushes-push-to-deploy-and-more/#atomic-pushes
    - https://stackoverflow.com/a/3745250
    - https://therightstuff.medium.com/the-rights-and-wrongs-of-git-push-with-tags-998667eaed8f
    stefanzweifel committed Feb 26, 2021
    1

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9bb0fd2 View commit details

Commits on Mar 2, 2021

  1. Merge pull request #146 from stefanzweifel/fixes/145

    Push Tags along with Commits
    stefanzweifel authored Mar 2, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e944668 View commit details
  2. Update Changelog

    stefanzweifel committed Mar 2, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ae9ae1b View commit details

Commits on Mar 4, 2021

  1. Release v4.9.2

    stefanzweifel committed Mar 4, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    be7095c View commit details
Showing with 77 additions and 3 deletions.
  1. +6 −1 CHANGELOG.md
  2. +2 −2 entrypoint.sh
  3. +69 −0 tests/git-auto-commit.bats
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,10 +4,15 @@ 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/)
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.9.2...HEAD)

> TBD
## [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

4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -104,15 +104,15 @@ _push_to_github() {
if [ -n "$INPUT_TAGGING_MESSAGE" ]
then
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
echo "::debug::git push origin";
git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"};
fi

else
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
}

69 changes: 69 additions & 0 deletions tests/git-auto-commit.bats
Original file line number Diff line number Diff line change
@@ -225,6 +225,13 @@ git_auto_commit() {

run git ls-remote --tags --refs
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" {
@@ -331,3 +338,65 @@ git_auto_commit() {

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
}