]>
git.proxmox.com Git - ceph.git/blob - ceph/src/script/build-integration-branch
4 Builds integration branches. Something similar to
5 $ git checkout -b branch-name
6 $ for b in $(get-branches-from-github) ; do
10 Requires `~/.github_token`.
14 build-integration-branch <label> [--no-date]
15 build-integration-branch -h | --help
18 -h --help Show this screen.
19 --no-date Don't add `{postfix}` to the branch name.
22 from __future__
import print_function
27 from subprocess
import call
31 from urllib
.parse
import urljoin
33 from urlparse
import urljoin
35 TIME_FORMAT
= '%Y-%m-%d-%H%M'
36 postfix
= "-" + time
.strftime(TIME_FORMAT
, time
.localtime())
41 from docopt
import docopt
42 arguments
= docopt(__doc__
.format(postfix
=postfix
))
43 label
= arguments
['<label>']
45 if not arguments
['--no-date']:
48 # Fallback without docopt.
50 assert len(sys
.argv
) == 2
51 branch
= label
+ postfix
54 with
open(os
.environ
['HOME'] + '/.github_token', 'r') as myfile
:
55 token
= myfile
.readline().strip()
58 baseurl
= urljoin('https://api.github.com', (
59 'repos/{repo}/issues?labels={label}'
60 '&access_token={token}'
71 j
= json
.loads(r
.text
or r
.content
)
72 print("--- found %d issues tagged with %s" % (len(j
), label
))
77 if 'pull_request' not in issue
:
79 r
= requests
.get(issue
['pull_request']['url'] + '?access_token=' + token
)
80 pr
= json
.loads(r
.text
or r
.content
)
82 prtext
.append(pr
['html_url'] + ' - ' + pr
['title'])
83 print("--- queried %s prs" % len(prs
))
85 print("branch %s" % branch
)
88 print('--- creating branch %s' % branch
)
89 r
= call(['git', 'branch', '-D', branch
])
90 r
= call(['git', 'checkout', '-b', branch
])
93 print('--- pr %d --- pulling %s branch %s' % (
95 pr
['head']['repo']['clone_url'],
97 r
= call(['git', 'pull', '--no-edit',
98 pr
['head']['repo']['clone_url'],
101 print('--- done. these PRs were included:')
102 print('\n'.join(prtext
).encode('ascii', errors
='ignore').decode())
103 print('--- perhaps you want to: make && ctest -j12 && git push ci %s' % branch
)