Git Product home page Git Product logo

dotnet-format's Introduction

Hi there ๐Ÿ‘‹

Here are some of the recent projects I've been working on.

.NET

GitHub Actions

  • setup-dotnet - A wrapper around the official actions/setup-dotnet action with extra features that aren't yet implemented.
  • dotnet-sdk-updater - Update global.json files with the latest .NET SDK version.
  • actions-toolkit - Helper functions, scripts, and Typescript types for working with GitHub Actions.
  • secrets-sync - Sync secrets across multiple repositories.
  • secrets-sync-template - Template to quickly get setup using secrets-sync.

GitHub Actions Workflows

Check out my OnlyPans ๐Ÿ•

dotnet-format's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar dependamerge[bot] avatar xt0rted avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dotnet-format's Issues

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

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

Commit step not finding any changes

I am running dotnet format and then trying to commit and push the changes. I can see that the format step updates some files but somehow the commit step doesn't find any changes.

This is the output of the commit step:

Running in /home/runner/work/project/project
Add input parsed as single string, running 1 git add command.
> Using 'Github Actions <[email protected]>' as author.
> Using "Automated dotnet-format update" as commit message.
Internal logs
> Working tree clean. Nothing to commit.
Outputs

I don't understand how the working tree can be clear after the dotnet format step formatted 4 files.

This is my YAML:

name: Format check on pull request
on: pull_request
jobs:
  dotnet-format:
    runs-on: ubuntu-latest
    steps:
      - name: Install dotnet-format
        run: dotnet tool install -g dotnet-format --version "5.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json

      - name: Checkout repo
        uses: actions/checkout@v2

      - name: Run dotnet format
        id: format
        uses: xt0rted/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          action: "fix"
          only-changed-files: false
          fail-fast: false
      
      - name: Commit files
        if: steps.format.outputs.has-changes == 'true'
        uses: EndBug/add-and-commit@v8
        with:
          author_name: Github Actions
          author_email: [email protected]
          message: Automated dotnet-format update

Any idea what I'm doing wrong?

Not working with .NET Core v6

I spent past hour or so trying to get dotnet format working in my action pipeline for a .NET Core v6 project. I went through various configurations to the yml file but all end with the same result:

Unrecognized command or argument '--check'
Unrecognized command or argument '--dry-run'
Unrecognized command or argument '--files'

Is there any workaround for this?

Error running Format check on push example

Not sure if I did something wrong implementing the example yaml or this is a legit bug.

Run xt0rted/[email protected]
with:
repo-token: ***
action: check
fail-fast: true
/usr/bin/dotnet format --check --dry-run
Could not execute because the specified command or file was not found.
Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-format does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
    (node:2919) UnhandledPromiseRejectionWarning: Error: Formatting issues found
    at Object. (/home/runner/work/_actions/xt0rted/dotnet-format/v1.0.1/dist/index.js:1355:19)
    at Generator.next ()
    at fulfilled (/home/runner/work/_actions/xt0rted/dotnet-format/v1.0.1/dist/index.js:1335:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    (node:2919) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
    (node:2919) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    ##[error]Formatting issues found

dotnet format not installed

This is likely a newbie error, but it's not documented.

When running, I get:

Run dotnet format1s
(node:2726) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Run xt0rted/dotnet-format@v1
Checking 22 files
/usr/bin/dotnet format --check --dry-run --files BunchOfFiles

Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-format does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

So it looks like this tool assumes that dotnet format is insalled. But it is not in this case. Is there a simple option to add? A place where I should add in a run: dotnet tool install -g dotnet-format ?

Deprecated options

Note the output of the run, some deprecated options of dotnet-format are used:

Run xt0rted/dotnet-format@v1
Checking 7 files
/usr/bin/dotnet format --check --dry-run --files _somefiles_
  The `--files` option is deprecated. Use the `--include` option instead.
  The `--dry-run` option is deprecated. Use the `--check` option instead.

fix upon pull request is not working

As you may see here, I tried to make pull requests as fixer action.

Two issues occurred,

  1. It triggered a new action upon commit
  2. steps.format.outputs.has-changes returns true even there is no file to commit, which causes an additional error you may find it in here

I don't want to use a comment; if the formatting is wrong, it should be fixed it right at the commit into the pull request in my case.

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.