Commit 1201e4e8 authored by Michal Sojka's avatar Michal Sojka

Fixes

parent 120da506
......@@ -4,4 +4,5 @@ INPUT = 244f8d49940fde16255b2e4eba0c79907412e7ad \
.PHONY: test
test:
echo $(INPUT) | ./brutegit-ae-sync
git branch -D ae || :
echo $(INPUT) | bash -x ./brutegit-ae-sync
......@@ -25,8 +25,11 @@ set -e
# continues and produces empty tree, which is bad
set -o pipefail
glob=$(git config --get-all brutegit.glob| paste -s -d '|')
if [ -z "$glob" ]; then glob='*/ae | */auto_evaluation'; fi
# Needed for +(...|...) pattern matching
shopt -s extglob
glob=$(git config --get-all brutegit.glob| paste -s -d '|') || :
if [ -z "$glob" ]; then glob='*/ae|*/auto_evaluation'; fi
handle_commit() {
commit=$1
......@@ -37,7 +40,7 @@ handle_commit() {
( while read mode type hash path; do
path="./$path"
case "$path" in
$glob)
+($glob))
upper_path="${path%/*}"
trees[$upper_path]+="$(echo -e "$mode tree $hash\t${path##*/}")"$'\n'
;;
......@@ -50,7 +53,7 @@ handle_commit() {
done
echo -n "${trees[.]}" | git mktree ))
ae=$(git rev-parse --verify --quiet refs/heads/ae)
ae=$(git rev-parse --verify --quiet refs/heads/ae) || :
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)"
......@@ -63,13 +66,17 @@ handle_commit() {
while read oldrev newrev refname; do
if [ "$refname" = "refs/heads/master" ]; then
echo "Checking for AE updates"
ae=$(git rev-parse --verify --quiet refs/heads/ae)
ae=$(git rev-parse --verify --quiet refs/heads/ae) || :
for rev in $(git rev-list --reverse $oldrev..$newrev); do
handle_commit $rev
done
if [ $ae != $(git rev-parse --verify --quiet refs/heads/ae) ]; then
echo "Pushing AE to BRUTE"
git push -f --quiet brutegit ae:master
if [ "$ae" != $(git rev-parse --verify --quiet refs/heads/ae) ]; then
if git config remote.brutegit.url >/dev/null; then
echo "Pushing AE to BRUTE"
git push -f --quiet brutegit ae:master
else
echo "Not pushing AE to BRUTE because brutegit remote is not configured"
fi
fi
fi
done
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