Git Product home page Git Product logo

Comments (15)

samh-depop avatar samh-depop commented on July 17, 2024 7

I have the same issue.
I get this error message

fatal: Not a valid object name dev

dev is the value in ${{ github.base_ref }}

Anyway to fix that?

from action-swiftlint.

kerrmarin avatar kerrmarin commented on July 17, 2024

Same issue here!

from action-swiftlint.

dlackty avatar dlackty commented on July 17, 2024

@samh-depop @kerrmarin I've solved this problem with following action configs:

      - name: Fetch base ref
        run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }}
      - name: Run SwiftLint
        uses: norio-nomura/[email protected]
        with:
          args: --force-exclude
        env:
          DIFF_BASE: origin/${{ github.base_ref }}

from action-swiftlint.

tudorsirbu avatar tudorsirbu commented on July 17, 2024

I get the same issue with fatal: Not a valid object name dev. Has anyone managed to find a fix for this? I've tried what @dlackty has suggested but it doesn't review any files. It's saying no files changed. :(

from action-swiftlint.

dlackty avatar dlackty commented on July 17, 2024

@stefangerard Do you add additional git fetch step to fetch base ref?

Could you share the whole workflow yml? I would like to help.

from action-swiftlint.

BrentMifsud avatar BrentMifsud commented on July 17, 2024

I have the same problem. using DIFF_BASE: ${{ gitHub.base_ref }} just results in:

no object master in the console log.

from action-swiftlint.

akashnimare avatar akashnimare commented on July 17, 2024

base_ref is only available for forked repo I think -

https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables

from action-swiftlint.

theoriginalbit avatar theoriginalbit commented on July 17, 2024

I too have noticed that github.base_ref isn't actually working like we'd expect.

Though I am getting a PR lint successfully when new commits are pushed, but when run locally linting fails. It seems that it is only linting against the changes that were pushed and not the entire PR? The pushed commits didn't have linting issues but also didn't fix the previous linting issues. Has anyone else experienced this issue while using github.base_ref? Should we be using github.ref instead? 🤔

@akashnimare it comes from the github context not env vars (look at github.base_ref docs)

from action-swiftlint.

akashnimare avatar akashnimare commented on July 17, 2024

I have tried out github_ref as well doesn't work as expected.

image

What's the best way to test out GitHub actions locally?

from action-swiftlint.

theoriginalbit avatar theoriginalbit commented on July 17, 2024

What's the best way to test out GitHub actions locally?

I haven't found a way. I just have a private repo that I do lots of commits on.

from action-swiftlint.

akashnimare avatar akashnimare commented on July 17, 2024

Internet says this tool could be used for testing actions locally.

from action-swiftlint.

yo1995 avatar yo1995 commented on July 17, 2024

Same issue here. Will opt-out changed file only till it works.

from action-swiftlint.

rvilardo avatar rvilardo commented on July 17, 2024

having the same issue. Any clue?

from action-swiftlint.

shrutis826 avatar shrutis826 commented on July 17, 2024

Facing same issue, any solution suggested?

from action-swiftlint.

ayoy avatar ayoy commented on July 17, 2024

The root cause is that the action cannot perform a diff against base branch, because the base branch has not been checked out by the workflow (hence fatal: Not a valid object: dev/main/master errors). If you fetch its most recent commit, then it's known to git locally and diff works.

- name: Fetch PR's target branch
  run: git fetch --no-tags --prune --depth=1 origin ${{ github.base_ref }}
- name: Run SwiftLint on files changed in the PR
  uses: norio-nomura/[email protected]
  with:
    args: --force-exclude
  env:
    DIFF_BASE: ${{ github.base_ref }}

It's similar to what @dlackty posted, although in my case origin/ doesn't seem to be needed (in fact it doesn't work that way). Works here, however it still prints that error 🤷

from action-swiftlint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.