Example #1
0
def main(sysargs=None):
    if len(sysargs if sysargs is not None else sys.argv[1:]) == 0:
        # This means show me the current config, first check we have an env
        ensure_clean_working_env()
        if not branch_exists(BLOOM_CONFIG_BRANCH):
            sys.exit("No {0} branch found".format(BLOOM_CONFIG_BRANCH))
        show_current()
        info("See: 'git-bloom-config -h' on how to change the configs")
        return 0

    parser = get_argument_parser()
    add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Also check to see if git has been init'ed
    check_git_init()
    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise
    # Then call the verb
    try:
        args.func(args)
    except (KeyboardInterrupt, EOFError):
        error("\nUser sent a Keyboard Interrupt, aborting.", exit=True)
Example #2
0
def main(sysargs=None):
    parser = get_parser()
    parser = add_global_arguments(parser)

    # List the generators
    generator_names = list_generators()

    # Create the generators
    generators = create_generators(generator_names)

    # Setup a subparser for each generator
    create_subparsers(parser, generators.values())

    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    generator = generators[args.generator]

    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise

    # Run the generator that was selected in a clone
    # The clone protects the release repo state from mid change errors
    with log_prefix('[git-bloom-generate {0}]: '.format(generator.title)):
        git_clone = GitClone()
        with git_clone:
            run_generator(generator, args)
        git_clone.commit()
Example #3
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise

    git_clone = GitClone()
    with git_clone:
        import_upstream(
            args.archive_path,
            args.patches_path,
            args.release_version,
            args.name,
            args.replace)
    git_clone.commit()

    info("I'm happy.  You should be too.")
Example #4
0
def main(sysargs=None):
    parser = get_parser()
    parser = add_global_arguments(parser)

    # List the generators
    generator_names = list_generators()

    # Create the generators
    generators = create_generators(generator_names)

    # Setup a subparser for each generator
    create_subparsers(parser, generators.values())

    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    generator = generators[args.generator]

    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise

    # Run the generator that was selected in a clone
    # The clone protects the release repo state from mid change errors
    with log_prefix('[git-bloom-generate {0}]: '.format(generator.title)):
        git_clone = GitClone()
        with git_clone:
            run_generator(generator, args)
        git_clone.commit()
Example #5
0
def main(sysargs=None):
    parser = get_parser()
    parser = add_global_arguments(parser)

    # List the generators
    generator_names = list_generators()

    # Create the generators
    generators = create_generators(generator_names)

    # Setup a subparser for each generator
    create_subparsers(parser, generators.values())

    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    generator = generators[args.generator]

    # Run the generator that was selected in a clone
    # The clone protects the release repo state from mid change errors
    with log_prefix('[git-bloom-generate {0}]: '.format(generator.title)):
        git_clone = GitClone()
        try:
            with git_clone:
                ret = run_generator(generator, args)
            if ret > 0:
                return ret
            git_clone.commit()
            return ret
        except GeneratorError as err:
            return err.retcode
Example #6
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    export_upstream(args.uri, args.tag, args.type, args.output_dir, args.display_uri, args.name)
Example #7
0
def main(sysargs=None):
    if len(sysargs if sysargs is not None else sys.argv[1:]) == 0:
        # This means show me the current config, first check we have an env
        ensure_clean_working_env()
        if not branch_exists('bloom'):
            sys.exit("No bloom branch found")
        show_current()
        info("See: 'git-bloom-config -h' on how to change the configs")
        return 0

    parser = get_argument_parser()
    add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Also check to see if git has been init'ed
    check_git_init()
    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise
    # Then call the verb
    try:
        args.func(args)
    except (KeyboardInterrupt, EOFError):
        error("\nUser sent a Keyboard Interrupt, aborting.", exit=True)
Example #8
0
def main(sysargs=None):
    # Check that the current directory is a serviceable git/bloom repo
    ensure_clean_working_env()
    ensure_git_root()

    # Get tracks
    tracks_dict = get_tracks_dict_raw()
    if not tracks_dict['tracks']:
        error("No tracks configured, first create a track with "
              "'git-bloom-config new <track_name>'", exit=True)

    # Do argparse stuff
    parser = get_argument_parser([str(t) for t in tracks_dict['tracks']])
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    verify_track(args.track, tracks_dict['tracks'][args.track])

    execute_track(args.track, tracks_dict['tracks'][args.track],
                  args.release_increment, args.pretend, args.debug, args.unsafe)

    # Notify the user of success and next action suggestions
    print('\n\n')
    warning("Tip: Check to ensure that the debian tags created have the same "
            "version as the upstream version you are releasing.")
    info(fmt("@{gf}@!Everything went as expected, "
         "you should check that the new tags match your expectations, and "
         "then push to the release repo with:@|"))
    info(fmt("  git push --all && git push --tags  "
             "@{kf}@!# You might have to add --force to the second command if you "
             "are over-writing existing flags"))
