#!/usr/bin/env python3
"""
-Builds integration branches. Something similar to
+Builds integration branches. Something similar to
$ git checkout -b branch-name
$ for b in $(get-branches-from-github) ; do
> git pull b
--no-date Don't add `{postfix}` to the branch name.
"""
-from __future__ import print_function
-
import json
import os
import requests
-from subprocess import call, check_output
import sys
import time
-try:
- from urllib.parse import urljoin
-except:
- from urlparse import urljoin
+
+from subprocess import call, check_output
+from urllib.parse import urljoin
TIME_FORMAT = '%Y-%m-%d-%H%M'
postfix = "-" + time.strftime(TIME_FORMAT, time.localtime())
-current_branch = check_output('git rev-parse --abbrev-ref HEAD', shell=True).strip().decode()
+current_branch = check_output('git rev-parse --abbrev-ref HEAD',
+ shell=True).strip().decode()
if current_branch in 'mimic nautilus octopus pacific'.split():
- postfix += '-' + current_branch
- print(f"Adding current branch name '-{current_branch}' as a postfix")
+ postfix += '-' + current_branch
+ print(f"Adding current branch name '-{current_branch}' as a postfix")
repo = "ceph/ceph"
try:
- from docopt import docopt
- arguments = docopt(__doc__.format(postfix=postfix))
- label = arguments['<label>']
- branch = label
- if not arguments['--no-date']:
- branch += postfix
+ from docopt import docopt
+ arguments = docopt(__doc__.format(postfix=postfix))
+ label = arguments['<label>']
+ branch = label
+ if not arguments['--no-date']:
+ branch += postfix
except ImportError:
- # Fallback without docopt.
- label = sys.argv[1]
- assert len(sys.argv) == 2
- branch = label + postfix
+ # Fallback without docopt.
+ label = sys.argv[1]
+ assert len(sys.argv) == 2
+ branch = label + postfix
-with open(os.environ['HOME'] + '/.github_token', 'r') as myfile:
+with open(os.path.expanduser('~/.github_token')) as myfile:
token = myfile.readline().strip()
# get prs
-baseurl = urljoin('https://api.github.com', (
- 'repos/{repo}/issues?labels={label}'
- '&sort=created'
- '&direction=asc'
- )
- )
-url = baseurl.format(
- label=label,
- repo=repo)
+baseurl = urljoin('https://api.github.com',
+ ('repos/{repo}/issues?labels={label}'
+ '&sort=created'
+ '&direction=asc'))
+url = baseurl.format(label=label,
+ repo=repo)
r = requests.get(url,
headers={'Authorization': 'token %s' % token})
assert(r.ok)