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

Improve pre-commit (dotnet, and remove a python warning) #627

Merged
merged 4 commits into from
Feb 19, 2024

Conversation

mikeage
Copy link
Member

@mikeage mikeage commented Feb 14, 2024

Use the system version of dotnet format instead of a pre-commit managed version. While this is normally not the best way to use pre-commit, it seems like everyone has it installed anyway, and this will let us use the latest versions without having to do ugly hacks like specifically inject v7.something

@mikeage mikeage added the infrastructure Build or tooling infrastructure label Feb 14, 2024
@mikeage
Copy link
Member Author

mikeage commented Feb 14, 2024

@andybak , can I ask you to try this PR locally (when you're back)?

Basically do the following:

git fetch --all -p
git checkout infra/precommit-dotnet
pre-commit run -a dotnet

And make sure it runs.

I think I finally figured out how to get rid of the ugly code to inject a specific version of dotnet-format. It works for me locally and it works in CI, so I'm hopeful....

@mikeage mikeage changed the title Improve pre-commit Improve pre-commit (dotnet, and remove a python warning) Feb 14, 2024
@andybak
Copy link
Contributor

andybak commented Feb 19, 2024

pre-commit run -a dotnet

PS I:\Unity Projects\open-brush-main> git checkout infra/precommit-dotnet
hint: If you meant to check out a remote tracking branch on, e.g. 'origin',
hint: you can do so by fully qualifying the name with the --track option:
hint:
hint:     git checkout --track origin/<name>
hint:
hint: If you'd like to always have checkouts of an ambiguous <name> prefer
hint: one remote, e.g. the 'origin' remote, consider setting
hint: checkout.defaultRemote=origin in your config.
fatal: 'infra/precommit-dotnet' matched multiple (2) remote tracking branches
PS I:\Unity Projects\open-brush-main> git checkout --track origin/infra/precommit-dotnet
Switched to a new branch 'infra/precommit-dotnet'
branch 'infra/precommit-dotnet' set up to track 'origin/infra/precommit-dotnet'.
PS I:\Unity Projects\open-brush-main> pre-commit run -a dotnet
[INFO] Initializing environment for https://github.com/adrienverge/yamllint.git.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/pycqa/flake8.
[INFO] Initializing environment for https://github.com/PyCQA/pylint.git.
[INFO] Initializing environment for https://github.com/PyCQA/pylint.git:typing_extensions.
No hook with id `dotnet` in stage `pre-commit`

@mikeage
Copy link
Member Author

mikeage commented Feb 19, 2024

Sorry typo in my instructions. It should have said dotnet-format

@andybak
Copy link
Contributor

andybak commented Feb 19, 2024

Oh - I should have spotted that myself!

@andybak
Copy link
Contributor

andybak commented Feb 19, 2024

Seems to work:

PS I:\Unity Projects\open-brush-main> pre-commit run -a dotnet-format
dotnet-format............................................................Passed

@andybak
Copy link
Contributor

andybak commented Feb 19, 2024

Just checked on my Macbook and that worked fine as well!

@mikeage
Copy link
Member Author

mikeage commented Feb 19, 2024

Excellent, thank you!

@mikeage mikeage merged commit 648c242 into main Feb 19, 2024
36 checks passed
@mikeage mikeage deleted the infra/precommit-dotnet branch February 19, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Build or tooling infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants