-
Notifications
You must be signed in to change notification settings - Fork 3
/
post-commit
executable file
·24 lines (18 loc) · 926 Bytes
/
post-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# Brief: Push till successful
cd "${outgoing_dir}" # Just for neatness and safety
flock -n . -c ''|| exit 1
stash="${GIBBERISH_DIR}/stash" # Use this instead of git-stash simply to avoid conflicts
until (date;git push --quiet origin "${push_branch}") &>>"${push_error_log}"; do
# The grand sync: Let's make it conflict-less
commit_msg="$(git log -1 --pretty=%B)"
mv -f "${iofile}" "${stash}"
git reset --quiet --hard "origin/${push_branch}"
until (date;git pull --ff-only --quiet origin "${push_branch}") &>>"${pull_error_log}"; do :;done
mv -f "${stash}" "${iofile}"
git add -u
# Flock makes sure post-commit hook is not called following the below commit
flock -x . git commit --quiet --no-gpg-sign --allow-empty --allow-empty-message -m "${commit_msg}"
done
cat /dev/null > "${push_error_log}" 2>"${pull_error_log}" # Clean up log when normal operation resumes
GIBBERISH_prep_api