rycus86 / githooks

Githooks: per-repo and global Git hooks with version control
MIT License
380 stars 19 forks source link

Global shared hooks for this repo #122

Closed gabyx closed 3 years ago

gabyx commented 3 years ago

@rycus: For your suggestion #119 , we might need clear notation what we mean with global shared hooks, local shared hooks and the new global shared hooks for this repo only.

—local is currently .shared file

—global is global githooks.shared

I am wondering how we make this CLI option. Should we keep the definition or have something like:

rycus86 commented 3 years ago

In terms of CLI, I think in the https://github.com/rycus86/githooks/blob/master/docs/command-line-tool.md#git-hooks-config git hooks config shared <url> could maybe get a --local flag to only set this for the current repo.

For the logic, everything could work as-is, maybe there's some merging needed for local+global git configs for the shared repo lists. Other than that the only thing I'd want is to refuse running local (and/or file://) repo hooks from the .shared file (because someone else can update it for you).

gabyx commented 3 years ago

The thing is there is already a —local flag, isnt it? Which puts the url into the .shared file...

Von meinem iPhone gesendet

Am 13.09.2020 um 11:18 schrieb Viktor Adam notifications@github.com:

In terms of CLI, I think in the https://github.com/rycus86/githooks/blob/master/docs/command-line-tool.md#git-hooks-config git hooks config shared could maybe get a --local flag to only set this for the current repo.

For the logic, everything could work as-is, maybe there's some merging needed for local+global git configs for the shared repo lists. Other than that the only thing I'd want is to refuse running local (and/or file://) repo hooks from the .shared file (because someone else can update it for you).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

rycus86 commented 3 years ago

Oh, you're right, there is. 🙈 I was only checking the cli docs and that doesn't tell about it.

Looking back now, I don't think --local is appropriate for changing the .shared file, I'd probably use --shared for that, then --local could just set the local git config variable.

gabyx commented 3 years ago

That would be 👌 :)

Von meinem iPhone gesendet

Am 13.09.2020 um 12:00 schrieb Viktor Adam notifications@github.com:

Oh, you're right, there is. 🙈 I was only checking the cli docs and that doesn't tell about it.

Looking back now, I don't think --local is appropriate for changing the .shared file, I'd probably use --shared for that, then --local could just set the local git config variable.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

gabyx commented 3 years ago

OK, I suggest the following:

Then the executing sequence should be now as follows, (IMO):

    execute_shared_hooks --shared "$@" || return 1 # .shared file
    execute_shared_hooks  --local "$@" || return 1 # first --local git config: githooks.shared,
    execute_shared_hooks  --global "$@" || return 1 # then --global git config: githooks.shared
    execute_all_hooks_in "$(pwd)/.githooks" "$@" || return 1
rycus86 commented 3 years ago

Sounds good to me, thanks!