Esempio n. 1
0
File: Import.py Progetto: rec/grit
def run_import(branch, **kwds):
    user, branch = parse_branch(branch)
    if branch not in Git.branch1es(user):
        raise ValueError(_BRANCH_ERROR.format(**locals()))
    if user == Settings.USER:
        Git.git('checkout', branch)
    else:
        Remote.remote(user, **kwds)
        Git.git('fetch', user, branch)
        Git.git('checkout', '-b', '/'.join([user, branch]))
Esempio n. 2
0
File: Start.py Progetto: rec/grit
def clone(directory):
    settings = Project.settings("clone")
    branch = settings.get("base_branch", "develop")

    root = GitRoot.root(os.getcwd())
    if root:
        directory = directory or os.path.basename(root)
        root = os.path.dirname(root)
    else:
        directory = directory or Settings.PROJECT
        root = os.getcwd()

    directory = File.next_version(os.path.join(root, directory))
    settings.update(branch=branch, directory=directory, project=Settings.PROJECT, user=Settings.USER)
    # Call git clone.
    if Git.git(*_CLONE.format(**settings).split(), cwd=root):
        raise ValueError("Failed to start new directory")

    Remote.remote("all", cwd=directory)
    Remote.remote("upstream", Settings.PROJECT, directory)
    Git.git("pull", "upstream", branch)
    banner("Created", branch + ", directory", directory)
    return directory
Esempio n. 3
0
def get_url(name='', user=''):
    if not platform.system() in _OPEN_COMMANDS:
        raise ValueError("Can't open a URL for platform.system() = " + plat)

    if user and 'upstream'.startswith(user):
        user = Settings.PROJECT_USER
    elif name and 'upstream'.startswith(name):
        user = Settings.PROJECT_USER
        name = ''
    elif user:
        for nickname, account in Remote.remote():
            if nickname == account:
                user = account
                break
    else:
        user = Settings.USER

    context = get_context(user)
    fmt = get_format_string(name, user, context)
    return fmt.format(**context)