From 9aefe3c6240e2fc95db0da2871508451c27291df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 7 Jul 2025 19:43:20 +0000 Subject: [PATCH 1/4] Initial plan From 1532162ca74522a1352ce83ac5c77ca7595d694d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 7 Jul 2025 19:47:56 +0000 Subject: [PATCH 2/4] Add force_without_lease parameter to allow true --force push Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> --- README.md | 4 +++- action.yml | 4 ++++ entrypoint.sh | 8 ++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7de05a6..2c2d6ab 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Features: commit_prefix: "[AUTO]" commit_message: "Automatic commit" force: false + force_without_lease: false target_branch: update/version ``` @@ -58,7 +59,8 @@ Features: | amend | No | `false` | Whether to make amendment to the previous commit (`--amend`). Cannot be used together with `commit_message` or `commit_prefix`. | | commit_prefix | No | `""` | Prefix added to commit message. Combines with `commit_message`. | | commit_message | No | `""` | Commit message to set. Combines with `commit_prefix`. Cannot be used together with `amend`. | -| force | No | `false` | Whether to use force push for fast-forward changes (`--force`). Use only if necessary, e.g. when using `--amend`. And set `fetch-depth: 0` for `actions/checkout`. | +| force | No | `false` | Whether to use force push with lease (`--force-with-lease`). Use only if necessary, e.g. when using `--amend`. And set `fetch-depth: 0` for `actions/checkout`. | +| force_without_lease | No | `false` | Whether to use force push without lease (`--force`). Use only when you need to overwrite remote changes. Potentially dangerous. | | no_edit | No | `false` | Whether to not edit commit message when using amend (`--no-edit`). | | organization_domain | No | `github.com` | Github Enterprise domain name. | | target_branch | No | *current branch* | Name of a new branch to push the code into. Creates branch if not existing. | diff --git a/action.yml b/action.yml index 9f086c8..90c4ae9 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,10 @@ inputs: description: Whether to force push required: false default: "false" + force_without_lease: + description: Whether to force push without lease (--force instead of --force-with-lease) + required: false + default: "false" no_edit: description: Whether to not edit commit message when using amend required: false diff --git a/entrypoint.sh b/entrypoint.sh index 88af7fb..70d2cf6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,6 +11,7 @@ echo " amend: ${INPUT_AMEND}" echo " commit_prefix: ${INPUT_COMMIT_PREFIX}" echo " commit_message: ${INPUT_COMMIT_MESSAGE}" echo " force: ${INPUT_FORCE}" +echo " force_without_lease: ${INPUT_FORCE_WITHOUT_LEASE}" echo " no_edit: ${INPUT_NO_EDIT}" echo " organization_domain: ${INPUT_ORGANIZATION_DOMAIN}" echo " target_branch: ${INPUT_TARGET_BRANCH}" @@ -76,8 +77,11 @@ if [[ -n ${FILES_CHANGED} ]]; then fi # Push -if [[ "${INPUT_FORCE}" == "true" ]]; then - echo "[INFO] Force pushing changes" +if [[ "${INPUT_FORCE_WITHOUT_LEASE}" == "true" ]]; then + echo "[INFO] Force pushing changes without lease" + git push --force origin "${BRANCH}" +elif [[ "${INPUT_FORCE}" == "true" ]]; then + echo "[INFO] Force pushing changes with lease" git push --force-with-lease origin "${BRANCH}" elif [[ -n ${FILES_CHANGED} ]]; then echo "[INFO] Pushing changes" From ab7e225cfb7935038b7f5c31c0318b998fded53e Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Mon, 7 Jul 2025 22:25:48 +0200 Subject: [PATCH 3/4] fix git-lfs config issue --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b57630e..44558ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,8 +22,14 @@ RUN chmod +x /entrypoint.sh ;\ add-apt-repository ppa:git-core/ppa ;\ apt-get update -y ;\ apt-get install --no-install-recommends -y \ - git \ - git-lfs ;\ + git ;\ + # Install git-lfs without post-install configuration to avoid dpkg errors + apt-get download git-lfs ;\ + dpkg --unpack git-lfs*.deb ;\ + rm -f /var/lib/dpkg/info/git-lfs.postinst ;\ + dpkg --configure git-lfs ;\ + apt-get install -f ;\ + rm git-lfs*.deb ;\ apt-get clean ;\ rm -rf /var/lib/apt/lists/* From fc74270035c0f7195c11f15d6d85e2c7af5835b6 Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Mon, 7 Jul 2025 22:33:11 +0200 Subject: [PATCH 4/4] lint Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 44558ee..77e8a56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,7 @@ RUN chmod +x /entrypoint.sh ;\ dpkg --unpack git-lfs*.deb ;\ rm -f /var/lib/dpkg/info/git-lfs.postinst ;\ dpkg --configure git-lfs ;\ - apt-get install -f ;\ + apt-get install -f --no-install-recommends -y ;\ rm git-lfs*.deb ;\ apt-get clean ;\ rm -rf /var/lib/apt/lists/*