2023-06-04 17:35:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-10-19 01:54:40 +00:00
|
|
|
filename="$1"
|
2023-10-19 07:18:25 +00:00
|
|
|
output="$2"
|
2023-06-04 17:35:54 +00:00
|
|
|
lines_per_chunk=100
|
|
|
|
|
|
|
|
if [ -e "$output" ]; then
|
|
|
|
rm "$output"
|
|
|
|
fi
|
|
|
|
|
|
|
|
total_lines=$(wc -l < "$filename")
|
|
|
|
for ((start=1; start <= total_lines; start += lines_per_chunk)); do
|
|
|
|
repos=$(tail -n +$start "$filename" | head -n $lines_per_chunk)
|
|
|
|
query=""
|
|
|
|
index=1
|
|
|
|
while IFS= read -r line; do
|
|
|
|
owner="${line%%/*}"
|
|
|
|
repo_name="${line#*/}"
|
|
|
|
query=$query" r$index: repository(name: \"$repo_name\", owner: \"$owner\", followRenames: true) {
|
|
|
|
isArchived
|
|
|
|
nameWithOwner
|
|
|
|
}"
|
|
|
|
index=$((index+1))
|
|
|
|
done <<< $repos
|
|
|
|
# result=$(gh api graphql -f query="query repository { $query }" 2>/dev/null | jq -r '.data[] | .nameWithOwner + ": " + (.isArchived|tostring)')
|
|
|
|
result=$(gh api graphql -f query="query repository { $query }" 2>/dev/null | jq -r '.data[]|(.isArchived|tostring)')
|
|
|
|
paste -d ":" <(echo "$repos") <(echo "$result") | tee -a "$output"
|
|
|
|
done
|