Example #9
0
def main():
    # Assumptions: in a git repo, this command verb was passed, argv has enough
    sysargs = sys.argv[2:]
    parser = get_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)
    return trim(args.sub_directory, args.force, args.undo)
Example #10
0
def main():
    # Assumptions: in a git repo, this command verb was passed, argv has enough
    sysargs = sys.argv[2:]
    parser = get_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)
    return rebase_patches()
Example #11
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    export_upstream(args.uri, args.tag, args.type, args.output_dir,
                    args.display_uri, args.name)
Example #12
0
def main(sysargs=None):
    from bloom.config import upconvert_bloom_to_config_branch
    upconvert_bloom_to_config_branch()

    # Check that the current directory is a serviceable git/bloom repo
    ensure_clean_working_env()
    ensure_git_root()

    # Get tracks
    tracks_dict = get_tracks_dict_raw()
    if not tracks_dict['tracks']:
        error(
            "No tracks configured, first create a track with "
            "'git-bloom-config new <track_name>'",
            exit=True)

    # Do argparse stuff
    parser = get_argument_parser([str(t) for t in tracks_dict['tracks']])
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    os.environ['BLOOM_TRACK'] = args.track

    verify_track(args.track, tracks_dict['tracks'][args.track])

    git_clone = GitClone()
    with git_clone:
        quiet_git_clone_warning(True)
        disable_git_clone(True)
        execute_track(args.track,
                      tracks_dict['tracks'][args.track],
                      args.release_increment,
                      args.pretend,
                      args.debug,
                      args.unsafe,
                      interactive=args.interactive)
        disable_git_clone(False)
        quiet_git_clone_warning(False)
    git_clone.commit()

    # Notify the user of success and next action suggestions
    info('\n\n', use_prefix=False)
    warning("Tip: Check to ensure that the debian tags created have the same "
            "version as the upstream version you are releasing.")
    info(
        fmt("@{gf}@!Everything went as expected, "
            "you should check that the new tags match your expectations, and "
            "then push to the release repo with:@|"))
    info(
        fmt("  git push --all && git push --tags  "
            "@{kf}@!# You might have to add --force to the second command if you "
            "are over-writing existing tags"))
Example #13
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    if args.list_tracks:
        list_tracks(args.repository, args.ros_distro)
        return

    perform_release(args.repository, args.track, args.ros_distro,
                    args.new_track, not args.non_interactive, args.pretend)
Example #14
0
def main(sysargs=None):
    parser = argparse.ArgumentParser(
        description="Calls a generator on a local package, e.g. bloom-generate debian"
    )

    generator_cmds = list_generator_commands()

    create_subparsers(parser, generator_cmds)

    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    sys.exit(args.func(args) or 0)
Example #15
0
def main(sysargs=None):
    parser = argparse.ArgumentParser(
        description=
        "Calls a generator on a local package, e.g. bloom-generate debian")

    generator_cmds = list_generator_commands()

    create_subparsers(parser, generator_cmds)

    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    sys.exit(args.func(args) or 0)
Example #16
0
def main(sysargs=None):
    global _quiet
    parser = get_argument_parser()
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)
    _quiet = args.quiet

    user_bloom = os.path.join(os.path.expanduser('~'), '.bloom')
    try:
        fetch_update(user_bloom)
    except Exception as e:
        if not _quiet:
            print('Error fetching latest version: ' + str(e), file=sys.stderr)
        if os.path.exists(user_bloom):
            os.remove(user_bloom)
Example #17
0
def main(sysargs=None):
    global _quiet
    parser = get_argument_parser()
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)
    _quiet = args.quiet

    user_bloom = os.path.join(os.path.expanduser('~'), '.bloom')
    try:
        fetch_update(user_bloom)
    except Exception as e:
        if not _quiet:
            print('Error fetching latest version: ' + str(e), file=sys.stderr)
        if os.path.exists(user_bloom):
            os.remove(user_bloom)
