build: update spec for renamed versions of some doc files
[pcp.git] / scripts / pcp-push
blobc58d144dbc22c54a89df54fb6f61147c491cab2f
1 #!/bin/sh
3 # typical usage:
4 # push-pcp -b master -t pcp -r 6bad98e4b0537c2e99b3906ca7a36f4998ea3419..
7 tmp=/var/tmp/$$
8 trap "rm -f $tmp.*; exit 0" 0 1 2 3 15
10 _usage()
12 echo >&2 "Usage: pcp-push [options]"
13 echo >&2
14 echo >&2 "options:"
15 echo >&2 " -b branch [defaults to master]"
16 echo >&2 " -n dryrun"
17 echo >&2 " -r range [defaults to \$(cat pushed.sha)..)]"
18 echo >&2 " -t tree [defaults to pcp]"
19 echo >&2 " -s short format, do not include commit messages"
20 exit 1
23 dryrun=false
24 GIT=git
25 branch=master
26 tree=origin
27 short=false
28 if [ -f pushed.sha ]
29 then
30 range=$(cat pushed.sha)..
31 else
32 range=''
34 while getopts "b:nr:st:?" c
36 case $c
39 branch="$OPTARG"
42 dryrun=true
43 GIT="echo + git"
46 range="$OPTARG"
49 short=true
52 tree="$OPTARG"
55 _usage
56 # NOTREACHED
57 esac
58 done
59 shift `expr $OPTIND - 1`
61 [ $# -eq 0 ] || _usage
63 if [ -z "$range" ]
64 then
65 echo "Error: no range from pushed.sha, so need -r range"
66 exit 1
70 unset GIT_EXTERNAL_DIFF
71 #old# pull=git://git.pcp.io/$tree.git
72 #old# push="ssh://git.pcp.io/oss/git/$tree.git $branch"
73 pull=`git config remote.$tree.url`
74 push=`echo "$pull" | sed -e 's/^git:/ssh:/' -e "s;/git.pcp.io/;/git.pcp.io/oss/git/;"`
75 push="$push $branch"
76 echo "Changes committed to $pull $branch" >/tmp/msg
77 echo >>/tmp/msg
78 git shortlog --no-merges --numbered $range >$tmp.tmp
79 if [ -s $tmp.tmp ]
80 then
81 cat $tmp.tmp >>/tmp/msg
82 else
83 echo "Nothing to push ... bye."
84 rm -f /tmp/msg
85 exit
87 git log --no-merges -p $range | diffstat -p1 >>/tmp/msg
88 if $short
89 then
91 else
92 echo >>/tmp/msg
93 echo "Details ..." >>/tmp/msg
94 echo >>/tmp/msg
95 git log --no-merges $range >>/tmp/msg
98 xclip -sel clip < /tmp/msg
99 cat /tmp/msg
100 echo "(all of this for email is in /tmp/msg)"
101 rm -f $tmp.y
102 while true
104 echo -n "Push to $push? [y|n|q] (or ctrl+C to abort) "
105 read ans </dev/tty
106 if [ -z "$ans" ]
107 then
109 elif [ "$ans" = y ]
110 then
111 touch $tmp.y
112 break
113 elif [ "$ans" = n ]
114 then
115 break
116 elif [ "$ans" = q ]
117 then
118 echo "Quitting ... pushed.sha not updated"
119 exit
121 echo "Answer the question, bozo!"
122 done
123 if [ -f $tmp.y ]
124 then
125 $GIT push $push
126 $GIT push --tags $push
129 rm -f $tmp.y
130 while true
132 echo -n "Push to github mirror? [y|n|q] (or ctrl+C to abort) "
133 read ans </dev/tty
134 if [ -z "$ans" ]
135 then
137 elif [ "$ans" = y ]
138 then
139 touch $tmp.y
140 break
141 elif [ "$ans" = n ]
142 then
143 break
144 elif [ "$ans" = q ]
145 then
146 echo "Quitting ... pushed.sha not updated"
147 exit
149 echo "Answer the question, bozo!"
150 done
151 if [ -f $tmp.y ]
152 then
153 push="ssh://git@github.com/performancecopilot/pcp.git"
154 $GIT push --mirror $push
157 # remember last commit that was pushed ...
159 sha=`git log | sed -e 's/commit //' -e 1q`
160 if $dryrun
161 then
162 echo "+ echo $sha >pushed.sha"
163 else
164 echo "$sha" >pushed.sha
165 case `id -un`
167 kenj)
168 echo "To send commit mail ..."
169 echo '$ sendcommitmail'
171 esac