Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.
This repository was archived by the owner on May 7, 2024. It is now read-only.

When a squash! message is included, /autosquash fails. #111

Description

@githubdev58yashi

If the commit message contains squash!, invoking action with the /autosquash comment will result in an error.
Please update the Installation in the README as it describes a tentative solution.

Error commit message:

squash! update file.txt

Executed rebase.yml:

on:
  issue_comment:
    types: [created]
jobs:
  rebase:
    name: Rebase
    runs-on: ubuntu-latest
    if: >-
      github.event.issue.pull_request != '' && 
      (
        contains(github.event.comment.body, '/rebase') || 
        contains(github.event.comment.body, '/autosquash')
      )
    steps:
      - name: Checkout the latest code
        uses: actions/checkout@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
      - name: Automatic Rebase
        uses: cirrus-actions/rebase@1.8
        with:
          autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

GithubActions error log:

##[group]Run cirrus-actions/rebase@1.8
with:
  autosquash: true
env:
  GITHUB_TOKEN: ***
##[endgroup]
##[command]/usr/bin/docker run --name de2f69ae319184d0241798d11f98376a2cf86_718cfc --label 9de2f6 --workdir /github/workspace --rm -e "GITHUB_TOKEN" -e "INPUT_AUTOSQUASH" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/github-actions-test/github-actions-test":"/github/workspace" 9de2f6:9ae319184d0241798d11f98376a2cf86
Collecting information about PR #5 of githubdev58yashi/github-actions-test...
Base branch for PR #5 is main
+ git fetch origin main
From https://github.com/githubdev58yashi/github-actions-test
 * branch            main       -> FETCH_HEAD
+ git fetch fork feature/rebase-branch1
From https://github.com/githubdev58yashi/github-actions-test
 * branch            feature/rebase-branch1 -> FETCH_HEAD
 * [new branch]      feature/rebase-branch1 -> fork/feature/rebase-branch1
+ git checkout -b fork/feature/rebase-branch1 fork/feature/rebase-branch1
branch 'fork/feature/rebase-branch1' set up to track 'fork/feature/rebase-branch1'.
Switched to a new branch 'fork/feature/rebase-branch1'
+ [[ true == \t\r\u\e ]]
+ GIT_SEQUENCE_EDITOR=:
+ git rebase -i --autosquash origin/main
Rebasing (2/2)
error: Terminal is dumb, but EDITOR unset
Please supply the message using either -m or -F option.
Could not apply 41c4d8e... squash! update file.txt

The GIT_SEQUENCE_EDITOR setting is described in the entrypoint.sh, but it does not appear to be working well.

rebase/entrypoint.sh

Lines 103 to 107 in 297443e

if [[ $INPUT_AUTOSQUASH == 'true' ]]; then
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash origin/$BASE_BRANCH
else
git rebase origin/$BASE_BRANCH
fi

The tentative solution to this error is to add the GIT_EDITOR setting to the yml.

Fixed rebase.yml:

on:
  issue_comment:
    types: [created]
jobs:
  rebase:
    name: Rebase
    runs-on: ubuntu-latest
    if: >-
      github.event.issue.pull_request != '' && 
      (
        contains(github.event.comment.body, '/rebase') || 
        contains(github.event.comment.body, '/autosquash')
      )
    steps:
      - name: Checkout the latest code
        uses: actions/checkout@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
      - name: Automatic Rebase
        uses: cirrus-actions/rebase@1.8
        with:
          autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # add GIT_EDITOR config
          GIT_EDITOR: ':'

Perhaps adding the GIT_EDITOR setting to entrypoint.sh could also solve the error.
However, this has not been tested.

Modified entrypoint.sh:

if [[ $INPUT_AUTOSQUASH == 'true' ]]; then
	GIT_EDITOR=: GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash origin/$BASE_BRANCH
else
	git rebase origin/$BASE_BRANCH
fi

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions