-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from xm0onh/autofill-author
build:change
- Loading branch information
Showing
11 changed files
with
103 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ | |
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
yarn-error.log* | ||
|
||
*.env |
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 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: update-last-update | ||
name: Update Last Update Field | ||
entry: scripts/update_last_update.sh | ||
language: script | ||
files: '\.md$' |
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
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
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
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
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,38 @@ | ||
#!/bin/bash | ||
|
||
# Assuming your .env file is at the root of your repository | ||
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" | ||
REPO_ROOT=$(dirname "$SCRIPT_DIR") | ||
echo "REPO_ROOT: $REPO_ROOT" | ||
|
||
source "$REPO_ROOT/.env" | ||
|
||
date=$(date -u +"%m/%d/%Y") | ||
author_name=$AUTHOR_NAME | ||
|
||
# Check if AUTHOR_NAME is set | ||
if [[ -z "$author_name" ]]; then | ||
echo "Error: Author name is empty." | ||
exit 1 | ||
fi | ||
|
||
for file in $(git diff --cached --name-only | grep '\.md$'); do | ||
awk -v date="$date" -v author="$author_name" ' | ||
BEGIN {printed=0} | ||
/^---$/ {count++} # Count the number of occurrences of "---" | ||
count == 1 && !printed { # Only print between the first set of "---" | ||
if (/^last_update:/) { | ||
print "last_update:" | ||
print " date: " date | ||
print " author: " author | ||
printed=1 | ||
next | ||
} | ||
} | ||
!/^last_update:/ && !/^ date:/ && !/^ author:/ {print} # Skip old last_update lines | ||
' "$file" > temp && mv temp "$file" | ||
|
||
# Add the updated file to the staging area | ||
git add "$REPO_ROOT/$file" | ||
|
||
done |