当前位置: 首页>>代码示例>>Python>>正文


Python DebianGitRepository.find_version方法代码示例

本文整理汇总了Python中gbp.deb.git.DebianGitRepository.find_version方法的典型用法代码示例。如果您正苦于以下问题:Python DebianGitRepository.find_version方法的具体用法?Python DebianGitRepository.find_version怎么用?Python DebianGitRepository.find_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gbp.deb.git.DebianGitRepository的用法示例。


在下文中一共展示了DebianGitRepository.find_version方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import find_version [as 别名]
def main(argv):
    ret = 0
    changelog = "debian/changelog"
    until = "HEAD"
    found_snapshot_banner = False
    version_change = {}
    branch = None

    options, args, dch_options, editor_cmd = parse_args(argv)

    try:
        try:
            repo = DebianGitRepository(".")
        except GitRepositoryError:
            raise GbpError("%s is not a git repository" % (os.path.abspath(".")))

        try:
            branch = repo.get_branch()
        except GitRepositoryError:
            # Not being on any branch is o.k. with --ignore-branch
            if not options.ignore_branch:
                raise

        if options.debian_branch != branch and not options.ignore_branch:
            gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
            raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")

        source = DebianSource(".")
        cp = source.changelog

        if options.since:
            since = options.since
        else:
            since = ""
            if options.auto:
                since = guess_documented_commit(cp, repo, options.debian_tag)
                if since:
                    msg = "Continuing from commit '%s'" % since
                else:
                    msg = "Starting from first commit"
                gbp.log.info(msg)
                found_snapshot_banner = has_snapshot_banner(cp)
            else:  # Fallback: continue from last tag
                since = repo.find_version(options.debian_tag, cp["Version"])
                if not since:
                    raise GbpError("Version %s not found" % cp["Version"])

        if args:
            gbp.log.info("Only looking for changes on '%s'" % " ".join(args))
        commits = repo.get_commits(since=since, until=until, paths=args, options=options.git_log.split(" "))
        commits.reverse()

        # add a new changelog section if:
        if options.new_version or options.bpo or options.nmu or options.qa or options.team or options.security:
            if options.bpo:
                version_change["increment"] = "--bpo"
            elif options.nmu:
                version_change["increment"] = "--nmu"
            elif options.qa:
                version_change["increment"] = "--qa"
            elif options.team:
                version_change["increment"] = "--team"
            elif options.security:
                version_change["increment"] = "--security"
            else:
                version_change["version"] = options.new_version
            # the user wants to force a new version
            add_section = True
        elif cp["Distribution"] != "UNRELEASED" and not found_snapshot_banner and commits:
            # the last version was a release and we have pending commits
            add_section = True
        elif options.snapshot and not found_snapshot_banner:
            # the user want to switch to snapshot mode
            add_section = True
        else:
            add_section = False

        if add_section and not version_change and not source.is_native():
            # Get version from upstream if none provided
            v = guess_version_from_upstream(repo, options.upstream_tag, cp)
            if v:
                version_change["version"] = v

        i = 0
        for c in commits:
            i += 1
            parsed = parse_commit(repo, c, options, last_commit=i == len(commits))
            commit_msg, (commit_author, commit_email) = parsed
            if not commit_msg:
                # Some commits can be ignored
                continue

            if add_section:
                # Add a section containing just this message (we can't
                # add an empty section with dch)
                cp.add_section(
                    distribution="UNRELEASED",
                    msg=commit_msg,
                    version=version_change,
                    author=commit_author,
#.........这里部分代码省略.........
开发者ID:hemmop,项目名称:git-buildpackage,代码行数:103,代码来源:dch.py

示例2: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import find_version [as 别名]
def main(argv):
    dirs = dict(top=os.path.abspath(os.curdir))
    needs_repo = False
    ret = 0
    skipped = False

    options, pkg, target = parse_all(argv)
    if not options:
        return ExitCodes.parse_error

    try:
        try:
            repo = DebianGitRepository('.')
            is_empty = repo.is_empty()

            (clean, out) = repo.is_clean()
            if not clean and not is_empty:
                gbp.log.err("Repository has uncommitted changes, commit these first: ")
                raise GbpError(out)
        except GitRepositoryError:
            # no repo found, create one
            needs_repo = True
            is_empty = True

        if options.download:
            dsc = download_source(pkg,
                                  dirs=dirs,
                                  unauth=options.allow_unauthenticated)
        else:
            dsc = pkg

        src = DscFile.parse(dsc)
        if src.pkgformat not in ['1.0', '3.0']:
            raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
        if options.verbose:
            print_dsc(src)

        if needs_repo:
            target = target or src.pkg
            if os.path.exists(target):
                raise GbpError("Directory '%s' already exists. If you want to import into it, "
                               "please change into this directory otherwise move it away first."
                               % target)
            gbp.log.info("No git repository found, creating one.")
            repo = DebianGitRepository.create(target)
            os.chdir(repo.path)
            repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo)

        if repo.bare:
            disable_pristine_tar(options, "Bare repository")

        dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
        upstream = DebianUpstreamSource(src.tgz)
        upstream.unpack(dirs['tmp'], options.filters)
        for (component, tarball) in src.additional_tarballs.items():
            gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
            unpack_component_tarball(upstream.unpacked, component, tarball, options.filters)

        format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
        tag = repo.version_to_tag(format[0], src.upstream_version)
        msg = "%s version %s" % (format[1], src.upstream_version)

        if repo.find_version(options.debian_tag, src.version):
            gbp.log.warn("Version %s already imported." % src.version)
            if options.allow_same_version:
                gbp.log.info("Moving tag of version '%s' since import forced" % src.version)
                move_tag_stamp(repo, options.debian_tag, src.version)
            else:
                raise SkipImport

        if not repo.find_version(format[0], src.upstream_version):
            gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1]))
            if is_empty:
                branch = None
            else:
                branch = [options.upstream_branch,
                          options.debian_branch][src.native]
                if not repo.has_branch(branch):
                    if options.create_missing_branches:
                        gbp.log.info("Creating missing branch '%s'" % branch)
                        repo.create_branch(branch)
                    else:
                        gbp.log.err(no_upstream_branch_msg % branch +
                                    "\nAlso check the --create-missing-branches option.")
                        raise GbpError

            if src.native:
                author = get_author_from_changelog(upstream.unpacked)
                committer = get_committer_from_author(author, options)
                commit_msg = "Import %s\n%s" % (msg, get_changes(upstream.unpacked,
                                                                 repo,
                                                                 is_empty,
                                                                 options.debian_branch))
            else:
                author = committer = {}
                commit_msg = "Import %s" % msg

            commit = repo.commit_dir(upstream.unpacked,
                                     commit_msg,
                                     branch,
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例3: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import find_version [as 别名]

#.........这里部分代码省略.........
                                        dest="customization_file",
                                        help=help_msg)

    (options, args) = parser.parse_args(argv[1:])
    gbp.log.setup(options.color, options.verbose)
    dch_options = process_options(options, parser)
    editor_cmd = process_editor_option(options)

    try:
        try:
            repo = DebianGitRepository('.')
        except GitRepositoryError:
            raise GbpError("%s is not a git repository" % (os.path.abspath('.')))

        branch = repo.get_branch()
        if options.debian_branch != branch and not options.ignore_branch:
            gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch))
            raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.")

        cp = ChangeLog(filename=changelog)

        if options.since:
            since = options.since
        else:
            since = ''
            if options.auto:
                since = guess_snapshot_commit(cp, repo, options)
                if since:
                    gbp.log.info("Continuing from commit '%s'" % since)
                    found_snapshot_header = True
                else:
                    gbp.log.info("Couldn't find snapshot header, using version info")
            if not since:
                since = repo.find_version(options.debian_tag, cp['Version'])
                if not since:
                    raise GbpError("Version %s not found" % cp['Version'])

        if args:
            gbp.log.info("Only looking for changes on '%s'" % " ".join(args))
        commits = repo.get_commits(since=since, until=until, paths=args,
                                   options=options.git_log.split(" "))
        commits.reverse()

        # add a new changelog section if:
        if options.new_version or options.bpo or options.nmu or options.qa or options.team:
            if options.bpo:
                version_change['increment'] = '--bpo'
            elif options.nmu:
                version_change['increment'] = '--nmu'
            elif options.qa:
                version_change['increment'] = '--qa'
            elif options.team:
                version_change['increment'] = '--team'
            else:
                version_change['version'] = options.new_version
            # the user wants to force a new version
            add_section = True
        elif cp['Distribution'] != "UNRELEASED" and not found_snapshot_header and commits:
            # the last version was a release and we have pending commits
            add_section = True
        elif options.snapshot and not found_snapshot_header:
            # the user want to switch to snapshot mode
            add_section = True
        else:
            add_section = False
