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

a present core.hooksPath setting is ignored #7

Closed
hekmekk opened this issue Sep 9, 2019 · 4 comments
Closed

a present core.hooksPath setting is ignored #7

hekmekk opened this issue Sep 9, 2019 · 4 comments

Comments

@hekmekk
Copy link
Owner

hekmekk commented Sep 9, 2019

Bug Report

git-team version: 1.3.4
go version: 1.12

failure description

The git config option core.hooksPath is overriden on enable and then unset on disable. If it was set before, the respective hooks will be deactivated when git-team is enabled and not re-enabled when git-team is disabled again. This is confusing for users.

expected behaviour description

Existing hooks in core.hooksPath – apart from prepare-commit-msg – should be respected.

@delitescere
Copy link

delitescere commented Apr 30, 2021

Could either record a previous value to /usr/local/etc/git-team/hooks/.original.hookspath or use a team.state.originalHooksPath config value to restore upon git team disable.

The new proxy.sh script could also use this to activate hooks (as well or instead of ones in REAL_LOCAL_HOOK)

@delitescere
Copy link

delitescere commented Apr 30, 2021

An updated proxy.sh would look like this.

#!/bin/sh

PREVIOUS_HOOKS_PATH=$(git config --get team.state.previousHooksPath)
REAL_GLOBAL_HOOK="${PREVIOUS_HOOKS_PATH}/$(basename $0)"

if [ -n "${PREVIOUS_HOOKS_PATH}" ] && [ -x "${REAL_GLOBAL_HOOK}" ]; then
  "${REAL_GLOBAL_HOOK}" "$@" || exit $?
else
  REAL_LOCAL_HOOK="$(git rev-parse --show-toplevel)/.git/hooks/$(basename $0)"

  if [ -x "${REAL_LOCAL_HOOK}" ]; then
    "${REAL_LOCAL_HOOK}" "$@" || exit $?
  fi
fi

exit 0

Also corrected to only use executable files, and mimic git hooks behaviour in that if a global hook is present, a local hooks is ignored (assuming that most well-written global hooks have logic to execute local hooks when present).

@hekmekk
Copy link
Owner Author

hekmekk commented May 1, 2021

Thanks for the input. My thoughts were going in a pretty similar direction. Your suggestion for proxy.sh looks good!

hekmekk added a commit that referenced this issue Oct 9, 2022
When the git config option core.hooksPath is overriden by git-team
enable, its previous value is recorded and ...
- used to lookup and run other git hooks while git-team is enabled
- restored when running git-team disable

fixes issue 7, see: #7
@hekmekk
Copy link
Owner Author

hekmekk commented Oct 9, 2022

Finally closed by 39bb2cc.

@hekmekk hekmekk closed this as completed Oct 9, 2022
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

No branches or pull requests

2 participants