From 97264af7514697f47ff702f9f1f1c83d0a99fa9f Mon Sep 17 00:00:00 2001 From: NotXia <35894453+NotXia@users.noreply.github.com> Date: Sat, 16 Mar 2024 20:53:19 +0100 Subject: [PATCH] Update output directory hierarchy --- .github/workflows/compile.yml | 2 +- compile.sh | 31 ++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index a422d62..c25cdd2 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -4,7 +4,7 @@ on: push: branches: - main - paths: ["src/**", .github/workflows/**, ./compile.sh] + paths: ["src/**", .github/workflows/**, compile.sh] jobs: compile: diff --git a/compile.sh b/compile.sh index d908fcc..7c8ed19 100644 --- a/compile.sh +++ b/compile.sh @@ -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 \ No newline at end of file +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 \ No newline at end of file