コード例 #1
0
 def test_branch(self):
     """
     _test_branch_
     """
     self.mock_repo.heads = []
     self.mock_repo.active_branch = 'new_branch'
     branch(None, self.mock_repo.active_branch, 'master')
     self.failUnless(self.mock_git.Repo.called)
コード例 #2
0
ファイル: git_tools_test.py プロジェクト: evansde77/cirrus
 def test_branch(self):
     """
     _test_branch_
     """
     self.mock_repo.heads = []
     self.mock_repo.active_branch = 'new_branch'
     branch(None, self.mock_repo.active_branch, 'master')
     self.failUnless(self.mock_git.Repo.called)
コード例 #3
0
ファイル: package.py プロジェクト: rajeshv23/cirrus
def setup_branches(opts):
    """
    set up git branches, starting from master
    """
    do_push = not opts.no_remote
    LOGGER.info("setting up branches master={} develop={}".format(
        opts.master, opts.develop))
    with working_dir(opts.repo):
        initializer = RepoInitializer(opts.repo)
        initializer.init_branch(opts.master, opts.origin, remote=do_push)
        initializer.init_branch(opts.develop, opts.origin, remote=do_push)
        branch(opts.repo, opts.develop, opts.master)
    LOGGER.info("Working on {}".format(get_active_branch(opts.repo)))
コード例 #4
0
ファイル: package.py プロジェクト: jordansamuels/cirrus
def setup_branches(opts):
    """
    set up git branches, starting from master
    """
    do_push = not opts.no_remote
    LOGGER.info("setting up branches master={} develop={}".format(
        opts.master, opts.develop))
    with working_dir(opts.repo):
        branch(opts.repo, opts.master, opts.master)
        branch(opts.repo, opts.develop, opts.master)
        if do_push:
            LOGGER.info("Pushing {}...".format(opts.develop))
            push(opts.repo)

    LOGGER.info("Working on {}".format(get_active_branch(opts.repo)))
コード例 #5
0
ファイル: package.py プロジェクト: rajeshv23/cirrus
def commit_and_tag(opts, *files):
    """
    add files, commit changes and verify that initial tag
    exists

    """
    do_push = not opts.no_remote
    commit_files_optional_push(opts.repo, "git cirrus package init", do_push,
                               *files)

    tags = get_tags(opts.repo)
    if opts.version not in tags:
        msg = ("tag {} not found, tagging {}...").format(
            opts.version, opts.master)
        LOGGER.info(msg)
        tag_release(opts.repo, opts.version, master=opts.master, push=do_push)
    branch(opts.repo, opts.develop, opts.develop)
コード例 #6
0
ファイル: feature.py プロジェクト: jordansamuels/cirrus
def new_feature_branch(opts):
    """
    _new_feature_branch_

    Checks out branch, creates new branch 'name', optionally
    pushes new branch to remote
    """
    config = load_configuration()
    repo_dir = os.getcwd()
    checkout_and_pull(repo_dir, config.gitflow_branch_name())
    LOGGER.info("Checked out and pulled {0}".format(
        config.gitflow_branch_name()))
    branch_name = ''.join((config.gitflow_feature_prefix(), opts.name[0]))
    branch(repo_dir, branch_name, config.gitflow_branch_name())
    LOGGER.info("Created branch {0}".format(branch_name))
    if opts.push:
        push(repo_dir)
        LOGGER.info("Branch {0} pushed to remote".format(branch_name))
コード例 #7
0
ファイル: feature.py プロジェクト: evansde77/cirrus
def new_feature_branch(opts):
    """
    _new_feature_branch_

    Checks out branch, creates new branch 'name', optionally
    pushes new branch to remote
    """
    config = load_configuration()
    repo_dir = repo_directory()
    checkout_and_pull(
        repo_dir,
        config.gitflow_branch_name(),
        pull=not opts.no_remote
    )
    LOGGER.info("Checked out and pulled {0}".format(
        config.gitflow_branch_name()))
    branch_name = ''.join((config.gitflow_feature_prefix(), opts.name[0]))
    branch(repo_dir,
           branch_name,
           config.gitflow_branch_name())
    LOGGER.info("Created branch {0}".format(branch_name))
    if not opts.no_remote:
        push(repo_dir)
        LOGGER.info("Branch {0} pushed to remote".format(branch_name))
コード例 #8
0
def new_release(opts):
    """
    _new_release_

    - Create a new release branch in the local repo
    - Edit the conf to bump the version
    - Edit the history file with release notes

    """
    LOGGER.info("Creating new release...")
    if not highlander([opts.major, opts.minor, opts.micro]):
        msg = "Can only specify one of --major, --minor or --micro"
        LOGGER.error(msg)
        raise RuntimeError(msg)

    fields = ['major', 'minor', 'micro']
    mask = [opts.major, opts.minor, opts.micro]
    field = [x for x in itertools.compress(fields, mask)][0]

    config = load_configuration()

    # version bump:
    current_version = config.package_version()
    new_version = bump_version_field(current_version, field)

    # release branch
    branch_name = "{0}{1}".format(config.gitflow_release_prefix(), new_version)
    LOGGER.info('release branch is {0}'.format(branch_name))

    # need to be on the latest develop
    repo_dir = repo_directory()
    # make sure the branch doesnt already exist on remote
    if remote_branch_exists(repo_dir, branch_name):
        msg = ("Error: branch {branch_name} already exists on the remote repo "
               "Please clean up that branch before proceeding\n"
               "git branch -d {branch_name}\n"
               "git push origin --delete {branch_name}\n").format(
                   branch_name=branch_name)
        LOGGER.error(msg)
        raise RuntimeError(msg)

    # make sure repo is clean
    if has_unstaged_changes(repo_dir):
        msg = ("Error: Unstaged changes are present on the branch "
               "Please commit them or clean up before proceeding")
        LOGGER.error(msg)
        raise RuntimeError(msg)

    main_branch = config.gitflow_branch_name()
    checkout_and_pull(repo_dir, main_branch, pull=not opts.no_remote)

    # create release branch
    branch(repo_dir, branch_name, main_branch)

    # update cirrus conf
    config.update_package_version(new_version)
    changes = ['cirrus.conf']

    if opts.bump:
        reqs_file = os.path.join(repo_dir, 'requirements.txt')
        for pkg, version in opts.bump:
            LOGGER.info("Bumping dependency {} to {}".format(pkg, version))
            bump_package(reqs_file, pkg, version)
        changes.append(reqs_file)

    # update release notes file
    relnotes_file, relnotes_sentinel = config.release_notes()
    if (relnotes_file is not None) and (relnotes_sentinel is not None):
        LOGGER.info('Updating release notes in {0}'.format(relnotes_file))
        relnotes = "Release: {0} Created: {1}\n".format(
            new_version,
            datetime.datetime.utcnow().isoformat())
        relnotes += build_release_notes(repo_dir, current_version,
                                        config.release_notes_format())
        update_file(relnotes_file, relnotes_sentinel, relnotes)
        changes.append(relnotes_file)

    # update __version__ or equivalent
    version_file, version_attr = config.version_file()
    if version_file is not None:
        LOGGER.info('Updating {0} attribute in {1}'.format(
            version_file, version_attr))
        update_version(version_file, new_version, version_attr)
        changes.append(version_file)

    # update files changed
    msg = "cirrus release: new release created for {0}".format(branch_name)
    LOGGER.info('Committing files: {0}'.format(','.join(changes)))
    LOGGER.info(msg)
    commit_files_optional_push(repo_dir, msg, not opts.no_remote, *changes)
    return (new_version, field)