]> git.proxmox.com Git - ceph.git/blob - ceph/src/script/build-integration-branch
update sources to 12.2.7
[ceph.git] / ceph / src / script / build-integration-branch
1 #!/usr/bin/env python
2
3 from __future__ import print_function
4
5 import json
6 import os
7 import requests
8 from subprocess import call
9 import sys
10 import time
11 try:
12 from urllib.parse import urljoin
13 except:
14 from urlparse import urljoin
15
16 label = sys.argv[1]
17 repo = "ceph/ceph"
18
19 with open(os.environ['HOME'] + '/.github_token', 'r') as myfile:
20 token = myfile.readline().strip()
21
22 # get prs
23 baseurl = urljoin('https://api.github.com',
24 'repos/{repo}/issues?labels={label}&access_token={token}')
25 url = baseurl.format(
26 label=label,
27 repo=repo,
28 token=token)
29 r = requests.get(url)
30 assert(r.ok)
31 j = json.loads(r.text or r.content)
32 print("--- found %d issues tagged with %s" % (len(j), label))
33
34 prs = []
35 prtext = []
36 for issue in j:
37 if 'pull_request' not in issue:
38 continue
39 r = requests.get(issue['pull_request']['url'] + '?access_token=' + token)
40 pr = json.loads(r.text or r.content)
41 prs.append(pr)
42 prtext.append(pr['html_url'] + ' - ' + pr['title'])
43 print("--- queried %s prs" % len(prs))
44
45 # name branch
46 TIME_FORMAT = '%Y-%m-%d-%H%M'
47 branch = label + "-" + time.strftime(TIME_FORMAT, time.localtime())
48 print("branch %s" % branch)
49
50 # assemble
51 print('--- creating branch %s' % branch)
52 r = call(['git', 'checkout', '-b', branch])
53 assert not r
54 for pr in prs:
55 print('--- pr %d --- pulling %s branch %s' % (
56 pr['number'],
57 pr['head']['repo']['clone_url'],
58 pr['head']['ref']))
59 r = call(['git', 'pull', '--no-edit',
60 pr['head']['repo']['clone_url'],
61 pr['head']['ref']])
62 assert not r
63 print('--- done. these PRs were included:')
64 print('\n'.join(prtext).encode('ascii', errors='ignore').decode())
65 print('--- perhaps you want to: make && ctest -j12 && git push ci %s' % branch)