|
1 | | -# List of commit hashes to ignore |
2 | | -# Most of these commits were site-wide changes that did not affect the content |
3 | | -ignore_commits=("67f6075f51de7c62327fba114e9310774f94fb95" "03eb7d5aea2e4750b1db40aa363b36b409d802a6" "1c14119c3afb28a20f892926de83e7f7c9eb8141" "c02f425d27b9dd76f451f3fec0fbf45979fd1048" "0d2a48e2e108d3ebb1ee6c0d825097b55c997394" "5d77a63b0f1899235bbabd6a6629f3306efd6af4" "c5838bc8b91c59fd7fbe5743dea6d5052d7427e5" "fa0ae14cfdaf0c51f51f7bbef398ccd4496d23b7" "ccad2024da87cc5ad70a7d34e6425ac9f1062b93" "6aa96e1c68ceb62ed99efa0f4173b8f79f5dc6eb" "267bb26f822c361da2386c9325764a9c99e65316" "feb7d14386e877e8f6f0781bad8c001addcd9971" "d1cd416ec70a5d12930c338a49c9beb41d853734") |
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
4 | 3 |
|
5 | | -find content/wiki -name "*.md" | while read fname; do |
6 | | - echo -n "$fname|" |
| 4 | +ignore_commits=( |
| 5 | + "67f6075f51de7c62327fba114e9310774f94fb95" |
| 6 | + "03eb7d5aea2e4750b1db40aa363b36b409d802a6" |
| 7 | + "1c14119c3afb28a20f892926de83e7f7c9eb8141" |
| 8 | + "c02f425d27b9dd76f451f3fec0fbf45979fd1048" |
| 9 | + "0d2a48e2e108d3ebb1ee6c0d825097b55c997394" |
| 10 | + "5d77a63b0f1899235bbabd6a6629f3306efd6af4" |
| 11 | + "c5838bc8b91c59fd7fbe5743dea6d5052d7427e5" |
| 12 | + "fa0ae14cfdaf0c51f51f7bbef398ccd4496d23b7" |
| 13 | + "ccad2024da87cc5ad70a7d34e6425ac9f1062b93" |
| 14 | + "6aa96e1c68ceb62ed99efa0f4173b8f79f5dc6eb" |
| 15 | + "267bb26f822c361da2386c9325764a9c99e65316" |
| 16 | + "feb7d14386e877e8f6f0781bad8c001addcd9971" |
| 17 | + "d1cd416ec70a5d12930c338a49c9beb41d853734" |
| 18 | + "f1f64019dbc4c68ba0930fabcb09bcba00f5f1ac" |
| 19 | +) |
7 | 20 |
|
8 | | - # Initialize variables |
9 | | - commit_found=false |
10 | | - commit_index=1 |
| 21 | +# Determine job count (cross-platform) |
| 22 | +if command -v nproc >/dev/null 2>&1; then |
| 23 | + JOBS=$(nproc) |
| 24 | +elif [[ "$OSTYPE" == "darwin"* ]]; then |
| 25 | + JOBS=$(sysctl -n hw.ncpu) |
| 26 | +else |
| 27 | + JOBS=4 |
| 28 | +fi |
11 | 29 |
|
12 | | - # Loop to find the first non-ignored commit |
13 | | - while [ "$commit_found" = false ]; do |
14 | | - current_commit=$(git log -"$commit_index" --follow --pretty="format:%H" -- "$fname" | tail -n 1) |
| 30 | +ignore_pattern=$(IFS='|'; echo "${ignore_commits[*]}") |
| 31 | +export ignore_pattern |
15 | 32 |
|
16 | | - if [[ ! " ${ignore_commits[@]} " =~ " ${current_commit} " ]]; then |
17 | | - commit_found=true |
18 | | - git log -"$commit_index" --follow --date=iso --pretty="format:%cs|%H;" -- "$fname" | tail -n 1 |
19 | | - else |
20 | | - commit_index=$((commit_index + 1)) |
21 | | - fi |
22 | | - done |
23 | | -done |
| 33 | +process_file() { |
| 34 | + local fname="$1" |
| 35 | + local line |
| 36 | + line=$(git log --follow --no-patch --date=iso --pretty="format:%cs|%H;" -- "$fname" \ |
| 37 | + | grep -Ev "$ignore_pattern" \ |
| 38 | + | head -n 1) |
| 39 | + # No newline here |
| 40 | + printf '%s|%s' "$fname" "$line" |
| 41 | +} |
| 42 | + |
| 43 | +export -f process_file |
| 44 | + |
| 45 | +# Collect outputs in parallel but without newlines |
| 46 | +find content/wiki -name "*.md" -print0 | |
| 47 | + xargs -0 -P "$JOBS" -I{} bash -c 'process_file "$@"' _ {} |
0 commit comments