done
RSYNC_OPTS=(
- rsync -av
+ rsync -a
--delete
--exclude=.git
--exclude=target
)
checkout_branch() {
- if [ "$TAG_SUFFIX" != "" ]; then
- git checkout "${1}--${TAG_SUFFIX}"
+ if [ -n "$TAG_SUFFIX" ]; then
+ git checkout -q "${1}--${TAG_SUFFIX}"
else
- git checkout "$1"
+ git checkout -q "$1"
fi
}
sync_to() {
- mkdir -p "$1"
- "${RSYNC_OPTS[@]}" . "$1"
+ local dest="$1" rsync_out
+ rsync_out=$(mktemp)
+ mkdir -p "$dest"
+ "${RSYNC_OPTS[@]}" --itemize-changes . "$dest" > "$rsync_out"
+ grep -E '^[>c*]' "$rsync_out" || true
+ rm -f "$rsync_out"
+}
+
+sync_header() {
+ local branch="$1" dest="$2"
+ local src="${TAG_SUFFIX:+${branch}--${TAG_SUFFIX}}"
+ src="${src:-${branch}}"
+ echo -e "\n${src} → ${dest#../training-exercises/}"
}
if [ "$TAG_SUFFIX" = "" ] && ! $LOCAL; then
fi
echo "Einheitliche Tags vorhanden: $(echo "$_common_suffixes" | tr '\n' ' ')"
- echo "Aktualisiere alle Branches auf Remote-Stand..."
- git fetch origin
+ echo -e "\nAktualisiere alle Branches auf Remote-Stand..."
+ git fetch origin -q
reset_branches_to_remote
fi
EXPECTED=$(mktemp)
trap 'rm -f "$EXPECTED"' EXIT
+sync_header "grundlagen/docker" "$VORLAGEN/grundlagen/docker"
checkout_branch "grundlagen/docker"
echo "$VORLAGEN/grundlagen/docker" >> "$EXPECTED"
sync_to "$VORLAGEN/grundlagen/docker/"
declare -n branch=${i}
case "$branch" in
*--livecoding--schritte)
- echo "Ignoriere Einzelschritte eines Live-Codings: $branch"
+ echo -e "\nÜberspringe $branch"
continue
;;
*--vorlage)
dest="$MUSTERLOESUNGEN/$branch"
;;
esac
+ sync_header "$branch" "$dest"
checkout_branch "$branch"
echo "$dest" >> "$EXPECTED"
sync_to "$dest/"
done < <(find "$base" -mindepth 2 -maxdepth 2 -type d | sort)
done
-git checkout scripting
+git checkout -q scripting
reset_branches_to_remote() {
local branch
for branch in "${BRANCH_NAMES[@]}"; do
- echo -e "\nResetting $branch to origin/$branch"
- git checkout "$branch"
- git reset --hard "origin/$branch"
+ echo " $branch"
+ git checkout -q "$branch"
+ git reset -q --hard "origin/$branch"
done
- git checkout scripting
+ git checkout -q scripting
}