Commit 853441eb authored by Michal Sojka's avatar Michal Sojka

Update commit-ae hook

parent 244f8d49
#!/bin/bash
set -ex
set -e
handle_update() {
handle_commit() {
commit=$1
subdir=$2
declare -A trees=()
new_tree=$(git ls-tree -r -d $commit $subdir | tac | \
while read mode type hash path; do
if [ "$path" != "./" ]; then
path="./$path"
else
path="."
fi
case $path in
ae | */ae | auto_evaluation | */auto_evaluation)
upper_path="${path%/*}"
trees[$upper_path]+="$(echo -e "$mode tree $hash\t${path##*/}")"$'\n'
;;
$upper_path)
new_hash=$(echo -n "${trees[$path]}" | git mktree)
upper_path="${path%/*}"
trees[$upper_path]+="$(echo -e "040000 tree $new_hash\t${path##*/}")"$'\n'
[ $path = "./$subdir" ] && echo $new_hash
;;
esac
done)
new_tree=$(
git ls-tree -r -d $commit | tac | \
( while read mode type hash path; do
path="./$path"
case "$path" in
*/ae | */auto_evaluation)
upper_path="${path%/*}"
trees[$upper_path]+="$(echo -e "$mode tree $hash\t${path##*/}")"$'\n'
;;
$upper_path)
new_hash=$(echo -n "${trees[$path]}" | git mktree)
upper_path="${path%/*}"
trees[$upper_path]+="$(echo -e "040000 tree $new_hash\t${path##*/}")"$'\n'
;;
esac
done
echo -n "${trees[.]}" | git mktree ))
ae=$(git rev-parse refs/heads/ae)
if git diff-tree --quiet $ae $new_tree; then return; fi
export GIT_AUTHOR_NAME="$(git log --format=%an -1 $commit)"
export GIT_AUTHOR_EMAIL="$(git log --format=%ae -1 $commit)"
new_commit=$(git commit-tree $new_tree -p $ae -m "$(git cat-file commit $commit|sed -e '0,/^$/d')")
git update-ref refs/heads/ae $commit $ae
ae=$(git rev-parse refs/heads/ae) || 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)"
[ "$ae" ] && parent="-p $ae"
new_commit=$(git commit-tree $new_tree $parent -m "$(git cat-file commit $commit|sed -e '0,/^$/d')")
git update-ref refs/heads/ae $new_commit $ae
fi
}
while read oldrev newrev refname; do
if [ "$refname" = "refs/heads/master" ]; then
echo "Checking for AE updates"
for rev in $(git rev-list --reverse $oldrev..$newrev); do
handle_update $rev cviceni
handle_commit $rev cviceni
done
echo "Pushing AE to BRUTE"
git push -f --quiet git@brutegit.felk.cvut.cz:2017z_b4b35osy/ae.git ae:master
#git push -f --quiet git@brutegit.felk.cvut.cz:2017z_b4b35osy/ae.git ae:master
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