Update output directory hierarchy

This commit is contained in:
2024-03-16 20:53:19 +01:00
parent e49b4a7ceb
commit 97264af751
2 changed files with 29 additions and 4 deletions

View File

@ -4,7 +4,7 @@ on:
push:
branches:
- main
paths: ["src/**", .github/workflows/**, ./compile.sh]
paths: ["src/**", .github/workflows/**, compile.sh]
jobs:
compile:

View File

@ -22,14 +22,14 @@ work_dir=`realpath src`
mkdir -p $out_dir
touch $hash_file
# $1: path of the directory
getDirLastHash() {
# $1: path of the directory
path="$1"
echo `awk -F"," "\\$1 == \"$path\" { print \\$2 } " $hash_file`
}
# $1: path of the directory
getDirCurrHash() {
# $1: path of the directory
path="$1"
echo `git log -n 1 --format='%h' $path/**/*.!(cls)`
}
@ -49,6 +49,19 @@ updateHashes() {
done
}
moveHierarchyUp() {
# Recursively moves the content of a directory up of a level.
# $1: starting directory
cd $1
mv ./*.* ../
for dir in */; do
[ "$dir" == "*/" ] && continue
moveHierarchyUp $dir
done
cd ..
rmdir $1 2> /dev/null
}
cd $work_dir
@ -90,4 +103,16 @@ for f in **/[!_]*.tex; do
cd $work_dir
done
updateHashes
updateHashes
# Moves the content of each output directory up of a level
cd $out_dir
for course_dir in */; do
[ "$course_dir" == "*/" ] && continue
cd $course_dir
for dir in */; do
[ "$dir" == "*/" ] && continue
moveHierarchyUp $dir
done
cd ..
done