Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: The head commit for this pull_request event is not ahead of the base commit #42

Open
bstuff opened this issue Sep 8, 2021 · 5 comments

Comments

@bstuff
Copy link

bstuff commented Sep 8, 2021

Error output in GitHub action pushed me to create this issue:
image

./.github/workflows/check-codestyle.yml

name: Check codestyle

on:
  pull_request:
    types:
      - opened
      - synchronize

jobs:
  php-cs-fixer:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          ref: 'refs/pull/${{ github.event.number }}/head'

      - id: files
        uses: jitterbit/get-changed-files@v1
        with:
          format: 'csv'

      - name: lint
        run: |
          FILES_COUNT=0
          CHANGED_FILES=""
          mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
          for added_modified_file in "${added_modified_files[@]}"; do
            echo "Do something with this ${added_modified_file}."
            CHANGED_FILES=$(printf "%s\n${added_modified_file}" "$CHANGED_FILES")
            FILES_COUNT+=1
          done

          set -x
          // truncated due to nda
@IceTDrinker
Copy link

Yes this probably should be an option if the author is around.

In the mean time you can ignore the error of the step I believe with github actions

@bstuff
Copy link
Author

bstuff commented Sep 15, 2021

I used another way to get modified files that is not based on tree relation between commits:

          API_URL=$(jq --raw-output .pull_request._links.self.href "$GITHUB_EVENT_PATH")

          FILES=$(curl --request GET \
            --url "$API_URL/files?per_page=100" \
            --header "accept: application/vnd.github.v3+json" \
            --header "authorization: token ${{secrets.GITHUB_TOKEN}}")
          echo $FILES

          CHANGED_FILES=$(echo $FILES | jq '.[] | select(.status == "added" or .status == "modified") | .filename')

@yammerings
Copy link

CHANGED_FILES=$(echo $FILES | jq '.[] | select(.status == "added" or .status == "modified") | .filename')

This is working for you?

Running this locally I am getting:

parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 23, column 33

mardy added a commit to mardy/snapd that referenced this issue Apr 14, 2022
Use the most popular action (249 stars at the moment) to retrieve the
list of changed files, because the action we used before only works fine
for branches forked off the tip of the master branch (fast-forward):

jitterbit/get-changed-files#42
@merobi-hub
Copy link

IceTDrinker, can you suggest a resource on how to ignore the error?

@bfenton-smugmug
Copy link

@merobi-hub I'm guessing they're suggesting something like this? that's what I'm about to try

    - id: files
      name: Get changed files
      uses: jitterbit/get-changed-files@b17fbb00bdc0c0f63fcf166580804b4d2cdc2a42 # v1
      continue-on-error: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants