Skip to content

Commit

Permalink
test:
Browse files Browse the repository at this point in the history
  • Loading branch information
wkelly17 committed Nov 4, 2024
1 parent 0f07db0 commit a5fa14e
Show file tree
Hide file tree
Showing 3 changed files with 520 additions and 2 deletions.
27 changes: 27 additions & 0 deletions ex.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Load existing dates.json into a variable
if [[ -f "metadata.json" ]]; then
json=$(<dates.json)
else
json="{}" # Start with an empty JSON if dates.json doesn't exist
fi

# Use jq to ensure json is formatted correctly
json=$(echo "$json" | jq '.')

# Get modified files in the current commit
modified_files=$(git diff --name-only HEAD~1 HEAD)

# Update dates for modified files only
for filename in $modified_files; do
# Only proceed if file exists in repo and isn't hidden or in hidden folders
if [[ -f "$filename" ]] && [[ ! "$filename" =~ ^\. ]] && [[ ! "$filename" =~ /\. ]]; then
date=$(git log -1 --format="%aI" -- "$filename")
# Update the JSON object with the new date for the modified file
json=$(echo "$json" | jq --arg file "$filename" --arg date "$date" '.[$file] = $date')
fi
done

# Save the updated JSON to metadata.json
echo "$json" > metadata.json
2 changes: 1 addition & 1 deletion exampleFile.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Change whatever locally
Change whatever locally d
493 changes: 492 additions & 1 deletion metadata.json

Large diffs are not rendered by default.

0 comments on commit a5fa14e

Please sign in to comment.