示例#1
0
def set_changelog_path(options, git_logger):
    # set default changelog path
    changelog_files = glob("**/changelog")
    if len(changelog_files) > 0:
        default_changelog_path = changelog_files[0]
    else:
        default_changelog_path = "debian/changelog"

    if options["changelog_path"]:
        changelog_path = options["changelog_path"]
    elif options["detailed"]:
        # ask path to changelog
        changelog_path = ask_question(
            "Related path to changelog (default %s): " %
            default_changelog_path, default_changelog_path)
    else:
        git_logger.info("Related path to changelog: %s" %
                        default_changelog_path)
        changelog_path = default_changelog_path
    git_logger.debug("set changelog_path to '%s" % changelog_path)

    # fails if changelog does not exist
    if os.path.isdir(changelog_path):
        git_logger.error("changelog-git: changelog '%s' is a directory" %
                         changelog_path)
        sys.exit(EXIT_CODES.CHANGELOG_PATH_INVALID)
    changelog_path_dir = os.path.dirname(changelog_path)
    if not os.path.isdir(changelog_path_dir):
        git_logger.error("changelog-git: changelog dir '%s' doesn't exists" %
                         changelog_path_dir)
        sys.exit(EXIT_CODES.CHANGELOG_PATH_INVALID)
    return changelog_path
示例#2
0
def set_changelog_path(options, git_logger):
    # set default changelog path
    changelog_files = glob("**/changelog")
    if len(changelog_files) > 0:
        default_changelog_path = changelog_files[0]
    else:
        default_changelog_path = "debian/changelog"

    if options["changelog_path"]:
        changelog_path = options["changelog_path"]
    elif options["detailed"]:
        # ask path to changelog
        changelog_path = ask_question(
            "Related path to changelog (default %s): " % default_changelog_path,
            default_changelog_path
        )
    else:
        git_logger.info("Related path to changelog: %s" % default_changelog_path)
        changelog_path = default_changelog_path
    git_logger.debug("set changelog_path to '%s" % changelog_path)

    # fails if changelog does not exist
    if os.path.isdir(changelog_path):
        git_logger.error("changelog-git: changelog '%s' is a directory" % changelog_path)
        sys.exit(EXIT_CODES.CHANGELOG_PATH_INVALID)
    changelog_path_dir = os.path.dirname(changelog_path)
    if not os.path.isdir(changelog_path_dir):
        git_logger.error("changelog-git: changelog dir '%s' doesn't exists" % changelog_path_dir)
        sys.exit(EXIT_CODES.CHANGELOG_PATH_INVALID)
    return changelog_path
示例#3
0
def set_version(options, default, git_logger):
    # ask version
    if options["version"]:
        version = options["version"]
    elif options["skip_prompt"]:
        git_logger.info("Version: %s" % default)
        version = default
    else:
        version = ask_question("Version (default %s): " % default, default)
    git_logger.debug("set version to '%s" % version)
    return version
示例#4
0
def set_version(options, default, git_logger):
    # ask version
    if options["version"]:
        version = options["version"]
    elif options["skip_prompt"]:
        git_logger.info("Version: %s" % default)
        version = default
    else:
        version = ask_question("Version (default %s): " % default, default)
    git_logger.debug("set version to '%s" % version)
    return version
示例#5
0
def set_package_name(options, default, git_logger):
    if options["package_name"]:
        package_name = options["package_name"]
    elif options["detailed"]:
        # ask package name
        package_name = ask_question("Package name (default %s): " % default, default)
    else:
        git_logger.info("Package name: %s" % default)
        package_name = default
    git_logger.debug("set package_name to '%s" % package_name)
    return package_name
示例#6
0
def set_package_name(options, default, git_logger):
    if options["package_name"]:
        package_name = options["package_name"]
    elif options["detailed"]:
        # ask package name
        package_name = ask_question("Package name (default %s): " % default,
                                    default)
    else:
        git_logger.info("Package name: %s" % default)
        package_name = default
    git_logger.debug("set package_name to '%s" % package_name)
    return package_name