开发者ID:dex4er,项目名称:git-buildpackage,代码行数:69,代码来源:dch.py

示例4: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import find_version [as 别名]
def main(argv):
    dirs = dict(top=os.path.abspath(os.curdir))
    needs_repo = False
    ret = 1
    skipped = False

    options, pkg, target = parse_all(argv)
    if not options:
        return ExitCodes.parse_error

    try:
        try:
            repo = DebianGitRepository('.')
            # remember if the was repo initially empty
            repo.empty = repo.is_empty()

            (clean, out) = repo.is_clean()
            if not clean and not repo.empty:
                raise GbpError("Repository has uncommitted changes, commit these first: %s" % out)
        except GitRepositoryError:
            # no repo found, create one
            needs_repo = True

        if options.download:
            dscfile = download_source(pkg,
                                      dirs=dirs,
                                      unauth=options.allow_unauthenticated)
        else:
            dscfile = pkg

        dsc = DscFile.parse(dscfile)
        if dsc.pkgformat not in ['1.0', '3.0']:
            raise GbpError("Importing %s source format not yet supported." % dsc.pkgformat)
        if options.verbose:
            print_dsc(dsc)

        if needs_repo:
            target = target or dsc.pkg
            if os.path.exists(target):
                raise GbpError("Directory '%s' already exists. If you want to import into it, "
                               "please change into this directory otherwise move it away first."
                               % target)
            gbp.log.info("No git repository found, creating one.")
            repo = DebianGitRepository.create(target)
            repo.empty = True
            os.chdir(repo.path)
            repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo)

        if repo.bare:
            disable_pristine_tar(options, "Bare repository")

        # unpack
        dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
        source = DebianUpstreamSource(dsc.tgz)
        source.unpack(dirs['tmp'], options.filters)
        for (component, tarball) in dsc.additional_tarballs.items():
            gbp.log.info("Found component tarball '%s'" % os.path.basename(tarball))
            unpack_component_tarball(source.unpacked, component, tarball, options.filters)

        if repo.find_version(options.debian_tag, dsc.version):
            gbp.log.warn("Version %s already imported." % dsc.version)
            if options.allow_same_version:
                gbp.log.info("Moving tag of version '%s' since import forced" % dsc.version)
                move_tag_stamp(repo, options.debian_tag, dsc.version)
            else:
                raise SkipImport

        # import
        if dsc.native:
            import_native(repo, source, dsc, options)
        else:
            imported = False
            commit = repo.find_version(options.upstream_tag, dsc.upstream_version)
            if not repo.find_version(options.upstream_tag, dsc.upstream_version):
                commit = import_upstream(repo, source, dsc, options)
                imported = True

            if not repo.has_branch(options.debian_branch):
                if options.create_missing_branches:
                    repo.create_branch(options.debian_branch, commit)
                else:
                    raise GbpError("Branch %s does not exist, use --create-missing-branches" %
                                   options.debian_branch)

            if dsc.diff or dsc.deb_tgz:
                apply_debian_patch(repo, source, dsc, commit, options)
            else:
                gbp.log.warn("Didn't find a diff to apply.")

            if imported and options.pristine_tar:
                repo.create_pristine_tar_commits(commit,
                                                 dsc.tgz,
                                                 dsc.additional_tarballs.items())

        if repo.get_branch() == options.debian_branch or repo.empty:
            # Update HEAD if we modified the checked out branch
            repo.force_head(options.debian_branch, hard=True)
        ret = 0
    except KeyboardInterrupt:
        gbp.log.err("Interrupted. Aborting.")
