10 -C use cached data, no download
32 shift $
(($OPTIND - 1))
37 echo "name is-a-fork created pushed updated description"
38 next_url
="https://api.github.com/users/${2?USERNAME is missing.}/repos"
39 while [ -n "$next_url" ]
41 resp
=`curl -sSi "$next_url"`
43 next_url
=`echo "$resp" |\
44 sed -ne '/^Link:/ s/.*\?<\(.\+\)>\s*;\s*rel=.next.*/\1/ p; /^\r*$/q' |\
48 sed -e '1,/^\r*$/d' |\
49 jq
-r '.[] | [.name, (.fork|tostring), .created_at, .pushed_at, .updated_at, ((.description//"")|gsub("\n";"\\n"))] | join("\t")'
61 apicall
="issues?state=all"
65 "\n==========================",
66 ([(.number|tostring)+":",.title]|join(" ")),
67 ([" "+.state,(.labels|.[].name)]|join(", ")),
68 ([" comments",.comments|tostring]|join(": ")),
69 " --------------------------",
70 (.body | split("\n") | .[] | " "+.)
72 sort | .[] | .[1:] | join("\n")'
82 jq
='[.[].login] | sort | join("\n")'
95 masterremote
=`git config branch.master.remote`
98 for info
in `git remote -v | perl -ne 'm{^(\S+)\s+\S+github.com[/:](.+?)/([^/.\s]+)} and print "$1 $2 $3\n"'`
100 IFS
=$oIFS read remote ghUser ghRepo
<<<"$info"
101 if [ "$remote" = "$masterremote" ]; then break; fi
104 gitdir
=`git rev-parse --git-dir`
107 static_fetch_api_and_save_cache
()
109 apiurl
=https
://api.github.com
/repos
/$ghUser/$ghRepo/$apicall
110 if [ ! "$cached" ] && curl
-sS "$apiurl" |
tee "$gitdir/$cachekey.json~"
112 if jq
-r "$jq" < "$gitdir/$cachekey.json~" >/dev
/null
2>&1
114 mv "$gitdir/$cachekey.json~" "$gitdir/$cachekey.json"
116 echo "Can not parse Githup API <$apiurl> response, using cache." 1>&2
117 cat "$gitdir/$cachekey.json"
121 cat "$gitdir/$cachekey.json"
129 static_parse_api_response
()
137 static_fetch_api_and_save_cache | static_parse_api_response
140 declare -A error
=([fetch
]=${PIPESTATUS[0]} [display
]=${PIPESTATUS[1]})
142 if [ ${error[fetch]} = 0 ]
144 exit ${error[display]}