Exemplo n.º 1
0
def _usage(ctx, options=''):
    if ctx.task:
        print(f'''USAGE: mold {ctx.command} {ctx.task} {options}
    run "mold {ctx.command} {ctx.task} help" for more info''')
        return system.fail()
    else:
        print(f'''USAGE: mold {ctx.command} [task] [...options] [--flags]
    run "mold {ctx.command} help" for more info''')
        return system.fail()
Exemplo n.º 2
0
def force_push(ctx, branch=None):
    if not _check_has_remote(ctx):
        print('ERROR: no remote origin unable to push')
        return system.fail()
    if not branch:
        branch = 'HEAD'
    _git_shell(ctx, f'push origin {branch} --force')
Exemplo n.º 3
0
def pull(ctx, branch=None):
    if not _check_has_remote(ctx):
        print('ERROR: no remote origin unable to push')
        return system.fail()
    if not branch:
        branch = _get_current_branch(ctx)
    return _git_shell(ctx, f'pull origin {branch}')
Exemplo n.º 4
0
def _set_remote(ctx, uri=None, remote_name='origin'):
    '''works as both git add and git set for the MOLD_ROOT'''
    if not uri:
        return system.fail()
    if not _check_remote_uri(ctx, uri).check_ok():
        return system.fail()
    _git_exec(ctx, 'remote remove ' +
              remote_name)  # remove and ignore failure (if no remote)
    result = _git_shell(ctx, f'remote add {remote_name} {uri}')
    if not result.check_ok():
        return result
    result = _git_shell(ctx, f'fetch --all -v')
    if not result.check_ok():
        print(f'WARNING: failed to git fetch {remote_name}')
        return result
    print(f'MOLD_ROOT\'s git remote {remote_name} is now:', uri)
    return result
Exemplo n.º 5
0
def clone(ctx, uri=None):
    # clone uses system.exec and shell because there is not MOLD_ROOT to cd into
    if not uri:
        print('ERROR: git clone requires a git-uri')
        return system.fail()
    # DO NOT refactor to USE _check_remote_uri because it will try to cd to MOLD_ROOT
    # whitch does not exits
    print(f'Checking {uri}: ', end='')
    result = system.exec('git ls-remote ' + uri)
    if not result.check_ok():
        print(f'Sorry, that a not valid remote uri.')
        return result
    print('OK')
    return system.shell(f'git clone {uri} {ctx.MOLD_ROOT}')
Exemplo n.º 6
0
def new_branch(ctx, branch=None):
    if not branch:
        return system.fail()
    return _git_shell(ctx, f'checkout -b {branch}')