Skip to content

Commit

Permalink
Revert "Feature: Checkout Options"
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel authored Oct 22, 2020
1 parent 30cd17b commit 25cac34
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 48 deletions.
1 change: 0 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ jobs:
uses: github/super-linter@v3
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_MARKDOWN: false
DEFAULT_BRANCH: master
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ Add the following step at the end of your job, after other steps that might add

# Optional: Disable dirty check and always try to create a commit and push
skip_dirty_check: true

# Optional: Allows you to update how the repo is checked out
checkout_options: '-q --force -b'
```
## Example
Expand Down
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ inputs:
description: Push options (eg. --force)
required: false
default: ''
checkout_options:
description: Checkout options (eg. --branch)
required: false
default: ''
skip_dirty_check:
description: Skip the check if the git repository is dirty and always try to create a commit.
required: false
Expand Down
8 changes: 2 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ _main() {

_switch_to_repository() {
echo "INPUT_REPOSITORY value: $INPUT_REPOSITORY";
cd "$INPUT_REPOSITORY";
cd $INPUT_REPOSITORY;
}

_git_is_dirty() {
# shellcheck disable=SC2086
[ -n "$(git status -s -- $INPUT_FILE_PATTERN)" ]
}

Expand All @@ -43,11 +42,8 @@ _switch_to_branch() {
# Fetch remote to make sure that repo can be switched to the right branch.
git fetch;

# shellcheck disable=SC2206
INPUT_CHECKOUT_OPTIONS_ARRAY=( $INPUT_CHECKOUT_OPTIONS );

# Switch to branch from current Workflow run
git checkout ${INPUT_CHECKOUT_OPTIONS:+"${INPUT_CHECKOUT_OPTIONS_ARRAY[@]}"} "$INPUT_BRANCH" --;
git checkout "$INPUT_BRANCH" --;
}

_add_files() {
Expand Down
34 changes: 0 additions & 34 deletions tests/git-auto-commit-mocked.bats
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ setup() {
export INPUT_COMMIT_AUTHOR="Test Suite <test@users.noreply.github.com>"
export INPUT_TAGGING_MESSAGE=""
export INPUT_PUSH_OPTIONS=""
export INPUT_CHECKOUT_OPTIONS=""
export INPUT_SKIP_DIRTY_CHECK=false

skipIfNot "$BATS_TEST_DESCRIPTION"
Expand Down Expand Up @@ -309,39 +308,6 @@ main() {

}

@test "git-checkout-options-are-applied" {

INPUT_CHECKOUT_OPTIONS="-b --progress"

touch "${test_repository}"/new-file-{1,2,3}.txt

shellmock_expect git --type partial --output " M new-file-1.txt M new-file-2.txt M new-file-3.txt" --match "status"
shellmock_expect git --type exact --match "fetch"
shellmock_expect git --type exact --match "checkout -b --progress master --"
shellmock_expect git --type partial --match "add ."
shellmock_expect git --type partial --match '-c'
shellmock_expect git --type partial --match 'push --set-upstream origin'

run main

echo "$output"

# Success Exit Code
[ "$status" = 0 ]

[ "${lines[10]}" = "::debug::Push commit to remote branch master" ]


shellmock_verify
[ "${capture[0]}" = "git-stub status -s -- ." ]
[ "${capture[1]}" = "git-stub fetch" ]
[ "${capture[2]}" = "git-stub checkout -b --progress master --" ]
[ "${capture[3]}" = "git-stub add ." ]
[ "${capture[4]}" = "git-stub -c user.name=Test Suite -c user.email=test@github.com commit -m Commit Message --author=Test Suite <test@users.noreply.github.com>" ]
[ "${capture[5]}" = "git-stub push --set-upstream origin HEAD:master --tags" ]

}

@test "can-checkout-different-branch" {

INPUT_BRANCH="foo"
Expand Down

0 comments on commit 25cac34

Please sign in to comment.