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

feat: configure the name of the checksums dir using env. var or git config #181

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

Conversation

victorciresica
Copy link

@victorciresica victorciresica commented Oct 2, 2024

I was trying to set centralized server hooks for a gitea instance and I had a problem with having centralized trust configuration because if I create a symbolic link to .githooks.checksums in the gitea init.templateDir it isn't copied in new repos, because it's a hidden directory. So I figured a way to set the name of the checksums' directory would fix my issue.

I don't know if it is Gitea specific, or this might be the case for all git service providers(e.g. gitlab, bitbucket). If it isn't specific to Gitea it will be very useful for others as well.

@gabyx
Copy link
Owner

gabyx commented Oct 3, 2024

@victorciresica : Thats actually correct, it does not work.

  • Probably the solution is better as you suggest.

Thanks for providing a PR -> Actually, its nice somebody uses this on Gitea, I once did that long ago too on a company instance.

I will have look at the PR =)

Copy link
Owner

@gabyx gabyx left a comment

Choose a reason for hiding this comment

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

Looks good, but needs some changes and discussion.

githooks/apps/runner/settings.go Outdated Show resolved Hide resolved
githooks/hooks/gitconfig.go Show resolved Hide resolved
githooks/hooks/trusted.go Show resolved Hide resolved
githooks/hooks/trusted.go Outdated Show resolved Hide resolved
@gabyx
Copy link
Owner

gabyx commented Oct 3, 2024

@victorciresica I enabled CI for forked PRs, it might enable when you ammend the commit.

@gabyx gabyx changed the title Configure the name of the checksums dir using ENV VAR or git config feat: configure the name of the checksums dir using env. var or git config Oct 3, 2024
@gabyx
Copy link
Owner

gabyx commented Oct 3, 2024

I need to figure out next week why the CI is not running probably due to pipeline.yml which has some wrong settings.

@victorciresica : You can run the tests with just test and just test-user. The tests are fully dockerized...
If you use Nix, there is a Nix shell with .envrc.

@victorciresica
Copy link
Author

@gabyx I did the changes you suggested. It remains just to add update the readme as well.

@gabyx gabyx force-pushed the feature/configurable-checksums-dir branch from 911d355 to 77869a8 Compare October 4, 2024 15:55
@gabyx
Copy link
Owner

gabyx commented Oct 4, 2024

@victorciresica : The question I have is; When you set a global checksums directory -> this directory could grow and nobody cleans that on Gitea, but you are right there are only a few deliberate hooks the server maintainer sets up so the directory containing the checksums will only be small and of limited size...

Also you read that section right: trust all hooks on the Server:
https://github.com/gabyx/Githooks?tab=readme-ov-file#install-on-the-server
especially:

# Automatically accept changes to all existing and new
# hooks in the current repository.
# This makes the fatal trust prompt pass.
git hooks config trust-all-hooks --accept

I would just leave the checksum directory local and not set it (rendering this PR actually obsolete ... I will still consider to merge it, since it actually is ok!)
Because on the server (Gitea) you will most likely set a few global hooks either with global shared hooks (or inside the init.templateDir if you use that...

https://github.com/gabyx/Githooks/blob/main/docs/cli/git_hooks_shared_add.md

git hooks shared add --global file:///path/to/the/shared/hooks/repo

@victorciresica
Copy link
Author

victorciresica commented Oct 9, 2024

I did read the section on trust-all-hooks, but it can only be set locally, on one repo at a time. I would like something global. So, I think the feature is still useful. @gabyx what do you think?

@victorciresica victorciresica force-pushed the feature/configurable-checksums-dir branch 2 times, most recently from 82b824f to bc79c9b Compare October 14, 2024 13:14
@victorciresica victorciresica force-pushed the feature/configurable-checksums-dir branch from bc79c9b to d91a7bd Compare October 23, 2024 13:08
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