1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
# Check for "DELME" in commit messages of about-to-be-pushed commits
####################################################################
# This hook script is triggered by `git push` right after a connection to the remote
# was established and its initial response was received, and right before generating
# and pushing a pack-file.
# The operation will be aborted when exiting with a non-zero status.
#
# The following arguments are provided:
#
# $1 - The symbolic name of the remote to push to, like "origin" or the URL like "https://github.com/GitoxideLabs/gitoxide" if there is no such name.
# $2 - The URL of the remote to push to, like "https://github.com/GitoxideLabs/gitoxide".
#
# The hook should then read from standard input in a line-by-line fashion and split the following space-separated fields:
#
# * local ref - the left side of a ref-spec, i.e. "local" of the "local:refs/heads/remote" ref-spec
# * local hash - the hash of the commit pointed to by `local ref`
# * remote ref - the right side of a ref-spec, i.e. "refs/heads/remote" of the "local:refs/heads/remote" ref-spec
# * remote hash - the hash of the commit pointed to by `remote ref`
#
# In this example, we abort the push if any of the about-to-be-pushed commits have "DELME" in their commit message.
#
# To enable this hook remove the `.sample` suffix from this file entirely.
remote=""
url=""
# Check each commit being pushed
while ; do
# Skip if the local hash is all zeroes (deletion)
zero_sha=
if [; then
continue
fi
# Get the commit message
commit_msg=
# Check if the commit message contains "DELME"
if | ; then
fi
done
# If no commit with "DELME" found, allow the push