Skip to content
Snippets Groups Projects
Commit 028e25c3 authored by Antoine Pietri's avatar Antoine Pietri
Browse files

seirl: ase-vault-test: add github queries

parent d550280d
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
github_query() {
query=$( cat )
jq -n --arg v "$query" '{"query": $v}' \
| curl -s -H "Authorization: bearer $( cat ~/.github_access_token )" \
-X POST -d @- https://api.github.com/graphql
}
extract_trees () {
jq --raw-output '.data.search.edges[].node.ref.target.tree.oid // empty'
}
cd "$( dirname $0 )"
tmpf=$( mktemp --suffix github-graphql-search )
cursor=""
for i in $( seq 1 5 ); do
echo >&2 "Requesting page $i..."
cat github_search.graphql \
| sed 's/\(search(.\+\))/\1'"$cursor)/" \
| github_query \
> "$tmpf"
extract_trees < "$tmpf"
hasNext=$( jq --raw-output '.data.search.pageInfo.hasNextPage' "$tmpf" )
if [ "$hasNext" != "true" ]; then
break;
fi
cursor=$( jq --raw-output '.data.search.pageInfo.startCursor' "$tmpf" )
cursor=", after:\"$cursor\""
done
rm "$tmpf"
#!/bin/bash
query=$( cat )
jq -n --arg v "$query" '{"query": $v}' | \
curl -s -H "Authorization: bearer $( cat ~/.github_access_token )" \
-X POST -d @- https://api.github.com/graphql
{
search(query: "language:c size:5000..12000 created:>=2010-01-01", type: REPOSITORY, first: 100) {
repositoryCount
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
edges {
node {
... on Repository {
name
url
ref(qualifiedName: "master") {
target {
... on Commit {
tree {
oid
}
}
}
}
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment