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

Piped hooks are not well ordered after 9 #540

Closed
bdarcet opened this issue Aug 23, 2023 · 0 comments · Fixed by #562
Closed

Piped hooks are not well ordered after 9 #540

bdarcet opened this issue Aug 23, 2023 · 0 comments · Fixed by #562
Labels
bug Something isn't working

Comments

@bdarcet
Copy link

bdarcet commented Aug 23, 2023

🔧 Summary

When using piped hooks (ordered hooks) we noticed that if we added more than 10, the 10th hook would be at the top of the list and so run as first hook.

Lefthook version

1.4.9

Steps to reproduce

running lefthook run post-merge
with this lefthook.yml

post-merge:
  piped: true
  commands:
    1_install:
      run: echo "test"
    2_install:
      run: echo "test"
    3_install:
      run: echo "test"
    4_install:
      run: echo "test"
    5_install:
      run: echo "test"
    6_install:
      run: echo "test"
    7_install:
      run: echo "test"
    8_install:
      run: echo "test"
    9_install:
      run: echo "test"
    10_install:
      run: echo "test"

Expected results

Lefthook v1.4.9
SYNCING
SERVED HOOKS: post-merge, pre-push, setup, pre-commit
RUNNING HOOK: post-merge
                      
  EXECUTE > 1_install
test

            
  EXECUTE > 2_install
test

            
  EXECUTE > 3_install
test

            
  EXECUTE > 4_install
test

            
  EXECUTE > 5_install
test

            
  EXECUTE > 6_install
test

            
  EXECUTE > 7_install
test

            
  EXECUTE > 8_install
test

            
  EXECUTE > 9_install
test

  EXECUTE > 10_install
test

                               
SUMMARY: (done in 0.04 seconds)
✔️  1_install
✔️  2_install
✔️  3_install
✔️  4_install
✔️  5_install
✔️  6_install
✔️  7_install
✔️  8_install
✔️  9_install
✔️  10_install

Actual results

Lefthook v1.4.9
SYNCING
SERVED HOOKS: post-merge, pre-push, setup, pre-commit
RUNNING HOOK: post-merge
            
  EXECUTE > 10_install
test

            
  EXECUTE > 1_install
test

            
  EXECUTE > 2_install
test

            
  EXECUTE > 3_install
test

            
  EXECUTE > 4_install
test

            
  EXECUTE > 5_install
test

            
  EXECUTE > 6_install
test

            
  EXECUTE > 7_install
test

            
  EXECUTE > 8_install
test

            
  EXECUTE > 9_install
test

                               
SUMMARY: (done in 0.04 seconds)
✔️  10_install
✔️  1_install
✔️  2_install
✔️  3_install
✔️  4_install
✔️  5_install
✔️  6_install
✔️  7_install
✔️  8_install
✔️  9_install

Possible Solution

we found a tmp fixed by adding a leading zero to the hook names
e.g:

    001_install:
      run: echo "test"
    002_install:
      run: echo "test"
    003_install:
      run: echo "test"
    004_install:
      run: echo "test"
    005_install:
      run: echo "test"
    006_install:
      run: echo "test"
    007_install:
      run: echo "test"
    008_install:
      run: echo "test"
    009_install:
      run: echo "test"
    010_install:
      run: echo "test"
@bdarcet bdarcet added the bug Something isn't working label Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant