Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9346158
get_all_trees.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
950 B
Subscribers
None
get_all_trees.sh
View Options
#!/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'
\
|
sort
|
uniq
}
cd
"
$(
dirname
$0
)
"
tmpf
=
$(
mktemp
--suffix
github-graphql-search
)
cursor
=
""
for
i
in
$(
seq
1
10
)
;
do
echo
>
&
2
"Requesting page
$i
..."
cat
github_search.graphql
\
|
sed
's/\(search(.\+\))/\1'
"
$cursor
)/"
\
|
tee
/dev/null
|
github_query
|
tee
/dev/null
\
>
"
$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.endCursor'
"
$tmpf
"
)
cursor
=
", after:\"
$cursor
\""
done
rm
"
$tmpf
"
File Metadata
Details
Attached
Mime Type
text/x-shellscript
Expires
Fri, Jul 4, 3:46 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3260227
Attached To
rDSNIP Code snippets
Event Timeline
Log In to Comment