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

Fix on pull request: nothing to commit, working tree clean #98

Open
anthony-steele-cko opened this issue Sep 2, 2020 · 4 comments
Open

Comments

@anthony-steele-cko
Copy link

anthony-steele-cko commented Sep 2, 2020

I am seeing similar to the nothing to commit, working tree clean issue here: #10 (comment), and it does not seem to be due to line-ending settings

I made a PR, with the config file similar to given there, and also added extra spaces to a code file, so that the format would have something to fix.
The result is that it is formatted on the format step,
and this is followed by "nothing to commit, working tree clean" at the commit step

image

@anthony-steele-cko
Copy link
Author

anthony-steele-cko commented Sep 2, 2020

My format.yml file is as follows:

name: Format check on pull request
on: pull_request
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}

      - name: Add dotnet-format problem matcher
        uses: xt0rted/dotnet-format-problem-matcher@v1

      - name: Restore dotnet tools
        uses: xt0rted/dotnet-tool-restore@v1

      - name: Run dotnet format
        id: format
        uses: xt0rted/dotnet-format@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          action: "fix"
          only-changed-files: true

      - name: Commit files
        if: steps.format.outputs.has-changes == 'true'
        run: |
          git config --local user.name "github-actions[bot]"
          git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git commit -a -m 'Automated dotnet-format update

          Co-authored-by: ${{ github.event.pull_request.user.login }} <${{ github.event.pull_request.user.id }}+${{ github.event.pull_request.user.login }}@users.noreply.github.com>'

      - name: Push changes
        if: steps.format.outputs.has-changes == 'true'
        uses: ad-m/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.head_ref }}

ordering is different to here because we now use the .config\dotnet-tools.json file to specify which tools need to be installed, and that's only present after checkout.

@anthony-steele-cko
Copy link
Author

All working if I change line 20 to
uses: jfversluis/[email protected]

https://github.com/jfversluis/dotnet-format/

@Hona
Copy link

Hona commented Apr 22, 2021

Is there a way to run with --fix-style or --fix-analyzers? It would be useful to enforce style as well as just the whitespace

@xt0rted
Copy link
Owner

xt0rted commented Apr 26, 2021

@Hona I'm working on a new release that adds support for dotnet-format v4 and v5 which will include these new options. I'm expecting to release it sometime this week.

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

3 participants