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

Support --all-including-untracked-files #594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sanmai-NL
Copy link
Contributor

@sanmai-NL sanmai-NL commented Dec 14, 2023

‘All files’ currently means all files in the Git index, so this misses untracked, but unignored additions.

⚡ Summary

☑️ Checklist

  • Check locally
  • Add tests
  • Add documentation

@sanmai-NL sanmai-NL marked this pull request as ready for review December 14, 2023 18:40
@mrexox
Copy link
Member

mrexox commented Dec 15, 2023

Hey @sanmai-NL, could you please describe the use case? Why do you need to run lefthook hooks against untracked files?

@sanmai-NL
Copy link
Contributor Author

@mrexox As a DevOps specialist, I want data generated as part of a CI/CD pipeline to be included in checks orchestrated by Lefthook, so that I can catch suboptimalities in generation source code.

As a Developer, I want be able to run Lefthook on my entire working directory even as new content is gradually being added, without having to add and potentially remove new files to the index every time.

@mrexox
Copy link
Member

mrexox commented Dec 15, 2023

Do you use pre-commit hook for that or a custom hook name?

@sanmai-NL
Copy link
Contributor Author

A custom hook name.

@sanmai-NL
Copy link
Contributor Author

I addressed the cyclomatic complexity (only lint failure) in #595. After the review is finished for both this PR and #595, I hope it's possible to merge this as is, as the following PR #595 would be merged soon thereafter.

PushFiles string = "{push_files}"
SubFiles string = "{files}"
SubAllFiles string = "{all_files}"
SubAllFilesIncludingUntracked string = "{all_including_untracked_files}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanmai-NL , do you really need this template? Why can't a custom {files} be used instead?

Comment on lines +82 to +83
case r.AllFilesIncludingUntracked:
stagedFiles = r.Repo.AllFilesIncludingUntracked
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's no need to use {all_including_untracked_files} template we can move this part to internal/lefthook/run.go and pass those files via Files option. I suggested pretty similar solution here

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

Successfully merging this pull request may close these issues.

2 participants