Restore skip_fetch, skip_checkout, create_branch

This commit is contained in:
Stefan Zweifel
2025-09-17 11:02:55 +02:00
parent 01d77ca6cb
commit 2da8d963b4
3 changed files with 49 additions and 11 deletions

View File

@@ -105,10 +105,19 @@ The following is an extended example with all available options.
# Optional. Disable dirty check and always try to create a commit and push # Optional. Disable dirty check and always try to create a commit and push
skip_dirty_check: true skip_dirty_check: true
# Optional. Skip internal call to `git fetch`
skip_fetch: true
# Optional. Skip internal call to `git checkout`
skip_checkout: true
# Optional. Prevents the shell from expanding filenames. # Optional. Prevents the shell from expanding filenames.
# Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html # Details: https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html
disable_globbing: true disable_globbing: true
# Optional. Create given branch name in local and remote repository.
create_branch: true
# Optional. Creates a new tag and pushes it to remote without creating a commit. # Optional. Creates a new tag and pushes it to remote without creating a commit.
# Skips dirty check and changed files. Must be used with `tagging_message`. # Skips dirty check and changed files. Must be used with `tagging_message`.
create_git_tag_only: false create_git_tag_only: false
@@ -412,6 +421,7 @@ The steps in your workflow might look like this:
commit_message: ${{ steps.last-commit.outputs.message }} commit_message: ${{ steps.last-commit.outputs.message }}
commit_options: '--amend --no-edit' commit_options: '--amend --no-edit'
push_options: '--force' push_options: '--force'
skip_fetch: true
``` ```
See discussion in [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) for details. See discussion in [#159](https://github.com/stefanzweifel/git-auto-commit-action/issues/159#issuecomment-845347950) for details.

View File

@@ -56,9 +56,20 @@ inputs:
description: Skip the check if the git repository is dirty and always try to create a commit. description: Skip the check if the git repository is dirty and always try to create a commit.
required: false required: false
default: false default: false
skip_fetch:
description: Skip the call to git-fetch.
required: false
default: false
skip_checkout:
description: Skip the call to git-checkout.
required: false
default: false
disable_globbing: disable_globbing:
description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html) description: Stop the shell from expanding filenames (https://www.gnu.org/software/bash/manual/html_node/Filename-Expansion.html)
default: false default: false
create_branch:
description: Create new branch with the name of `branch`-input in local and remote repository, if it doesn't exist yet.
default: false
create_git_tag_only: create_git_tag_only:
description: Perform a clean git tag and push, without commiting anything description: Perform a clean git tag and push, without commiting anything
required: false required: false
@@ -66,17 +77,6 @@ inputs:
internal_git_binary: internal_git_binary:
description: Internal use only! Path to git binary used to check if git is available. (Don't change this!) description: Internal use only! Path to git binary used to check if git is available. (Don't change this!)
default: git default: git
skip_fetch:
description: "Deprecated: skip_fetch has been removed in v6. It does not have any effect anymore."
required: false
default: false
skip_checkout:
description: "Deprecated: skip_checkout has been removed in v6. It does not have any effect anymore."
required: false
default: false
create_branch:
description: "Deprecated: create_branch has been removed in v6. It does not have any effect anymore."
default: false
outputs: outputs:

View File

@@ -56,6 +56,8 @@ _main() {
_set_github_output "changes_detected" "true" _set_github_output "changes_detected" "true"
_switch_to_branch
_add_files _add_files
# Check dirty state of repo again using git-diff. # Check dirty state of repo again using git-diff.
@@ -127,6 +129,32 @@ _check_if_repository_is_in_detached_state() {
fi fi
} }
_switch_to_branch() {
echo "INPUT_BRANCH value: $INPUT_BRANCH";
# Fetch remote to make sure that repo can be switched to the right branch.
if "$INPUT_SKIP_FETCH"; then
_log "debug" "git-fetch will not be executed.";
else
git fetch --depth=1;
fi
# If `skip_checkout`-input is true, skip the entire checkout step.
if "$INPUT_SKIP_CHECKOUT"; then
_log "debug" "git-checkout will not be executed.";
else
# Create new local branch if `create_branch`-input is true
if "$INPUT_CREATE_BRANCH"; then
# shellcheck disable=SC2086
git checkout -B $INPUT_BRANCH --;
else
# Switch to branch from current Workflow run
# shellcheck disable=SC2086
git checkout $INPUT_BRANCH --;
fi
fi
}
_add_files() { _add_files() {
echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}"; echo "INPUT_ADD_OPTIONS: ${INPUT_ADD_OPTIONS}";
_log "debug" "Apply add options ${INPUT_ADD_OPTIONS}"; _log "debug" "Apply add options ${INPUT_ADD_OPTIONS}";