Example #18
0
def main(sysargs=None):
    if len(sysargs if sysargs is not None else sys.argv) == 1:
        retcode = ensure_clean_working_env()
        if retcode != 0:
            return retcode
        if branch_exists('bloom', False):
            show_current()
            info("See: 'git-bloom-config -h' on how to change the configs")
            return 0
        else:
            info("No bloom branch found")
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Check for freshly initialized repo
    ret = check_git_init()
    if ret != 0:
        return ret

    retcode = ensure_clean_working_env()
    if retcode != 0:
        return retcode

    # Summarize the requested operation
    summarize_arguments(args.upstream_repository, args.upstream_vcs_type,
                        args.upstream_branch)

    # Validate the arguments and repository
    if not validate_args(args.upstream_vcs_type):
        return 1

    # Store the current branch
    current_branch = get_current_branch()
    try:
        set_upstream(args.upstream_repository, args.upstream_vcs_type,
                     args.upstream_branch)
        info("Upstream successively set.")
        return 0
    finally:
        # Try to roll back to the branch the user was on before
        # this possibly failed.
        if current_branch:
            checkout(current_branch)

    return 1
Example #19
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    if args.list_tracks:
        list_tracks(args.repository, args.ros_distro)
        return

    try:
        os.environ['BLOOM_TRACK'] = args.track
        disable_git_clone(True)
        quiet_git_clone_warning(True)
        perform_release(args.repository, args.track, args.ros_distro,
                        args.new_track, not args.non_interactive, args.pretend)
    except (KeyboardInterrupt, EOFError) as exc:
        error("\nReceived '{0}', aborting.".format(type(exc).__name__))
Example #20
0
def main(sysargs=None):
    parser = get_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise

    # If the src argument isn't set, use the current branch
    if args.src is None:
        args.src = get_current_branch()
    # Execute the branching
    execute_branch(args.src, args.destination_branch, args.interactive)
Example #21
0
File: branch.py Project: po1/bloom
def main(sysargs=None):
    parser = get_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Check that the current directory is a serviceable git/bloom repo
    try:
        ensure_clean_working_env()
        ensure_git_root()
    except SystemExit:
        parser.print_usage()
        raise

    # If the src argument isn't set, use the current branch
    if args.src is None:
        args.src = get_current_branch()
    # Execute the branching
    execute_branch(args.src, args.destination_branch, args.interactive)
Example #22
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    if args.list_tracks:
        list_tracks(args.repository, args.ros_distro)
        return

    if args.no_web:
        os.environ['BLOOM_NO_WEBBROWSER'] = '1'

    try:
        os.environ['BLOOM_TRACK'] = args.track
        disable_git_clone(True)
        quiet_git_clone_warning(True)
        perform_release(args.repository, args.track, args.ros_distro,
                        args.new_track, not args.non_interactive, args.pretend)
    except (KeyboardInterrupt, EOFError) as exc:
        error("\nReceived '{0}', aborting.".format(type(exc).__name__))
Example #23
0
def main(sysargs=None):
    parser = get_argument_parser()
    parser = add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Check that the current directory is a serviceable git/bloom repo
    ret = ensure_clean_working_env()
    if ret != 0:
        parser.print_usage()
        return ret

    # Get the current git branch
    current_branch = get_current_branch()

    # Create a working temp directory
    tmp_dir = create_temporary_directory()

    cwd = os.getcwd()

    try:
        # Get off upstream branch
        if current_branch == 'upstream':
            checkout(get_commit_hash('upstream'), directory=cwd)

        retcode = import_upstream(cwd, tmp_dir, args)

        # Done!
        retcode = retcode if retcode is not None else 0
        if retcode == 0:
            info("I'm happy.  You should be too.")

        return retcode
    finally:
        # Change back to the original cwd
        os.chdir(cwd)
        # Clean up
        shutil.rmtree(tmp_dir)
        if current_branch and branch_exists(current_branch, True, cwd):
            checkout(current_branch, directory=cwd)
