-#!/bin/sh
+#!/bin/bash
# Sets: new_commits
# Assumes: $oldrev $newrev $refname
# "remotes/" will be ignored as well.
#
##################################################
-function set_new_commits() {
+set_new_commits() {
nl=$'\n'
# Get all the current branches, not'd as we want only new ones
# 0000->1234 (create)
# 1234->2345 (update)
# 2345->0000 (delete)
-function set_change_type() {
+set_change_type() {
if [ "$oldrev" == "0000000000000000000000000000000000000000" ] ; then
change_type="create"
else
# Sets: $newrev_type $oldrev_type $rev $rev_type
# Assumes: $newrev $oldrev
# --- Get the revision types
-function set_rev_types() {
+set_rev_types() {
newrev_type=$(git cat-file -t "$newrev" 2> /dev/null)
oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then
# Assumes: $rev
#
# The email subject will contain the best description of the ref that we can build from the parameters
-function set_describe() {
+set_describe() {
rev_to_describe="$rev"
if [ "$1" != "" ] ; then
rev_to_describe="$1"
# Assumes: $rev
#
# The email subject will contain the best description of the ref that we can build from the parameters
-function set_describe_tags() {
+set_describe_tags() {
rev_to_describe="$rev"
if [ "$1" != "" ] ; then
rev_to_describe="$1"
#
# with_lock "foo.lock" "echo a" # Works
# with_lock "foo.lock" "echo b1 ; echo b2" # Work
-# function several() {
+# several() {
# echo several1 ; echo several2
# }
# with_lock "foo.lock" several # Works
#
-function with_lock() {
+with_lock() {
lockfile="$1"
block="$2"
with_lock_has_lock=1
trap with_lock_unlock_if_held INT TERM EXIT
- lockfile -1 -r 300 "$lockfile"
+ # used to use lockfile to try multiple times but it's not always available
+ mkdir "$lockfile"
with_lock_has_lock=$?
if [ $with_lock_has_lock -ne 0 ] ; then
exit $?
fi
eval "$block"
- rm -f "$lockfile"
+ rmdir "$lockfile"
with_lock_has_lock=1
}
-function with_lock_unlock_if_held() {
+with_lock_unlock_if_held() {
if [[ "$with_lock_has_lock" -eq 0 ]] ; then
rm -f "$lockfile"
fi
}
-function display_error_message() {
+display_error_message() {
echo "----------------------------------------------------" >&2
echo "" >&2
echo "" >&2