How to use the bloom.git.track_branches function in bloom

To help you get started, we’ve selected a few bloom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ros-infrastructure / bloom / test / test_bloom_git.py View on Github external
check_call('git branch refactor', shell=True, cwd=orig_dir, stdout=PIPE)
    from vcstools import VcsClient
    clone = VcsClient('git', clone_dir)
    clone.checkout('file://{0}'.format(orig_dir), 'master')
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '* master\n'
    from bloom.git import track_branches
    track_branches(['bloom', 'upstream'], clone_dir)
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '  bloom\n* master\n  upstream\n', \
           '\n' + str(output) + '\n == \n' + '  bloom\n* master\n  upstream\n'
    track_branches(directory=clone_dir)
    output = check_output('git branch --no-color', shell=True, cwd=clone_dir)
    assert output == '  bloom\n* master\n  refactor\n  upstream\n', \
           output + ' == `  bloom\n* master\n  refactor\n  upstream\n`'
    track_branches(['fake'], clone_dir)
    output = check_output('git branch', shell=True, cwd=clone_dir)
    assert output.count('fake') == 0
    rmtree(tmp_dir)
github ros-infrastructure / bloom / bloom / generators / debian / main_all.py View on Github external
def main(sysargs=None):
    parser = get_argument_parser()
    args = parser.parse_args(sysargs)
    track_branches()
    branches = get_branches(local_only=True)
    targets = []
    for branch in branches:
        if branch.startswith(args.prefix):
            targets.append(branch)
    info("This will run git-bloom-generate-debian on these "
         "pacakges: " + str(targets))
    if not maybe_continue():
        error("Answered no to continue, exiting.")
        sys.exit(1)
    retcode = 0
    for index, target in enumerate(targets):
        # Branch first
        package = target[len('release/'):]
        new_target = 'debian/' + args.rosdistro
        info("Branching to debian prefix with: git-bloom-branch --src " + \
github ros-infrastructure / bloom / bloom / commands / git / branch.py View on Github external
set to the dst branch, otherwise the working branch will remain unchanged.

    :param src: source branch from which to copy
    :param dst: destination branch
    :param interactive: if True actions are summarized before committing
    :param directory: directory in which to preform this action

    :raises: subprocess.CalledProcessError if any git calls fail
    """
    # Determine if the srouce branch exists
    if src is None:
        error("No source specified and/or not a branch currently", exit=True)
    if branch_exists(src, local_only=False, directory=directory):
        if not branch_exists(src, local_only=True, directory=directory):
            debug("Tracking source branch: {0}".format(src))
            track_branches(src, directory)
    elif tag_exists(src):
        pass
    else:
        error("Specified source branch does not exist: {0}".format(src),
              exit=True)

    # Determine if the destination branch needs to be created
    create_dst_branch = False
    if branch_exists(dst, local_only=False, directory=directory):
        if not branch_exists(dst, local_only=True, directory=directory):
            debug("Tracking destination branch: {0}".format(dst))
            track_branches(dst, directory)
    else:
        create_dst_branch = True

    # Determine if the destination patches branch needs to be created
github ros-infrastructure / bloom / bloom / commands / git / patch / import_cmd.py View on Github external
def import_patches(directory=None):
    # Get current branch
    current_branch = get_current_branch(directory)
    if current_branch is None:
        error("Could not determine current branch.", exit=True)
    # Construct the patches branch name
    patches_branch = 'patches/' + current_branch
    # Ensure the patches branch exists and is tracked
    if branch_exists(patches_branch, False, directory=directory):
        if not branch_exists(patches_branch, True, directory=directory):
            track_branches(patches_branch, directory)
    else:
        error("The patches branch ({0}) does not ".format(patches_branch) +
              "exist, did you use git-bloom-branch?", exit=True)
    # Create a swap space
    tmp_dir = tempfile.mkdtemp()
    try:
        # Get parent branch and base commit from patches branch
        config = get_patch_config(patches_branch, directory)
        parent_branch, commit = config['parent'], config['base']
        if commit != get_commit_hash(current_branch, directory):
            debug(
                "commit != get_commit_hash(current_branch, directory)"
            )
            debug(
                "{0} != get_commit_hash({1}, {2}) != {3}".format(
                    commit, current_branch, directory,
github ros-infrastructure / bloom / bloom / config.py View on Github external
def upconvert_bloom_to_config_branch():
    global _has_checked_bloom_branch
    if _has_checked_bloom_branch:
        return
    # Assert that this repository does not have multiple remotes
    check_for_multiple_remotes()
    if get_root() is None:
        # Not a git repository
        return
    track_branches(['bloom', BLOOM_CONFIG_BRANCH])
    if show('bloom', PLACEHOLDER_FILE) is not None:
        return
    if show('bloom', 'bloom.conf') is not None:
        # Wait for the bloom.conf upconvert...
        return
    if not branch_exists('bloom'):
        return
    _has_checked_bloom_branch = True
    info("Moving configurations from deprecated 'bloom' branch "
         "to the '{0}' branch.".format(BLOOM_CONFIG_BRANCH))
    tmp_dir = mkdtemp()
    git_root = get_root()
    try:
        # Copy the new upstream source into the temporary directory
        with inbranch('bloom'):
            ignores = ('.git', '.gitignore', '.svn', '.hgignore', '.hg', 'CVS')
github ros-infrastructure / bloom / bloom / commands / git / branch.py View on Github external
# Determine if the destination branch needs to be created
    create_dst_branch = False
    if branch_exists(dst, local_only=False, directory=directory):
        if not branch_exists(dst, local_only=True, directory=directory):
            debug("Tracking destination branch: {0}".format(dst))
            track_branches(dst, directory)
    else:
        create_dst_branch = True

    # Determine if the destination patches branch needs to be created
    create_dst_patches_branch = False
    dst_patches = 'patches/' + dst
    if branch_exists(dst_patches, False, directory=directory):
        if not branch_exists(dst_patches, True, directory=directory):
            track_branches(dst_patches, directory)
    else:
        create_dst_patches_branch = True

    # Summarize
    if interactive:
        info("Summary of changes:")
        if create_dst_branch:
            info(" " * 22 + "- The specified destination branch, " +
                 ansi('boldon') + dst + ansi('reset') +
                 ", does not exist; it will be created from the source "
                 "branch " + ansi('boldon') + src + ansi('reset'))
        if create_dst_patches_branch:
            info(" " * 22 + "- The destination patches branch, " +
                 ansi('boldon') + dst_patches + ansi('reset') +
                 ", does not exist; it will be created")
        info(" " * 22 + "- The working branch will be set to " +
github ros-infrastructure / bloom / bloom / commands / git / import_upstream.py View on Github external
name_tag = '{0}/{1}'.format(name or 'upstream', version)
    if name_tag != upstream_tag and tag_exists(name_tag):
        if not replace:
            error("Tag '{0}' already exists, use --replace to override it."
                  .format(name_tag), exit=True)
        warning("Removing tag: '{0}'".format(name_tag))
        delete_tag(name_tag)
        if not get_git_clone_state():
            delete_remote_tag(name_tag)

    # If there is not upstream branch, create one
    if not branch_exists('upstream'):
        info("Creating upstream branch.")
        create_branch('upstream', orphaned=True)
    else:
        track_branches(['upstream'])

    # Import the given tarball
    info("Importing archive into upstream branch...")
    import_tarball(tarball_path, 'upstream', version, name)

    # Handle patches_path
    if patches_path:
        import_patches(patches_path, patches_path_dict, 'upstream', version)

    # Create tags
    with inbranch('upstream'):
        # Assert packages in upstream are the correct version
        _, actual_version, _ = get_package_data('upstream')
        if actual_version != version:
            error("The package(s) in upstream are version '{0}', but the version to be released is '{1}', aborting."
                  .format(actual_version, version), exit=True)