Example #24
0
def main(sysargs=None):
    parser = get_argument_parser()
    add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)
    retcode = "command not run"
    if get_root() is None:
        parser.print_help()
        error("This command must be run in a valid git repository.", exit=True)
    ensure_git_root()
    try:
        retcode = args.func(args) or 0
    except CalledProcessError as err:
        # Problem calling out to git probably
        print_exc(traceback.format_exc())
        error(str(err))
        retcode = 2
    except Exception as err:
        # Unhandled exception, print traceback
        print_exc(traceback.format_exc())
        error(str(err))
        retcode = 3
    sys.exit(retcode)
Example #25
0
def main(sysargs=None):
    parser = get_argument_parser()
    add_global_arguments(parser)
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)
    retcode = "command not run"
    if get_root() is None:
        parser.print_help()
        error("This command must be run in a valid git repository.", exit=True)
    ensure_git_root()
    try:
        retcode = args.func(args) or 0
    except CalledProcessError as err:
        # Problem calling out to git probably
        print_exc(traceback.format_exc())
        error(str(err))
        retcode = 2
    except Exception as err:
        # Unhandled exception, print traceback
        print_exc(traceback.format_exc())
        error(str(err))
        retcode = 3
    sys.exit(retcode)
Example #26
0
def main(args):
    handle_global_arguments(args)
    return remove_patches()
Example #27
0
def main(args):
    handle_global_arguments(args)
    return import_patches()
Example #28
0
def main(args):
    handle_global_arguments(args)

    ensure_git_root()

    return export_patches()
Example #29
0
def main(sysargs=None):
    # Do argparse stuff
    parser = get_argument_parser()
    parser = add_global_arguments(parser)

    # List the generators
    generator_names = list_generators()

    # Create the generators
    generators = create_generators(generator_names)

    # Setup a subparser for each generator
    create_subparsers(parser, generators.values())

    # Inject into sys.argv
    if '--prefix' not in sys.argv:
        sys.argv.extend(['--prefix', 'release'])
    args = parser.parse_args(sysargs)
    handle_global_arguments(args)

    # Set logging prefix
    push_log_prefix('[git-bloom-release]: ')

    # Run import upstream
    info("###")
    msg = "### Running 'git bloom-import-upstream --replace'... "
    info(msg)
    info("###")
    iu_args = ['--replace']
    if args.debug:
        iu_args.append('-d')
    ret = iu_main(iu_args)
    msg += "returned (" + str(ret) + ")"
    if ret > 0:
        error(msg)
        return 0
    if ret < 0:
        warning(msg)
    else:
        info(msg)
    print('\n')

    # Run release generator
    info("###")
    msg = "### Running 'git bloom-generate -y release --src upstream'... "
    info(msg)
    info("###")
    generator = generators['release']
    args.interactive = False
    release_args = copy.deepcopy(args)
    release_args.src = 'upstream'
    release_args.name = None
    ret = execute_generator(generator, release_args)
    msg += "returned (" + str(ret) + ")"
    if ret > 0:
        error(msg)
        return 0
    if ret < 0:
        warning(msg)
    else:
        info(msg)
    print('\n')

    # Run given generator
    info("###")
    msg = "### Running 'git bloom-generate -y {0}'... ".format(args.generator)
    info(msg)
    info("###")
    generator = generators[args.generator]
    ret = execute_generator(generator, args)
    msg += "returned (" + str(ret) + ")"
    if ret > 0:
        error(msg)
        return 0
    if ret < 0:
        warning(msg)
    else:
        info(msg)
    print('\n')

    # Undo log prefix
    pop_log_prefix()

    # Notify the user of success and next action suggestions
    print('\n\n')
    warning("Tip: Check to ensure that the debian tags created have the same "
            "version as the upstream version you are releasing.")
    info(ansi('greenf') + ansi('boldon') + "Everything went as expected, "
         "you should check that the new tags match your expectations, and "
         "then push to the release repo with:" + ansi('reset'))
    info("  git push --all && git push --tags  # You might have to add --force to the second command if you are over-writing existing flags")
    return 0
Example #30
0
def main(args):
    handle_global_arguments(args)
    return import_patches()
Example #31
0
def main(args):
    handle_global_arguments(args)

    ensure_git_root()

    return export_patches()
Example #32
0
def main(args):
    handle_global_arguments(args)
    return trim(args.sub_directory, args.force, args.undo)
Example #33
0
def main(args):
    handle_global_arguments(args)
    return trim(args.sub_directory, args.force, args.undo)
Example #34
0
def main(args):
    handle_global_arguments(args)
    return rebase_patches()