-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstale-branches.sh
More file actions
executable file
·34 lines (29 loc) · 962 Bytes
/
stale-branches.sh
File metadata and controls
executable file
·34 lines (29 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
readonly MAX_THRESHOLD=8
readonly GRAPHQL_PROJECT="aMat"
readonly JQ_CURSOR='.pageInfo.startCursor'
readonly JQ_REF_DATA='(.nodes[] | select(.headRef != null) | "\(.author.login) \(.headRefName)")'
threshold=0
cursor=""
generate_cursor_query() {
if [[ $cursor ]]; then
echo "\"$cursor\""
else
echo "null"
fi
}
total_results=()
while [ $MAX_THRESHOLD -gt $threshold ]; do
variables='{"owner": "lumoslabs", "name": "lumos_rails", "cursor":'"$(generate_cursor_query)"'}'
response=$(graphql query stale-branch.gql -a -p "$GRAPHQL_PROJECT" --variables="$variables")
round=`echo $response | jq -r ".data.repository.pullRequests | ${JQ_CURSOR}, ${JQ_REF_DATA}"`
cursor=`echo "$round" | head -n 1`
results=`echo "$round" | tail -n +2`
IFS=$'\n'
for result in $results; do
total_results+=($result)
done
unset IFS
((++threshold))
done
echo "TOTAL BRANCHES: ${#total_results[@]}"
printf '%s\n' "${total_results[@]}" | sort | uniq