-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added pre-commit hooks to auto encrypt and stage lab_members.js…
…on file when it is updated
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Check if lab_members.json is staged for commit | ||
if git diff --cached --name-only | grep -q 'lab_members.json'; then | ||
echo "lab_members.json has changed. Encrypting the file..." | ||
|
||
# Prompt for the secret key | ||
read -sp "Enter encryption key: " SECRET_KEY | ||
echo | ||
|
||
# Encrypt lab_members.json | ||
openssl aes-256-cbc -salt -a -e -in lab_members.json -out lab_members.json.enc -pass pass:$SECRET_KEY -pbkdf2 | ||
|
||
# Clear the secret key variable | ||
unset SECRET_KEY | ||
|
||
# Stage the encrypted file | ||
git add lab_members.json.enc | ||
|
||
# Notify the user | ||
echo "lab_members.json has been encrypted and lab_members.json.enc has been staged for commit." | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Copy hooks to .git/hooks | ||
cp scripts/hooks/pre-commit .git/hooks/pre-commit | ||
chmod +x .git/hooks/pre-commit | ||
|
||
echo "Git hooks installed." | ||
|