From 6167b46a1d967992d5d92a9910fe8200e3af00ff Mon Sep 17 00:00:00 2001 From: Alex Schmitz Date: Sat, 28 Dec 2024 20:51:22 +0100 Subject: [PATCH] fix: adjust script and hook for new folder structure --- setup.sh | 8 ++++---- tools/hooks/post-commit | 21 ++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/setup.sh b/setup.sh index c215773..b430eef 100644 --- a/setup.sh +++ b/setup.sh @@ -8,20 +8,20 @@ thisdir=$(dirname $(readlink -f "$0")) # Enable pandoc for .docx diffs echo "Adding local configuration for diffing with pandoc ..." -git config --local diff.docx.textconv "toolspandoc --from=docx --to=markdown --track-changes=all" +git config --local diff.docx.textconv "tools/pandoc --from=docx --to=markdown --track-changes=all" git config --local diff.docx.prompt "false" git config --local diff.docx.binary "true" # Enable pptx2md for .pptx diffs -echo "Add local configuration for diffing with pptx2md..." -git config --local diff.pptx.textconv "sh -c 'tools/pptx2md --disable-image --disable-wmf \"$0\" -o ~/.cache/git/presentation.md >/dev/null && cat ~/.cache/git/presentation.md'" +echo "Add local configuration for diffing with pptx2md ..." +git config --local diff.pptx.textconv "sh -c 'tools/pptx2md --disable-image --disable-wmf \"\$0\" -o ~/.cache/git/presentation.md >/dev/null && cat ~/.cache/git/presentation.md'" git config --local diff.pptx.cachetextconv "true" git config --local diff.pptx.prompt "false" git config --local diff.pptx.binary "true" # Enable pdftotxt for .pdf diffs echo "Add local configuration for diffing with pdftotxt ..." -git config --local diff.pdf.textconv "sh -c 'tools/pdftotext -simple -enc UTF-8 \"$0\" -'" +git config --local diff.pdf.textconv "sh -c 'tools/pdftotext -simple -enc UTF-8 \"\$0\" -'" git config --local diff.pdf.cachetextconv "true" git config --local diff.pdf.prompt "false" git config --local diff.pdf.binary "true" diff --git a/tools/hooks/post-commit b/tools/hooks/post-commit index 8aeb098..6224234 100644 --- a/tools/hooks/post-commit +++ b/tools/hooks/post-commit @@ -1,4 +1,5 @@ #!/bin/sh +set -e # Get the commit message export COM_MSG=`git log -n 1 HEAD --format=format:%s%n%b` @@ -7,22 +8,25 @@ export COM_MSG=`git log -n 1 HEAD --format=format:%s%n%b` [[ "$COM_MSG" != "Prepare v"* ]] && exit 0 # Get commit message to extract file names -IFS=$'\n' export FILES=`git log --name-only -n 1` # Loop all commit message lines for FILE in $FILES; do # Skip line if it does not contain .docx file information [[ "$FILE" != *".docx" ]] && continue - + # Skip if line is not an existing file [[ -f "$FILE" ]] || continue # Generate target file name - export FILE_NAME=${FILE/.docx/} + export BASE_FOLDER=$(dirname "$FILE") + export FILE_NAME=$(basename "${FILE/.docx/}") export VERSION_NUMBER=${COM_MSG/Prepare v/} export VERSION_NUMBER=${VERSION_NUMBER%"."} - export TARGET="document/releases/${FILE_NAME}_v${VERSION_NUMBER}.docx" + export TARGET="${BASE_FOLDER}/releases/${FILE_NAME}_v${VERSION_NUMBER}.docx" + + echo -e "$FILE" >> C://test.txt + echo -e "$TARGET" >> C://test.txt # Copy file to releases folder cp "$FILE" "$TARGET" @@ -37,11 +41,6 @@ for FILE in $FILES; do fi done - # Get all changed filenames - export CHANGED_FILES=`git log --name-only -n1` - - # Loop file named - #for CHANGED_FILE in $CHANGED_FILES; do - #done +echo "No errors found." -exit 1 \ No newline at end of file +exit 1