Browse Source

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 1 year ago
parent
commit
a6fb33c8c0
7 changed files with 38 additions and 22 deletions
  1. +1
    -1
      .gitattributes
  2. +1
    -2
      scripts/git/git-filter-clean-pEpEngine-commit-hash.sh
  3. +0
    -0
      scripts/git/post-checkout
  4. +25
    -0
      scripts/git/post-commit
  5. +0
    -0
      scripts/git/post-merge-commit
  6. +11
    -0
      scripts/git/pre-commit
  7. +0
    -19
      scripts/project/git-filter-smudge-pEpEngine-commit-hash.sh

+ 1
- 1
.gitattributes View File

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

scripts/project/git-filter-clean-pEpEngine-commit-hash.sh → scripts/git/git-filter-clean-pEpEngine-commit-hash.sh View File


scripts/project/post-checkout → scripts/git/post-checkout View File


+ 25
- 0
scripts/git/post-commit View File

@ -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
scripts/git/post-merge-commit View File


+ 11
- 0
scripts/git/pre-commit View File

@ -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

+ 0
- 19
scripts/project/git-filter-smudge-pEpEngine-commit-hash.sh View File

@ -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