#.........这里部分代码省略.........
开发者ID:agx,项目名称:git-buildpackage,代码行数:103,代码来源:import_dsc.py

示例5: main

# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import find_version [as 别名]
def main(argv):
    dirs = dict(top=os.path.abspath(os.curdir))
    needs_repo = False
    ret = 0
    skipped = False

    options, args = parse_args(argv)
    if not options:
        return 1

    try:
        if len(args) != 1:
            gbp.log.err("Need to give exactly one package to import. Try --help.")
            raise GbpError
        else:
            pkg = args[0]
            if options.download:
                dsc = download_source(pkg,
                                      dirs=dirs,
                                      unauth=options.allow_unauthenticated,
                                      no_default_keyrings=options.no_default_keyrings,
                                      keyrings=options.keyring)
            else:
                dsc = pkg

            src = DscFile.parse(dsc)
            if src.pkgformat not in [ '1.0', '3.0' ]:
                raise GbpError("Importing %s source format not yet supported." % src.pkgformat)
            if options.verbose:
                print_dsc(src)

            try:
                repo = DebianGitRepository('.')
                is_empty = repo.is_empty()

                (clean, out) = repo.is_clean()
                if not clean and not is_empty:
                    gbp.log.err("Repository has uncommitted changes, commit these first: ")
                    raise GbpError(out)

            except GitRepositoryError:
                # no repo found, create one
                needs_repo = True
                is_empty = True

            if needs_repo:
                gbp.log.info("No git repository found, creating one.")
                repo = DebianGitRepository.create(src.pkg)
                os.chdir(repo.path)

            if repo.bare:
                set_bare_repo_options(options)

            dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
            upstream = DebianUpstreamSource(src.tgz)
            upstream.unpack(dirs['tmp'], options.filters)

            format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native]
            tag = repo.version_to_tag(format[0], src.upstream_version)
            msg = "%s version %s" % (format[1], src.upstream_version)

            if repo.find_version(options.debian_tag, src.version):
                 gbp.log.warn("Version %s already imported." % src.version)
                 if options.allow_same_version:
                    gbp.log.info("Moving tag of version '%s' since import forced" % src.version)
                    move_tag_stamp(repo, options.debian_tag, src.version)
                 else:
                    raise SkipImport

            if not repo.find_version(format[0], src.upstream_version):
                gbp.log.info("Tag %s not found, importing %s tarball" % (tag, format[1]))
                if is_empty:
                    branch = None
                else:
                    branch = [options.upstream_branch,
                              options.debian_branch][src.native]
                    if not repo.has_branch(branch):
                        if options.create_missing_branches:
                            gbp.log.info("Creating missing branch '%s'" % branch)
                            repo.create_branch(branch)
                        else:
                            gbp.log.err(no_upstream_branch_msg % branch +
                                        "\nAlso check the --create-missing-branches option.")
                            raise GbpError

                if src.native:
                    author = get_author_from_changelog(upstream.unpacked)
                    committer = get_committer_from_author(author, options)
                else:
                    author = committer = {}

                commit = repo.commit_dir(upstream.unpacked,
                                         "Imported %s" % msg,
                                         branch,
                                         author=author,
                                         committer=committer)

                if not (src.native and options.skip_debian_tag):
                    repo.create_tag(name=tag,
                                    msg=msg,
#.........这里部分代码省略.........
开发者ID:kelleyk,项目名称:git-buildpackage,代码行数:103,代码来源:import_dsc.py


注:本文中的gbp.deb.git.DebianGitRepository.find_version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。