Skip to content

Commit

Permalink
fix: adjust script and hook for new folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sfadschm committed Dec 28, 2024
1 parent cb620ab commit 6167b46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 10 additions & 11 deletions tools/hooks/post-commit
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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"
Expand All @@ -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
exit 1

0 comments on commit 6167b46

Please sign in to comment.