为nix构建工具从github预取源代码
项目描述
简介
此模块实现了一个Python函数和一个命令行工具,帮助您在使用fetchFromGitHub时从github获取源代码。
本程序可以在GNU公共许可证第3版条件下分发。请查阅LICENSE.txt以阅读许可证文本。
命令行示例
result/bin/nix-prefetch-github seppeljordan nix-prefetch-github
{ "owner": "seppeljordan", "repo": "nix-prefetch-github", "rev": "b89933bf5643c97f00c374b39af4f265eef83220", "hash": "sha256-8veCTba0fhHEUPLge58FfWlk6tnYfAL852AYXWLu4Ss=" }
可用命令
nix-prefetch-github
此命令从github存储库下载代码并将其放入本地nix存储库。它还打印出fetchFromGitHub的功能参数到标准输出。
usage: nix-prefetch-github [-h] [--fetch-submodules] [--no-fetch-submodules] [--leave-dot-git] [--no-leave-dot-git] [--deep-clone] [--no-deep-clone] [--verbose] [--quiet] [--nix] [--json] [--meta] [--version] [--rev REV] owner repo positional arguments: owner repo options: -h, --help show this help message and exit --fetch-submodules Include git submodules in the output derivation --no-fetch-submodules Don't include git submodules in output derivation --leave-dot-git Include .git folder in output derivation. Use this if you need repository data, e.g. current commit hash, for the build process. --no-leave-dot-git Don't include .git folder in output derivation. --deep-clone Include all of the repository history in the output derivation. This option implies --leave-dot-git. --no-deep-clone Don't include the repository history in the output derivation. --verbose, -v Print additional information about the programs execution. This is useful if you want to issue a bug report. --quiet, -q Print less information about the programs execution. --nix Output the results as valid nix code. --json Output the results in the JSON format --meta Output the results in JSON format where the arguments to fetchFromGitHub are located under the src key of the resulting json dictionary and meta information about the prefetched repository is located under the meta key of the output. --version show program's version number and exit --rev REV
nix-prefetch-github-directory
此命令检查当前工作目录,并尝试确定它是否是链接到github的git存储库的一部分。如果成功,程序将预取当前签出的提交,类似于nix-prefetch-github命令。
usage: .nix-prefetch-github-directory-wrapped [-h] [--fetch-submodules] [--no-fetch-submodules] [--leave-dot-git] [--no-leave-dot-git] [--deep-clone] [--no-deep-clone] [--verbose] [--quiet] [--nix] [--json] [--meta] [--version] [--directory DIRECTORY] [--remote REMOTE] options: -h, --help show this help message and exit --fetch-submodules Include git submodules in the output derivation --no-fetch-submodules Don't include git submodules in output derivation --leave-dot-git Include .git folder in output derivation. Use this if you need repository data, e.g. current commit hash, for the build process. --no-leave-dot-git Don't include .git folder in output derivation. --deep-clone Include all of the repository history in the output derivation. This option implies --leave-dot-git. --no-deep-clone Don't include the repository history in the output derivation. --verbose, -v Print additional information about the programs execution. This is useful if you want to issue a bug report. --quiet, -q Print less information about the programs execution. --nix Output the results as valid nix code. --json Output the results in the JSON format --meta Output the results in JSON format where the arguments to fetchFromGitHub are located under the src key of the resulting json dictionary and meta information about the prefetched repository is located under the meta key of the output. --version show program's version number and exit --directory DIRECTORY --remote REMOTE
nix-prefetch-github-latest-release
此命令获取指定存储库的最新版本的代码。
usage: nix-prefetch-github-latest-release [-h] [--fetch-submodules] [--no-fetch-submodules] [--leave-dot-git] [--no-leave-dot-git] [--deep-clone] [--no-deep-clone] [--verbose] [--quiet] [--nix] [--json] [--meta] [--version] owner repo positional arguments: owner repo options: -h, --help show this help message and exit --fetch-submodules Include git submodules in the output derivation --no-fetch-submodules Don't include git submodules in output derivation --leave-dot-git Include .git folder in output derivation. Use this if you need repository data, e.g. current commit hash, for the build process. --no-leave-dot-git Don't include .git folder in output derivation. --deep-clone Include all of the repository history in the output derivation. This option implies --leave-dot-git. --no-deep-clone Don't include the repository history in the output derivation. --verbose, -v Print additional information about the programs execution. This is useful if you want to issue a bug report. --quiet, -q Print less information about the programs execution. --nix Output the results as valid nix code. --json Output the results in the JSON format --meta Output the results in JSON format where the arguments to fetchFromGitHub are located under the src key of the resulting json dictionary and meta information about the prefetched repository is located under the meta key of the output. --version show program's version number and exit
开发环境
使用启用了flake支持的nix develop。没有nix flake支持的开发不受官方支持。通过pytest运行提供的测试。您可以通过变量DISABLED_TESTS控制要运行哪种类型的测试。
# Only run tests that don't hit network and don't use nix DISABLED_TESTS="network requires_nix_build" pytest
目前,与该环境变量相关的唯一有意义的值是network和requires_nix_build。
您可以使用./generate-dependency-graph程序可视个别Python模块的依赖关系图。
您可以通过以下方式生成测试覆盖率报告:
coverage run -m nix_prefetch_github.run_tests && coverage html
更改
版本 v7.1.0
添加 -q / --quiet 选项以降低日志输出级别
添加 --meta 选项以在输出中包含最新预取提交的提交时间戳
使用 =GITHUB_TOKEN= 环境变量的内容进行 GitHub API 认证
版本 v7.0.0
输出格式已更改。在之前的版本中,json 和 nix 输出包含了 sha256 字段。为便于区分,已将该字段移除,改为 hash 字段。该字段的值是一个 SRI 哈希值。
版本 v6.0.1
修复了 nix-prefetch-github-directory 的仓库检测错误
版本 v6.0.0
停止支持 python3.8
从 json 输出中删除 fetchFromGitHub 的默认参数(例如 leaveDotGit = false;, fetchSubmodule = false;, deepClone = false;)
版本 v5.2.2
增加错误消息的详细信息
版本 v5.2.1
修复了一个破坏了没有实验性 `nix-command` 功能的用户程序的错误
版本 v5.2.0
如果使用不安全的选项 –deep-clone 和 –leave-dot-git,将发出警告。
略微改进 –help 输出
简化详细日志输出
版本 v5.1.2
由于 nix-prefetch-git 中存在错误,因此使用旧的预取实现。请参阅 此 GitHub 问题
版本 v5.1.1
修复了破坏 nix-prefetch-github --version 的错误
版本 v5.1.0
当可能时,使用 nix-prefetch-git 和 nix-prefetch-url 来计算 sha256 求和。如果 nix-prefetch-* 不可用,应用程序将回退到旧的方法。
版本 v5.0.1
修复了哈希生成中的破坏性错误
版本 v5.0.0
移除除“核心”包之外的所有其他 Python 包的依赖项
允许用户通过 --verbosity 命令行选项控制调试输出
所有命令现在都理解 --fetch-submodules 和 --no-fetch-submodules 选项
命令现在理解 --leave-dot-git 和 --no-leave-dot-git 选项
命令现在理解 --deep-clone 和 --no-deep-clone
版本 v4.0.4
为更好的调试打印子进程的标准错误输出
版本 v4.0.3
生成的哈希值不再有 “sha256-” 前缀
jinja2 已不再是 nix-prefetch-github 的依赖项
版本 v4.0.2
包装发布版本,没有错误修复或新功能
版本 v4.0.1
修复了问题 #38
版本 v4.0
在调用 Python 程序时将获取子模块默认为。CLI 应不受此更改的影响。
从所有内部类中删除 fetch_submodules 的默认值。
实现 nix-prefetch-github-latest-release 命令
版本 v3.0
对内部模块结构进行了重大更改
引入了 nix-prefetch-github-directory 命令
代码仓库现在作为 nix flake 运作
版本 v2.4
添加了 --fetch-submodules 标志
修复了与 nix 2.4 的不兼容性
版本 v2.3.2
修复问题 #21, #22
nix-prefetch-github 现在接受完整的引用名称,例如 refs/heads/master,自从 2.3 版本以来一直存在问题 (#23)
v2.3.1
修复生成 nix 表达式中的错误
修复阻止使用 prefetch 命令定位标签的错误
改进在找不到修订版本时的错误信息格式
v2.3
删除对 requests 的依赖
默认使用 master 分支而不是列表中的第一个分支
v2.2
添加 --version 标志
修复输出格式化中的错误
v2.1
修复 (#4) 错误,使 nix-prefetch-github 与 nix 2.2 不兼容。
v2.0
nixpretchgithub 及其相应的命令行工具现在总是包含工具检测到的实际提交哈希值,而不是分支或标签名称。
添加新的标志 --nix,使命令行工具输出有效的 nix 表达式
删除 --hash-only 和 --no-hash-only 标志,并改为添加 --prefetch 和 --no-prefetch 标志来替换它们。
项目详情
nix-prefetch-github-7.1.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | ef63da34d1050d961c305a70863263d59f259020d3abef4e6e707800228f4001 |
|
MD5 | 6a124bc686e594f1e9d34ce240007c21 |
|
BLAKE2b-256 | 9c9073f7a3768f59a58c997593a4bb7fd2f2e778212ee273cd1e124c9a6130f6 |