kamadorueda / alejandra

The Uncompromising Nix Code Formatter
https://kamadorueda.github.io/alejandra/
The Unlicense
855 stars 41 forks source link

Pre-commit autoupdate reverts from v3.0.0 to v1.3.0 #388

Closed arichtman closed 10 months ago

arichtman commented 1 year ago

Hi everyone - love the project and would like to contribute if anyone has any ideas on where this might be coming from. The git tags all seem to be chronologically correct too.

Action: autoupdate a pre-commit hook using Alejandra Expected: Version 3.0.0 is selected Actual: 1.3.0 is selected

[nixos@bruce-banner:~/repos/aws-bootstrap/foo]$ pre-commit autoupdate
Updating https://github.com/kamadorueda/alejandra ... updating 3.0.0 -> 1.3.0.

Files to reproduce are here.

https://gist.github.com/arichtman/5836c61721cc9d1fabae428e970bfbbc

arichtman commented 1 year ago

So it looks like pre-commit isn't seeing the tags. The only difference I can see is that 1.3.0 is unverified?

https://github.com/pre-commit/pre-commit/blob/bb49560dc99a65608c8f9161dd71467af163c0d1/pre_commit/commands/autoupdate.py#L42

[nixos@bruce-banner:~/repos/alejandra]$ git describe --tags --abbrev=0
1.3.0
[nixos@bruce-banner:~/repos/alejandra]$ git tag -l
0.0.0
0.1.0
0.2.0
0.3.0
0.3.1
0.4.0
0.5.0
0.6.0
0.7.0
1.0.0
1.1.0
1.2.0
1.3.0
1.4.0
1.5.0
2.0.0
3.0.0
arichtman commented 1 year ago

Yup, confirmed. I forked it, added a signed tag for v3.0.1 and pointed my .pre-commit-config.yaml to it and ran pre-commit autoupdate and it picked it up. Unfortunately there's no way I can send a pull request to sign these tags.

https://github.com/arichtman/alejandra/releases/tag/v3.0.1

- repo: https://github.com/arichtman/alejandra
  rev: v3.0.0
  hooks:
  - id: alejandra-nix
kamadorueda commented 1 year ago

I don't understand what the solution would be

3.0.0 is signed (according to this https://github.com/kamadorueda/alejandra/tags)

is signed vs unsigned the problem? should I sign 1.3.0?

another difference I see with your fork is that you are using v3.x.x instead of 3.x.x

happy to help adjust the tags once we confirm what the solution is

arichtman commented 1 year ago

Ah yes, you're right it's not the signing/verification. I pushed an unsigned tag of 3.0.1 to my fork and that updated the hook alejandra correctly.

I thought maybe they were different types of tags but they're all commits image

There's nothing obviously different here either image

😵

maxbrunet commented 1 year ago

Hello! :wave:

Tags must be on the default branch (main) for pre-commit autoupdate to work properly:

By default, this will bring the hooks to the latest tag on the default branch.

https://pre-commit.com/#updating-hooks-automatically

1.3.0 is the latest tag on main:

$ git tag --merged main
0.0.0
0.1.0
0.2.0
0.3.0
0.4.0
1.3.0
arichtman commented 10 months ago

@kamadorueda Can we apply the tags to main ?

kamadorueda commented 10 months ago

@maxbrunet thanks! I understand the problem now. The commit some tags point to is not a commit in main

The fix was making sure that 3.0.0 points to a commit in main: git tag 3.0.0 e7eac49074b70814b542fee987af2987dd0520b5 -f

Now 3.0.0 appears in main

$ git tag --merged origin/main
0.0.0
0.1.0
0.2.0
0.3.0
0.4.0
1.3.0
3.0.0

Thanks!

arichtman commented 10 months ago

Confirming this works now with v3.0.0.