示例#7
0
def set_to_commit(options, git_logger, repo):
    default = "HEAD"
    if options["to_commit"]:
        to_rev = options["to_commit"]
    elif options["detailed"]:
        # ask to commit
        to_rev = repo.git.rev_parse(
            ask_question("To commit (default %s): " % default, default))
    else:
        git_logger.info("To commit: HEAD %s" % default)
        to_rev = default
    git_logger.debug("set to_rev to '%s" % to_rev)
    return to_rev
示例#8
0
def set_to_commit(options, git_logger, repo):
    default = "HEAD"
    if options["to_commit"]:
        to_rev = options["to_commit"]
    elif options["detailed"]:
        # ask to commit
        to_rev = repo.git.rev_parse(
            ask_question("To commit (default %s): " % default, default)
        )
    else:
        git_logger.info("To commit: HEAD %s" % default)
        to_rev = default
    git_logger.debug("set to_rev to '%s" % to_rev)
    return to_rev
示例#9
0
def set_from_commit(options, git_logger, repo):
    if len(repo.tags) > 0:
        default = max_by_lambda(repo.tags,
                                (lambda x: x.tag.tagged_date
                                 if x.tag else x.commit.committed_date)).name
    else:
        default = "HEAD"

    if options["from_commit"]:
        from_rev = options["from_commit"]
    elif options["skip_prompt"]:
        git_logger.info("From commit: %s" % default)
        from_rev = default
    else:
        # ask from commit
        from_rev = repo.git.rev_parse(
            ask_question("From commit (default %s): " % default, default))
    git_logger.debug("set from_rev to '%s" % from_rev)
    return from_rev
示例#10
0
def set_from_commit(options, git_logger, repo):
    if len(repo.tags) > 0:
        default = max_by_lambda(
            repo.tags,
            (lambda x: x.tag.tagged_date if x.tag else x.commit.committed_date)
        ).name
    else:
        default = "HEAD"

    if options["from_commit"]:
        from_rev = options["from_commit"]
    elif options["skip_prompt"]:
        git_logger.info("From commit: %s" % default)
        from_rev = default
    else:
        # ask from commit
        from_rev = repo.git.rev_parse(
            ask_question("From commit (default %s): " % default, default)
        )
    git_logger.debug("set from_rev to '%s" % from_rev)
    return from_rev
示例#11
0
def set_project_path(options, git_logger):
    # set default project path
    default_project_path = os.getcwd()

    if options["project_path"]:
        project_path = options["project_path"]
    elif options["detailed"]:
        # ask project path
        project_path = os.path.abspath(
            ask_question("Project path (default %s): " % default_project_path, default_project_path)
        )
    else:
        git_logger.info("Project path: %s" % default_project_path)
        project_path = default_project_path
    git_logger.debug("project_path set to '%s'" % project_path)

    # check project path exist
    if not os.path.exists(project_path) or not os.path.isdir(project_path):
        git_logger.error("changelog-git: Can't find project directory '%s'" % project_path)
        sys.exit(EXIT_CODES.PROJECT_NOT_FOUND)
    os.chdir(project_path)
    git_logger.debug("chdir to project_path '%s'" % project_path)
    return project_path
示例#12
0
def set_project_path(options, git_logger):
    # set default project path
    default_project_path = os.getcwd()

    if options["project_path"]:
        project_path = options["project_path"]
    elif options["detailed"]:
        # ask project path
        project_path = os.path.abspath(
            ask_question("Project path (default %s): " % default_project_path,
                         default_project_path))
    else:
        git_logger.info("Project path: %s" % default_project_path)
        project_path = default_project_path
    git_logger.debug("project_path set to '%s'" % project_path)

    # check project path exist
    if not os.path.exists(project_path) or not os.path.isdir(project_path):
        git_logger.error("changelog-git: Can't find project directory '%s'" %
                         project_path)
        sys.exit(EXIT_CODES.PROJECT_NOT_FOUND)
    os.chdir(project_path)
    git_logger.debug("chdir to project_path '%s'" % project_path)
    return project_path