Skip to content

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

Open
victorciresica wants to merge 1 commit into
gabyx:mainfrom
victorciresica:feature/configurable-checksums-dir
Open

feat: configure the name of the checksums dir using env. var or git config#181
victorciresica wants to merge 1 commit into
gabyx:mainfrom
victorciresica:feature/configurable-checksums-dir

Conversation

@victorciresica

@victorciresica victorciresica commented Oct 2, 2024

Copy link
Copy Markdown

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

gabyx commented Oct 3, 2024

Copy link
Copy Markdown
Owner

@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 =)

@gabyx gabyx left a comment

Copy link
Copy Markdown
Owner

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.

Comment thread githooks/apps/runner/settings.go Outdated
Comment thread githooks/hooks/gitconfig.go
Comment thread githooks/hooks/trusted.go
Comment thread githooks/hooks/trusted.go Outdated
@gabyx

gabyx commented Oct 3, 2024

Copy link
Copy Markdown
Owner

@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

gabyx commented Oct 3, 2024

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

gabyx commented Oct 4, 2024

Copy link
Copy Markdown
Owner

@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

victorciresica commented Oct 9, 2024

Copy link
Copy Markdown
Author

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
@gabyx

gabyx commented Feb 20, 2026

Copy link
Copy Markdown
Owner

@victorciresica : The feature is useful, but needs more work. See the comments above.

// Remove checksum files...
cacheDir := hooks.GetChecksumDirectoryGitDir(gitDir)
// Remove local checksum files...
cacheDir := path.Join(gitDir, hooks.ChecksumsDir)

@gabyx gabyx Feb 20, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

question: I dont think this is the correct path now when uninstalling. I think one must do the same computation as in githooks.go + an Env variable which we should check also if set separately and delete that folder too. IMO

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