-
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.
Run more often, attempt to add to the jsonl automatically
- Loading branch information
Showing
2 changed files
with
29 additions
and
4 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,25 @@ | ||
#!/bin/bash | ||
last_commit_hash="" | ||
last_commit_time="" | ||
|
||
# Generate a list of commit hashes and associated file names | ||
git log --full-history -n 1 --reverse --name-only --pretty=format:"Commit: %H" -- "coinbase/24h_stats/BTC*" | \ | ||
awk '/^Commit:/ {commit=$2} !/^Commit:/ && NF {print commit, $0}' > commit_file_list.txt | ||
|
||
# Define a function to process each commit and file | ||
process_commit_file() { | ||
read -r commit file <<<"$1" | ||
|
||
# Fetch the commit time (no need to check for last commit as each job is independent) | ||
commit_time=$(git show -s --format=%ci "$commit") | ||
|
||
# Use git show to display the content of each file at the point of the commit | ||
if git ls-tree -r --name-only "$commit" | grep -q "^$file$"; then | ||
git show "${commit}:${file}" | jq -c --arg hash "$commit" --arg commit_time "$commit_time" '. + {commit_time: $commit_time, h: $hash}' >> "coinbase/jsonl/$(basename "$file")" | ||
fi | ||
} | ||
|
||
export -f process_commit_file | ||
|
||
# Use GNU Parallel to process each commit and file in parallel | ||
cat commit_file_list.txt | parallel -j 30 process_commit_file |