Browse Source

feat: add .gitignore file and hook scripts

master
Dennis Buchhorn 2 years ago
parent
commit
7b83c67ac0
3 changed files with 58 additions and 0 deletions
  1. +16
    -0
      .githooks/post-checkout
  2. +25
    -0
      .githooks/pre-commit
  3. +17
    -0
      .gitignore

+ 16
- 0
.githooks/post-checkout View File

@ -0,0 +1,16 @@
#!/bin/bash
repoRoot=$(git rev-parse --show-toplevel)
listFilesToSubstitute=$(find -name *.gitsubstitute)
listStaticPathFiles=$(git grep -lr --untracked $repoRoot)
listStagedFiles=$(git diff --staged --name-only)
staticPathSubstitution="\${REPO_ROOT}"
for entryFileToSubstitute in $listFilesToSubstitute; do
fullPath="${repoRoot}/${entryFileToSubstitute}"
fullPathSubstitute="${repoRoot}/${entryFileToSubstitute%.gitsubstitute}"
fileContent=$(<$fullPath)
echo "${fileContent//${staticPathSubstitution}/${repoRoot}}" > "${fullPathSubstitute}"
done

+ 25
- 0
.githooks/pre-commit View File

@ -0,0 +1,25 @@
#!/bin/bash
repoRoot=$(git rev-parse --show-toplevel)
listStaticPathFiles=$(git grep -lr --untracked $repoRoot)
listStagedFiles=$(git diff --staged --name-only)
staticPathSubstitution="\${REPO_ROOT}"
for entryStagedFile in $listStagedFiles; do
for entryStaticPathFile in $listStaticPathFiles; do
if [ $entryStagedFile == $entryStaticPathFile ]; then
fullPath="${repoRoot}/${entryStagedFile}"
entryStagedFileSubstitute="${entryStagedFile}.gitsubstitute"
fullPathSubstitute="${repoRoot}/${entryStagedFileSubstitute}"
rm -f $fullPathSubstitute
fileContent=$(<$fullPath)
echo "${fileContent//${repoRoot}/${staticPathSubstitution}}" > "${fullPathSubstitute}"
git rm --cached $entryStagedFile
git add -f $entryStagedFileSubstitute
fi
done
done

+ 17
- 0
.gitignore View File

@ -0,0 +1,17 @@
# ignore all workspace files
/.metadata/
/RemoteSystemsTempFiles/
.analytics
# ignore all log files
**/*.log
# ignore all files generated by pre-commit hook
**/*.gitsubstitute
# ignore all generated platform files but platform setup script
/hw_platform/*
!/hw_platform/platform.tcl
# ignore ide scripts
/*_system/_ide/scripts/*

Loading…
Cancel
Save