Exemplo n.º 1
0
import sys
import git_common

if __name__ == "__main__":
    if len(sys.argv) == 1: # No args
        print git_common.master_branch()
    elif len(sys.argv) == 2: # One arg
        try:
            git_common.master_branch(sys.argv[1])
        except Exception as e:
            for arg in e.args:
                print str(arg)
            sys.exit(-1)
    else:
        print "Usage: git ci-master [ [new master] ]"
        sys.exit(-1)
Exemplo n.º 2
0
    if project not in KNOWN_PROJECTS:
        response = raw_input(
            "You appear to be starting a branch for an unknown project.  Continue? [n]" 
        )
        if not response.startswith(('y','Y')):
            sys.exit(-1)

    branch = "JIRA-%s" % issue

    # branch may exist in remote but not local
    if os.spawnlp(os.P_WAIT,"git","git","fetch") != 0:
        print "Failed to fetch from origin. Branch not created."
        sys.exit(-1)

    if len(sys.argv) <= 2:
        master = git_common.master_branch()
    else:
        master = sys.argv[2]
        if master not in [b.name for b in git.Repo().branches]:
            print "Branch %s does not exist. Have you checked it out?" % master
            sys.exit(-1)

    # try to switch to the new branch
    if os.spawnlp(os.P_WAIT,"git","git","checkout",branch) == 0:
        # if it exists, pull
        print "Pulling from origin/%s..." % branch
        os.execlp("git","git","pull","origin",branch)
    else:
        # if it doesn't exist, create it
        print "Branch doesn't exist, creating new from %s" % master
        if os.spawnlp(os.P_WAIT,"git","git","checkout", master) != 0:
Exemplo n.º 3
0
import git
import sys
from jinja2 import Template
from git_common import sign_tag

import git_common

if __name__ == "__main__":

    params = {}
    # TODO: Is this correct? Should you be able to specify the branch?
    params['issue_branch'] =  git.Repo().active_branch.name
    params['merge_branch'] = git_common.master_branch()
    if len(sys.argv) > 1:
        params['merge_branch'] = sys.argv[1]
        if params['merge_branch'] not in [b.name for b in git.Repo().branches]:
            print "Branch %s does not exist. Have you checked it out?" % params['merge_branch']
            sys.exit(-1)
    if params['issue_branch'].lower() == params['merge_branch'].lower():
        print "You cannot merge an issue branch (%s) into itself" % params['issue_branch']
        sys.exit(-1)

    sign_tag('JIRA', params, "issue_sign_template.txt")