Commit 29d4be72 authored by Michal Sojka's avatar Michal Sojka

Cleanups etc.

- Use local variables instead of global ones
- Make branch a variable
parent 85d143d5
......@@ -43,12 +43,15 @@ glob=$(git config --get-all brutegit.glob| paste -s -d '|') || :
if [ -z "$glob" ]; then glob='*/ae|*/auto_evaluation'; fi
handle_commit() {
commit=$1
declare -A trees=()
local commit=${1:?}
local branch=${2:?}
local glob=${3:?}
new_tree=$(
git ls-tree -r -d $commit | tac | \
( while read mode type hash path; do
git ls-tree -r -d "$commit" | tac | \
(
declare -A trees=()
while read -r mode type hash path; do
path="./$path"
case "$path" in
+($glob))
......@@ -64,7 +67,7 @@ handle_commit() {
done
echo -n "${trees[.]}" | git mktree ))
local ae=$(git rev-parse --verify --quiet refs/heads/ae) || :
local ae=$(git rev-parse --verify --quiet "refs/heads/$branch") || :
if [ -z "$ae" ] || ! git diff-tree --quiet $ae $new_tree; then
export GIT_AUTHOR_NAME="$(git log --format=%an -1 $commit)"
export GIT_AUTHOR_EMAIL="$(git log --format=%ae -1 $commit)"
......@@ -81,7 +84,7 @@ handle_commit() {
if [ "$1" ]; then
# local testing
handle_commit $1
handle_commit "$1" ae "$glob"
else
# git hook
while read oldrev newrev refname; do
......@@ -89,7 +92,7 @@ else
echo "ae-sync: Checking for AE updates"
ae=$(git rev-parse --verify --quiet refs/heads/ae) || :
for rev in $(git rev-list --reverse $oldrev..$newrev); do
handle_commit $rev
handle_commit "$rev" ae "$glob"
done
if [ "$ae" != $(git rev-parse --verify --quiet refs/heads/ae) ]; then
if git config remote.brutegit.url >/dev/null; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment