-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
69 additions
and
60 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# Check if git is installed | ||
if ! command -v git &> /dev/null; then | ||
echo "git command not found. Please install git." | ||
exit 1 | ||
fi | ||
|
||
# Get the list of commits | ||
commits=$(git rev-list --all) | ||
|
||
result="[" | ||
|
||
for commit in $commits; do | ||
author_date=$(git show -s --format=%ai $commit) | ||
commit_date=$(git show -s --format=%ci $commit) | ||
message=$(git show -s --format=%s $commit | jq -R .) | ||
|
||
if [ "$author_date" != "$commit_date" ]; then | ||
# Convert dates to seconds since the epoch | ||
author_date_seconds=$(date -jf "%Y-%m-%d %H:%M:%S %z" "$author_date" "+%s") | ||
commit_date_seconds=$(date -jf "%Y-%m-%d %H:%M:%S %z" "$commit_date" "+%s") | ||
|
||
# Calculate time delta | ||
time_delta=$(($commit_date_seconds - $author_date_seconds)) | ||
|
||
result+="{ | ||
\"commit\": \"$commit\", | ||
\"message\": $message, | ||
\"author_date\": \"$author_date\", | ||
\"commit_date\": \"$commit_date\", | ||
\"time_delta_seconds\": $time_delta | ||
}," | ||
fi | ||
done | ||
|
||
# Remove trailing comma and close the JSON array | ||
result=${result%?} | ||
result+="]" | ||
|
||
echo $result | jq . | ||
|
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