示例#1
0
    def edit_changelog(self, branch, base_branch=None):
        repo = self.repo
        if not branch in repo.branches:
            raise ValueError("Branch %s does not exist." % branch)
        if base_branch and not base_branch in repo.branches:
            raise ValueError("Branch %s does not exist." % base_branch)

        repo.git.checkout(branch)
        topdir = repo.working_dir
        changelog = os.path.join(topdir, "Changelog")

        lines = []
        lines.append("#Changelog for %s\n" % branch)
        if base_branch:
            commits = repo.git.rev_list("%s..%s" % (base_branch, branch)).split("\n")
            for c in commits:
                commit = repo.commit(c)
                lines.append("* " + commit.message.split("\n")[0])
        lines.append("\n")

        f = open(changelog, 'rw+')
        lines.extend(f.readlines())
        f.seek(0)
        f.truncate(0)
        f.writelines(lines)
        f.close()

        editor = os.getenv('EDITOR')
        if not editor:
            editor = 'vim'
        call("%s %s" % (editor, changelog))
        repo.git.add(changelog)
        repo.git.commit(m="Update changelog")
        print "Updated changelog on branch %s" % branch
示例#2
0
文件: flow.py 项目: Erethon/devflow
def conflicts():
    try:
        yield
    except GitCommandError as e:
        if e.status != 128:
            print "An error occured. Resolve it and type 'exit'"
            call("bash")
        else:
            raise
示例#3
0
def conflicts():
    try:
        yield
    except GitCommandError as e:
        if e.status != 128:
            print "An error occured. Resolve it and type 'exit 0'"
            tmpbashrc=create_temp_file("bashrc")
            f = open(tmpbashrc, 'w')
            f.write("source $HOME/.bashrc ; export PS1=(Conflict)\"$PS1\"")
            f.close()
            call('bash --rcfile %s' % tmpbashrc)
            os.unlink(tmpbashrc)
        else:
            raise