mirror of
https://codeberg.org/vlw/dotfiles.git
synced 2026-01-11 21:36:00 +01:00
feat(git): add confirm prompt before commit to master branch
This commit is contained in:
parent
e5301dc413
commit
015c3bfce7
4 changed files with 19 additions and 1 deletions
|
|
@ -18,3 +18,5 @@
|
||||||
[commit]
|
[commit]
|
||||||
gpgsign = true
|
gpgsign = true
|
||||||
verbose = true
|
verbose = true
|
||||||
|
[init]
|
||||||
|
templatedir = ~/.local/bin/git-hooks
|
||||||
|
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -14,6 +14,8 @@
|
||||||
!.bash_aliases
|
!.bash_aliases
|
||||||
!.bash_profile
|
!.bash_profile
|
||||||
!.local/bin/
|
!.local/bin/
|
||||||
|
!.local/bin/git-hooks/
|
||||||
|
!.local/bin/git-hooks/pre-commit
|
||||||
!.local/bin/code_server_export_extensions
|
!.local/bin/code_server_export_extensions
|
||||||
!.local/share/
|
!.local/share/
|
||||||
!.local/share/code-server/
|
!.local/share/code-server/
|
||||||
|
|
|
||||||
14
.local/bin/git-hooks/pre-commit
Normal file
14
.local/bin/git-hooks/pre-commit
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the current branch name
|
||||||
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
|
||||||
|
# Check if the current branch is master
|
||||||
|
if [[ "$current_branch" == "master" ]]; then
|
||||||
|
read -p "You are about to commit to the master branch. Do you want to continue? (y/n) " -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
echo "Commit aborted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
2
Makefile
2
Makefile
|
|
@ -11,7 +11,7 @@ dotfiles:
|
||||||
|
|
||||||
# Use tracked git hooks
|
# Use tracked git hooks
|
||||||
git-hooks:
|
git-hooks:
|
||||||
git config --local core.hooksPath .local/share/git/hooks
|
git config --global core.hooksPath .local/bin/git-hooks
|
||||||
|
|
||||||
# Export code-server extensions to config directory
|
# Export code-server extensions to config directory
|
||||||
code-extensions:
|
code-extensions:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue