Debian Codegraph @

tools/distrib/pull_requests_interval.sh

raw
1 #!/bin/bash
2 # Copyright 2017 gRPC authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 if [ "x$1" = "x" ] ; then
17 echo "Usage: $0 <first ref> [second ref]"
18 exit 1
19 else
20 first=$1
21 fi
22
23 if [ -n $2 ] ; then
24 second=HEAD
25 fi
26
27 if [ -e ~/github-credentials.vars ] ; then
28 . ~/github-credentials.vars
29 fi
30
31 if [ "x$github_client_id" = "x" ] || [ "x$github_client_secret" = "x" ] ; then
32 echo "Warning: you don't have github credentials set."
33 echo
34 echo "You may end up exceeding guest quota quickly."
35 echo "You can create an application for yourself,"
36 echo "and get its credentials. Go to"
37 echo
38 echo " https://github.com/settings/developers"
39 echo
40 echo "and click 'Register a new application'."
41 echo
42 echo "From the application's information, copy/paste"
43 echo "its Client ID and Client Secret, into the file"
44 echo
45 echo " ~/github-credentials.vars"
46 echo
47 echo "with the following format:"
48 echo
49 echo "github_client_id=0123456789abcdef0123"
50 echo "github_client_secret=0123456789abcdef0123456789abcdef"
51 echo
52 echo
53 addendum=""
54 else
55 addendum="?client_id=$github_client_id&client_secret=$github_client_secret"
56 fi
57
58 unset notfirst
59 echo "["
60 git log --pretty=oneline $1..$2 |
61 grep '[^ ]\+ Merge pull request #[0-9]\{4,6\} ' |
62 cut -f 2 -d# |
63 cut -f 1 -d\ |
64 sort -u |
65 while read id ; do
66 if [ "x$notfirst" = "x" ] ; then
67 notfirst=true
68 else
69 echo ","
70 fi
71 echo -n " {\"url\": \"https://github.com/grpc/grpc/pull/$id\","
72 out=`mktemp`
73 curl -s "https://api.github.com/repos/grpc/grpc/pulls/$id$addendum" > $out
74 echo -n " "`grep '"title"' $out`
75 echo -n " "`grep '"login"' $out | head -1`
76 echo -n " \"pr\": $id }"
77 rm $out
78 done
79 echo
80 echo "]"