コード例 #1
0
ファイル: pullreq.py プロジェクト: kirk91/codecli
def branch_is_published_already(branch):
    check_call(['git', 'fetch', 'origin'])
    commits = getoutput(['git', 'log', '--pretty=oneline', 'master..%s' % branch])
    if commits:
        log_line = commits.split('\n')[-1]
        first_ci = log_line.split()[0]
    else:
        first_ci = branch
    return bool(getoutput(['git', 'branch', '-r', '--contains', first_ci]))
コード例 #2
0
ファイル: pullreq.py プロジェクト: CCv5/codecli
def branch_is_published_already(branch):
    check_call(['git', 'fetch', 'origin'])
    commits = getoutput(
        ['git', 'log', '--pretty=oneline',
         'master..%s' % branch])
    if commits:
        log_line = commits.split('\n')[-1]
        first_ci = log_line.split()[0]
    else:
        first_ci = branch
    return bool(getoutput(['git', 'branch', '-r', '--contains', first_ci]))
コード例 #3
0
def add_remote(username):
    user_git_url = origin_git_url = None

    output = getoutput(['git', 'remote', '-v'])
    for line in output.splitlines():
        words = line.split()
        if words[0] == 'origin':
            origin_git_url = words[1]
        if words[0] == username:
            user_git_url = words[1]

    if not origin_git_url:
        raise Exception("No origin remote found, abort")

    repo = origin_git_url.rsplit('/', 1)[-1].rsplit('.', 1)[0]
    remote_name = username
    remote_url = repo_git_url('%s/%s' % (username, repo))

    if user_git_url:
        if user_git_url != remote_url:
            raise Exception("remote %s already exists, delete it first?")
        # already added
        return

    check_call(['git', 'remote', 'add', remote_name, remote_url])
コード例 #4
0
def current_repo_git_url(remote):
    from codecli.utils import getoutput, is_under_git_repo

    if not is_under_git_repo(os.path.curdir):
        raise NoProviderFound("It is not under a git repo")

    for line in getoutput(['git', 'remote', '-v']).splitlines():
        words = line.split()
        if words[0] == remote and words[-1] == '(push)':
            giturl = words[1]
            break
    else:
        raise NoProviderFound("no remote %s found" % remote)
    return re.sub(r"(?<=http://).+:.+@", "", giturl)
コード例 #5
0
ファイル: __init__.py プロジェクト: joest67/codecli
def current_repo_git_url(remote):
    from codecli.utils import getoutput, is_under_git_repo

    if not is_under_git_repo(os.path.curdir):
        raise NoProviderFound("It is not under a git repo")

    for line in getoutput(['git', 'remote', '-v']).splitlines():
        words = line.split()
        if words[0] == remote and words[-1] == '(push)':
            giturl = words[1]
            break
    else:
        raise NoProviderFound("no remote %s found" % remote)
    return re.sub(r"(?<=http://).+:.+@", "", giturl)
コード例 #6
0
    def get_remote_repo_url(self, remote):
        for line in utils.getoutput(['git', 'remote', '-v']).splitlines():
            words = line.split()
            if words[0] == remote and words[-1] == '(push)':
                giturl = words[1]
                break
        else:
            raise Exception("no remote %s found" % remote)

        giturl = re.sub(r"(?<=http://).+:.+@", "", giturl)
        assert (re.match(r"^http://([a-zA-Z0-9]+@)?code.dapps.douban.com/.+\.git$", giturl) or
                re.match(r"^git@code.(intra|dapps).douban.com:.+\.git$", giturl)), \
            "This url do not look like code dapps git repo url: %s" % giturl
        repourl = giturl[: -len('.git')]
        return repourl
コード例 #7
0
ファイル: provider_gitein.py プロジェクト: sunyi00/codecli
    def get_remote_repo_url(self, remote):
        for line in utils.getoutput(['git', 'remote', '-v']).splitlines():
            words = line.split()
            if words[0] == remote and words[-1] == '(push)':
                giturl = words[1]
                break
        else:
            raise Exception("no remote %s found" % remote)

        giturl = re.sub(r"(?<=http://).+:.+@", "", giturl)

        assert re.match(r"^[email protected]:.+\.git$", giturl) or re.match(
            r"^https://git.ein.plus/.+\.git$",
            giturl), ("This url do not look like a git.ein.plus repo url: %s" %
                      giturl)
        repourl = giturl[:-len('.git')]
        return repourl
コード例 #8
0
    def merge_config(self):
        email = utils.get_config('user.email')
        if not email:
            email = utils.getoutput(['git', 'config', 'user.email']).strip()
            if not email.endswith('@douban.com'):
                email = '*****@*****.**' % getuser()
            email = utils.ask(
                "Please enter your @douban.com email [%s]: " % email,
                default=email)
            utils.set_config('user.email', email)

        name = utils.get_user_name()
        if not name:
            name = email.split('@')[0]
            name = utils.ask("Please enter your name [%s]: " % name, default=name)
            utils.set_config('user.name', name)

        for key, value in utils.iter_config():
            utils.check_call(['git', 'config', key, value])