ENGINE-883: files for commit hash work. Still need to set up the how-to and ensure we go back and forth to older commits without choking.

pull/3/head
Krista Bennett 2 years ago
parent 7abcfd2e8a
commit a6fb33c8c0

2
.gitattributes vendored

@ -1 +1 @@
*.h filter=commit_hash
commit_hash.h filter=commit_hash

@ -10,7 +10,6 @@ else
SED="sed -i"
fi
echo "FILE is $1"
echo "Replacing PEP_CURRENT_COMMIT_HASH value in src/commit_hash.h with DUMMY_COMMIT_HASH_ERROR. See you next checkout or after the commit!"
$($SED "s/\(PEP_CURRENT_COMMIT_HASH=\).*/\1\DUMMY_COMMIT_HASH_ERROR\"/" $1)
@ -18,4 +17,4 @@ $($SED "s/\(PEP_CURRENT_COMMIT_HASH=\).*/\1\DUMMY_COMMIT_HASH_ERROR\"/" $1)
# Honestly, I have no idea what git is doing with the stupid empty '' for sed, but I give up. It makes a commit_hash.h'' backup for no reason. So we eat it.
if [[ "$OSTYPE" == "darwin"* ]]; then
rm $1"'""'"
else
fi

@ -0,0 +1,25 @@
#! /bin/sh
#
# Pseudo-smudge file for pEpEngine's commit-hash header
#
if [[ "$OSTYPE" == "darwin"* ]]; then
SED='sed -i '"'""'"
else
SED="sed -i"
fi
if test -f "src/commit_hash.h"; then
commit_hash="$(git rev-parse HEAD)"
echo "Replacing PEP_CURRENT_COMMIT_HASH value in src/commit_hash.h with current HEAD commit hash, $commit_hash. Will clean on commit or checkout."
$($SED "s/\(PEP_CURRENT_COMMIT_HASH=\).*/\1\"$commit_hash\"/" src/commit_hash.h)
# Whatever. You win, MacOS. You win.
if [[ "$OSTYPE" == "darwin"* ]]; then
rm src/commit_hash.h"'""'"
fi
fi

@ -0,0 +1,11 @@
#! /bin/sh
grep "DUMMY_COMMIT_HASH_ERROR" src/commit_hash.h 1>/dev/null
if [ $? -eq 1 ]; then
staged_files=$(git diff-index --cached HEAD)
if [[ $staged_files == *commit_hash.h* ]]; then
echo "ERROR: You are checking in a modified src/commit_hash.h file which contains an unauthorised commit hash value - you shouldn't be. Please unstage it." >&2
echo "(Hint: git restore --staged src/commit_hash.h)"
exit 1
fi
fi

@ -1,19 +0,0 @@
#! /bin/sh
echo "HELLO????" >&2
#
# Smudge file for pEpEngine's commit-hash header
#
if [[ "$OSTYPE" == "darwin"* ]]; then
SED="sed -i ''"
else
SED="sed -i"
fi
commit_hash="$(git rev-parse HEAD)"
echo "Replacing PEP_CURRENT_COMMIT_HASH value in src/commit_hash.h with current HEAD commit hash, $commit_hash. Will clean on commit or checkout."
$($SED "s/\(PEP_CURRENT_COMMIT_HASH=\).*/\1\"$commit_hash\"/" $1)
Loading…
Cancel
Save