conan report

conan report 命令包含用于返回有关包和库信息的子命令。

$ conan report -h
usage: conan report [-h] [--out-file OUT_FILE]
                    [-v [{quiet,error,warning,notice,status,verbose,debug,v,trace,vv}]]
                    [-cc CORE_CONF]
                    {diff} ...

Gets information about the recipe and its sources.

positional arguments:
  {diff}                sub-command help
    diff                Get the difference between two recipes with their
                        sources. It can be used to compare two different
                        versions of the same recipe, or two different recipe
                        revisions. Each old/new recipe can be specified by a
                        path to a conanfile.py and a companion reference, or
                        by a reference only. If only a reference is specified,
                        it will be searched in the local cache, or downloaded
                        from the specified remotes. If no revision is
                        specified, the latest revision will be used.

options:
  -h, --help            show this help message and exit
  --out-file OUT_FILE   Write the output of the command to the specified file
                        instead of stdout.
  -v [{quiet,error,warning,notice,status,verbose,debug,v,trace,vv}]
                        Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Define core configuration, overwriting global.conf
                        values. E.g.: -cc core:non_interactive=True

conan report diff

$ conan report diff -h
usage: conan report diff [-h] [-f FORMAT] [--out-file OUT_FILE]
                         [-v [{quiet,error,warning,notice,status,verbose,debug,v,trace,vv}]]
                         [-cc CORE_CONF] [-op OLD_PATH] -or OLD_REFERENCE
                         [-np NEW_PATH] -nr NEW_REFERENCE [-r REMOTE]

Get the difference between two recipes with their sources. It can be used to
compare two different versions of the same recipe, or two different recipe
revisions. Each old/new recipe can be specified by a path to a conanfile.py
and a companion reference, or by a reference only. If only a reference is
specified, it will be searched in the local cache, or downloaded from the
specified remotes. If no revision is specified, the latest revision will be
used.

options:
  -h, --help            show this help message and exit
  -f FORMAT, --format FORMAT
                        Select the output format: json, html
  --out-file OUT_FILE   Write the output of the command to the specified file
                        instead of stdout.
  -v [{quiet,error,warning,notice,status,verbose,debug,v,trace,vv}]
                        Level of detail of the output. Valid options from less
                        verbose to more verbose: -vquiet, -verror, -vwarning,
                        -vnotice, -vstatus, -v or -vverbose, -vv or -vdebug,
                        -vvv or -vtrace
  -cc CORE_CONF, --core-conf CORE_CONF
                        Define core configuration, overwriting global.conf
                        values. E.g.: -cc core:non_interactive=True
  -op OLD_PATH, --old-path OLD_PATH
                        Path to the old recipe if comparing a local recipe is
                        desired
  -or OLD_REFERENCE, --old-reference OLD_REFERENCE
                        Old reference, e.g. 'mylib/1.0'. If used on its own,
                        it can contain a revision, which will be resolved to
                        the latest one if not provided, but it will be ignored
                        if a path is specified. If used with a path, it will
                        be used to create the reference for the recipe to be
                        compared.
  -np NEW_PATH, --new-path NEW_PATH
                        Path to the new recipe if comparing a local recipe is
                        desired
  -nr NEW_REFERENCE, --new-reference NEW_REFERENCE
                        New reference, e.g. 'mylib/1.0'. If used on its own,
                        it can contain a revision, which will be resolved to
                        the latest one if not provided, but it will be ignored
                        if a path is specified. If used with a path, it will
                        be used to create the reference for the recipe to be
                        compared.
  -r REMOTE, --remote REMOTE
                        Look in the specified remote or remotes server

conan report diff 命令获取两个配方的差异,并比较它们的源代码。此功能允许您比较同一配方的两个版本,或两个完全不同的配方。每个配方(旧版本和新版本)可以通过以下两种方式之一来标识:提供其 conanfile.py 的路径及其引用,或仅指定引用。

当仅提供引用时,Conan 首先会在本地缓存中搜索配方;如果未找到,它将尝试从配置的远程仓库下载。如果未显式提供修订版,Conan 将默认使用最新的可用修订版。

示例

远程引用 vs 远程引用

如果我们要比较在我们的 my-remote 远程仓库中可用的 mylib 的版本 1.0 和 2.0,那么将是

$ conan report diff --old-reference="mylib/1.0" --new-reference="mylib/2.0" -r=my-remote

远程引用 vs 本地引用

假设我们正在修改配方或添加新版本,并且想要将我们的更改与远程仓库中的版本进行比较。未在远程仓库中的版本需要配方的路径才能进行比较。如果它是我们正在修改的旧版本并且未在远程仓库中找到,我们将使用 --old-path

$ conan report diff --old-reference="mylib/1.0" --old-path="path/to/recipe" --new-reference="mylib/2.0"

另一方面,如果它是我们正在修改的新版本,我们将使用 --new-path

$ conan report diff --old-reference="mylib/1.0" --new-reference="mylib/2.0" --new-path="path/to/recipe"

本地引用 vs 本地引用

最后,如果我们在修改两个版本,我们需要提供两个路径。它们可能相同也可能不同。

$ conan report diff --old-reference="mylib/1.0" --old-path="path/to/recipe" --new-reference="mylib/2.0" --new-path="path/to/recipe"

指定修订版

该命令允许您指定要比较的包的修订版。默认情况下,它使用最新的修订版,但通过提供修订版,您可以定位到要比较的精确包。这使得能够进行诸如比较两个具有不同修订版的相同版本以检查它们之间的差异之类的事情。

$ conan report diff --old-reference="mylib/1.0#oldrev" --new-reference="mylib/1.0#newrev"

可用格式化程序

文本格式化程序

默认情况下,它显示此格式,该格式是由 git diff 在包之间提供的格式。

JSON 格式化程序

您可以以 JSON 格式获取结果,提供结构化输出,非常适合其他脚本使用。

$ conan report diff --old-reference="mylib/1.0" --new-reference="mylib/2.0" --format=json

HTML 格式化程序

HTML 格式生成一个小的自包含静态网页,包含在一个 HTML 文件中。此页面允许您方便地可视化配方的更改以及库的源代码中的更改。它包含用于包含和排除关键字的过滤器以及指向所有更改文件的快捷方式。

$ conan report diff --old-reference="zlib/1.3" --new-reference="zlib/1.3.1" --format=html > diff.html
../../_images/conan-report-diff_html.png