Skip to content

Commit 33ccb65

Browse files
authored
Create example hook to reject web UI blob edits
1 parent 80c3c95 commit 33ccb65

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#
3+
# This hook restricts changes on the default branch to disallow the Web UI blob editor
4+
#
5+
DEFAULT_BRANCH=$(git symbolic-ref HEAD)
6+
while read -r oldrev newrev refname; do
7+
if [[ "${refname}" != "${DEFAULT_BRANCH:=refs/heads/master}" ]]; then
8+
continue
9+
else
10+
if [[ "${GITHUB_VIA}" = 'blob#save' ]]; then
11+
echo "Changes to the default branch must be made by cli. Web UI edits are not allowed."
12+
exit 1
13+
else
14+
continue
15+
fi
16+
fi
17+
done

0 commit comments

Comments
 (0)