Exemple #1
0
def _release(pulls, working_branch, next_branch, selector_name):
    Git.complete_reset()
    Delete.do_delete([working_branch], print=None)
    Git.copy_from_remote(base_branch(), working_branch, push=False)

    pulls.sort(key=operator.attrgetter('number'))

    if pulls:
        print('%s: Building release branch for %s:' % (
            String.timestamp(), selector_name))
        print('  ' + '\n  '.join(str(p) for p in pulls))
        print()

    success = []
    failure = []
    exceptions = []
    for pull in pulls:
        try:
            print(pull.number, '...', sep='', end='')
            _pull_request(pull, working_branch)
        except VcxprojException:
            failure.append(pull.number)
            print('VCXPROJ...', end='')
        except Exception as e:
            failure.append(pull.number)
            print('ERROR...', end='')
        else:
            success.append(pull.number)
    if pulls:
        print()
        print()

    Version.version_commit(
        version_number=None, success=success, failure=failure)

    commit_id = Git.commit_id()

    Git.force_checkout(next_branch)
    Git.git('reset', '--hard', commit_id)
    Git.git('push', '-f')

    commits = Open.get_commits()
    plural = '' if len(commits) == 1 else 's'
    _print_pulls('Proposed new develop branch %s for pull%s' %
                 (commits, plural), success)
    _print_pulls('FAILED:', failure)
    if success or failure:
        print('---------------------------------------------')
        print()
    else:
        print(String.timestamp(), ': no pulls ready.')
Exemple #2
0
Fichier : Call.py Projet : rec/grit
def call_raw(command, **kwds):
    cmd = String.split_safe(command)
    try:
        return subprocess.check_output(cmd, **kwds)
    except subprocess.CalledProcessError as e:
        raise ValueError('Couldn\'t execute "%s", errorcode=%s' %
                         ' '.join(cmd), e.returncode)
Exemple #3
0
Fichier : Call.py Projet : rec/grit
def call_value(command, print=print, **kwds):
    cmd = String.split_safe(command)
    try:
        return 0, subprocess.check_output(cmd, **kwds)
    except subprocess.CalledProcessError as e:
        if print:
            print('ERROR2:'
                  ' command =', ' '.join(cmd),
                  ' code =', e.returncode)
            e.output and print(e.output)
        return e.returncode, ''
Exemple #4
0
def add_status_line(version, success, failure):
    parts = [version + ': ']
    for pulls, msg in [[success, 'Includes'], [failure, 'FAILED']]:
        if pulls:
            parts.extend(['%s pulls ' % msg, String.join_words(pulls), '. '])
    try:
        append = changelog()[-1].split(':')[0] != version
    except:
        append = True
    line = ''.join(parts).strip() + '\n'
    if append:
        changelog().append(line)
    else:
        changelog()[-1] = line
    write()
Exemple #5
0
def release():
    previous_pulls = {}
    while True:
        base_commit = Git.commit_id(upstream=True, branch=base_branch())
        success = False
        for selector in SELECTORS:
            success = selector.update_pulls(base_commit) or success

        if success:
            Slack.slack()
        else:
            print(String.timestamp(short=True) + ': no change.')
        if ARGS.period:
            time.sleep(ARGS.period)
            Cache.clear()
        else:
            break
Exemple #6
0
Fichier : Call.py Projet : rec/grit
def call(command, callback=None, print=print, **kwds):
    cmd = String.split_safe(command)
    returncode = 0
    error = ''
    if callback:
        try:
            callback(subprocess.check_output(cmd, **kwds))
        except subprocess.CalledProcessError as e:
            returncode = e.returncode
            error = e.output
    else:
        returncode = subprocess.call(cmd, **kwds)
    if returncode and print:
        print('ERROR:'
              ' command =', ' '.join(cmd),
              ' code =', returncode)
        error and print(error)
    return returncode
Exemple #7
0
def _print_pulls(message, pulls):
    if pulls:
        print(message, String.join_words(pulls) + '.')
Exemple #8
0
Fichier : Call.py Projet : rec/grit
def for_each(commands, before=None, after=None, **kwds):
    for command in filter(None, String.split_safe(commands, 'splitlines')):
        before and before(command)
        if call(command, **kwds):
            after and after(command)
Exemple #9
0
Fichier : Call.py Projet : rec/grit
def runlines(lines, print=print, **substitutions):
    for line in String.splitlines(lines.format(**substitutions)):
        run(line.split(), print=print)