Exemple #1
0
def _pull_request(pull, working_branch):
    if pull.user == Settings.USER:
        nickname = 'origin'
    else:
        try:
            nickname = Remote.inverse()[pull.user]
        except KeyError:
            Remote.add_remote(pull.user, pull.user)
            nickname = pull.user

    keywords = {
        'nickname': nickname,
        'pull_branch': pull.branch,
        'working_branch': working_branch,
        'print': print if ARGS.verbose else None,
    }

    Call.runlines(
        """git fetch {nickname} {pull_branch}
           git checkout {nickname}/{pull_branch}
           git rebase --preserve-merges {working_branch}""",
        **keywords)

    # Store the commit ID at this point so we can merge back to it.
    keywords['commit_id'] = Git.commit_id()
    Call.runlines(
        """git checkout {working_branch}
           git merge --ff-only {commit_id}""",
        **keywords)

    _check_vcxproj()
Exemple #2
0
def start(branch, directory=""):
    branches = Git.branches()
    if branch in branches:
        raise ValueError(_ERROR % (branch, " ".join(branches)))

    directory = clone(directory)
    Call.call_raw("git checkout -b " + branch, cwd=directory)
    banner("Checked out new branch", branch)
Exemple #3
0
def _check_vcxproj():
    # Now run scons vcxproj and see if anything changes.
    if not CHECK_VCXPROJ:
        return
    Call.runlines('scons vcxproj')
    status = Git.git('status')
    if not MATCH in status:
        # TODO: Check to see if src/soci/src/core/version.h is the only
        # difference.
        raise VcxprojException()
Exemple #4
0
Fichier : Open.py Projet : rec/grit
def get_remotes():
    remotes = {}
    for line in Call.run(['git', 'remote', '-v']).splitlines():
        name, url, direction = line.split()
        account, site, user, project = GIT_URL_MATCHER(url).groups()
        assert account == 'git' and site == 'github.com'
        remotes[name] = user, project

    return remotes
Exemple #5
0
Fichier : New.py Projet : rec/grit
def new(*files):
    if not files:
        raise Exception('No files specified for "new" command.')
    existing_templates = _existing_templates()

    templates = []
    for f in files:
        if os.path.exists(f):
            raise Exception(f + ' already exists!')
        for t in existing_templates:
            if f.endswith(t):
                template = Project.data('new', '%s.template' % t)
                break
        else:
            raise ValueError('No template for ' + f)
        templates.append([f, template])

    settings = Project.settings('new')
    namespace = settings.get('namespace', Settings.PROJECT),
    root = GitRoot.ROOT
    include_root = os.path.join(root, settings['include_root'])
    for f, template in templates:
        body, extension = os.path.splitext(f)
        if extension.startswith('.'):
            extension = extension[1:]
        name = os.path.basename(body)
        fname = os.path.dirname(os.path.abspath(name))
        path_to_file = os.path.relpath(fname, include_root)
        output = template.format(
            guard=_get_guard(f),
            path_to_file=path_to_file,
            name=name,
            namespace=namespace)
        name = '%s.%s' % (body, extension)
        with open(name, 'w') as f:
            f.write(output)
        Call.call('git add ' + name)
        print(name, 'written and git added.')
    Remake.remake()
Exemple #6
0
def branches(prefix='', *args):
    root = GitRoot.root_container()
    pulls = Git.pull_branches()

    if not ARGS.expanded:
        fname = ['']

        def before(f):
            fname[0] = os.path.basename(f)

        def callback(data):
            parts = filter(None, data.splitlines())
            for i, p in enumerate(parts):
                branch = p.split()[-1]
                if branch in pulls:
                    branch += '(%s)' % pulls[branch]
                if p.startswith('*'):
                    branch = '*' + branch
                parts[i] = branch
            print('%-12s  %s' % (fname[0] + ':', ' '.join(parts)))

        Call.for_each_directory(
            BRANCH_COMMAND,
            path=root,
            select=GitRoot.select(prefix),
            before=before,
            callback=callback)
    else:
        def before(f):
            print('\n%s:' % os.path.basename(f))
        Call.for_each_directory(
            BRANCH_COMMAND,
            path=root,
            select=GitRoot.select(prefix),
            before=before)

    if args:
        print('ERROR: arguments %s ignored' % ', '.join(args))
Exemple #7
0
Fichier : Open.py Projet : rec/grit
def open_url(url):
    Call.call('%s %s' % (_OPEN_COMMANDS[platform.system()], url))
Exemple #8
0
Fichier : Test.py Projet : rec/grit
def run_test(cwd=None):
    test = Project.data('test.sh').strip()
    if not test:
        raise ValueError('No test!')
    Call.for_each(test.format(project=Settings.PROJECT), cwd=cwd)
Exemple #9
0
def remake():
    remake = Project.settings('remake').get('remake')
    if remake:
        Call.call(remake, cwd=GitRoot.ROOT)
        print('Project file remade.')
Exemple #10
0
def amend():
    Call.call(_AMEND)
    if ARGS.force:
        Call.call(_PUSH_F)