]>
git.proxmox.com Git - ceph.git/blob - ceph/src/script/build-integration-branch
d92821b2f1f8060f59d53b68d6933c6b4964f21a
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.
28 from subprocess
import call
, check_output
29 from urllib
.parse
import urljoin
31 TIME_FORMAT
= '%Y-%m-%d-%H%M'
32 postfix
= "-" + time
.strftime(TIME_FORMAT
, time
.localtime())
34 current_branch
= check_output('git rev-parse --abbrev-ref HEAD',
35 shell
=True).strip().decode()
36 if current_branch
in 'mimic nautilus octopus pacific'.split():
37 postfix
+= '-' + current_branch
38 print(f
"Adding current branch name '-{current_branch}' as a postfix")
43 from docopt
import docopt
44 arguments
= docopt(__doc__
.format(postfix
=postfix
))
45 label
= arguments
['<label>']
47 if not arguments
['--no-date']:
50 # Fallback without docopt.
52 assert len(sys
.argv
) == 2
53 branch
= label
+ postfix
56 with
open(os
.path
.expanduser('~/.github_token')) as myfile
:
57 token
= myfile
.readline().strip()
60 baseurl
= urljoin('https://api.github.com',
61 ('repos/{repo}/issues?labels={label}'
64 url
= baseurl
.format(label
=label
,
67 headers
={'Authorization': 'token %s' % token
})
69 j
= json
.loads(r
.text
or r
.content
)
70 print("--- found %d issues tagged with %s" % (len(j
), label
))
75 if 'pull_request' not in issue
:
77 r
= requests
.get(issue
['pull_request']['url'],
78 headers
={'Authorization': 'token %s' % token
})
79 pr
= json
.loads(r
.text
or r
.content
)
81 prtext
.append(pr
['html_url'] + ' - ' + pr
['title'])
82 print("--- queried %s prs" % len(prs
))
84 print("branch %s" % branch
)
87 print('--- creating branch %s' % branch
)
88 r
= call(['git', 'branch', '-D', branch
])
89 r
= call(['git', 'checkout', '-b', branch
])
92 pr_number
= pr
['number']
93 pr_url
= pr
['head']['repo']['clone_url']
94 pr_ref
= pr
['head']['ref']
95 print(f
'--- pr {pr_number} --- pulling {pr_url} branch {pr_ref}')
97 r
= call(['git', 'pull', '--no-ff', '--no-edit', pr_url
, pr_ref
])
101 print(f
'Unable to access {pr_url}, retrying..')
103 message
= f
'Unable to resolve conflict when merging PR#{pr_number}'
104 raise Exception(message
)
106 message
= ('Exiting due to an unknown failure when pulling '
108 raise Exception(message
)
110 print('--- done. these PRs were included:')
111 print('\n'.join(prtext
).encode('ascii', errors
='ignore').decode())
112 print('--- perhaps you want to: ./run-make-check.sh && git push ci %s' % branch
)