Release notes summary - What our users need to know
Release notes summary - What our users need to know【免费下载链接】nushellA new type of shell项目地址: https://gitcode.com/GitHub_Trending/nu/nushellCool commandThis change adds a cool new feature. Heres how you use it:my-cool-command最终在 release notes 中会显示为 Cool command 标题下的段落。 ### 链接与引用 issue PR 描述中可使用 GitHub 的 linking keyword 自动关联 issue例如 - Fixes #xxxx - This PR should close #xxxx 也可以顺带 mention 相关的 issue、PR 或 discussion。 ## 本地检查toolkit check pr 及其底层命令 CI 会自动检查代码格式并运行测试。在提交 PR 之前可以在本地运行等价的检查。Nushell 仓库自带一套用 Nushell 脚本编写的开发工具链 [toolkit.nu](https://link.gitcode.com/i/56e31b4eae04fa551ac21fd03b51da45)模块入口为 [toolkit/mod.nu](https://link.gitcode.com/i/2a38c58f100343c3ede69c240041fe93)其设计目的正如模块注释所述为开发者在 PR 周期内提供统一接口完成1格式化源码、2用 Clippy 发现常见缺陷、3确认所有测试通过。 nushell use toolkit.nu # 也可以通过 env_change hook 自动激活 toolkit check pr从源码 toolkit/checks.nu 可以看到check pr实际按顺序执行四个阶段任一阶段失败即生成带状态的阶段报告fmt→clippy→test→test stdlib并固定 locale 环境变量以避免本地化差异影响测试export def check pr [ --fast # 使用 cargo-nextest 加速测试 --features: liststring # 指定要检查的 feature ] { # ... try { fmt --check --verbose } catch { return (report --fail-fmt) } try { clippy --features $features --verbose } catch { return (report --fail-clippy) } # ... try { test --workspace } catch { return (report --fail-test) } try { test stdlib } catch { return (report --fail-test-stdlib) } report --no-fail }各阶段也可以单独运行toolkit的每个子命令都有对应的底层 cargo 命令检查项toolkit 命令底层命令格式检查toolkit fmt --checkcargo fmt --all -- --check应用格式toolkit fmtcargo fmt --allClippytoolkit clippycargo clippy --workspace -- -D warnings -D clippy::unwrap_used全量测试toolkit testcargo test --workspace标准库测试toolkit test stdlibcargo run -- -c use toolkit.nu; toolkit test stdlibCONTRIBUTING.md 给出的原始命令清单在 cargo workspace 多 crate 结构下可能需要比你熟悉的单 crate 项目传递更多 flag构建并运行 Nushellcargo run运行 Clippycargo clippy --workspace -- -D warnings -D clippy::unwrap_used或use toolkit.nu clippy后执行clippy。注意 toolkit/checks.nu 中实际执行的命令比文档中更严格除-D warnings -D clippy::unwrap_used外还追加了-D clippy::unchecked_time_subtraction并且会排除nu_plugin_*单独处理插件单独跑一轮 Clippy测试代码中则不 deny unwrap。源码注释还提醒修改这些设置时须同步修改 CI 工作流配置运行全部测试cargo test --workspace或use toolkit.nu test后执行test--fast时改用cargo nextest run运行某个命令的测试cargo test --package nu-cli --test main -- commands::command_name_here检查格式cargo fmt --all -- --check应用格式cargo fmt --all安装 git hooks在 commit/push 前自动检查格式并跑 Clippyuse toolkit.nu setup-git-hooks setup-git-hooks该 hook 目前不支持 Windows对应实现见 toolkit/git-hooks.nu。如果本地检查全部通过而 CI 仍失败可以向核心团队求助。开发环境构建、测试与调试环境搭建Nushell 需要较新的 Rust 工具链及若干系统依赖以官方 Nu Book 的从源码构建章节为准。安装好依赖后构建方式与其他 Rust 项目一致git clone https://github.com/nushell/nushell cd nushell cargo build仓库根目录的 rust-toolchain.toml 声明了所使用的 Rust 工具链版本。结合 devdocs/rust_style.md 的说明Nushell 出于发行版打包考虑通常落后最新稳定版 Rust 约两个版本且禁止使用 nightly 特性。测试的组织方式CONTRIBUTING.md 建议为改动补充测试并主动考虑角落场景corner cases。仓库中测试分布在三处顶层 tests/ 目录集成测试含repl/、parsing/、shell/等子模块命令的 examples每个命令自带的示例会作为可执行测试运行各 crate 自身的测试如 crates/nu-protocol/tests/、crates/nu-std/tests/ 等。多数测试构建在nu-test-supportcrate 之上见 crates/nu-test-support/其中提供简单的run_test()与fail_test()辅助函数对于在 REPL 模式下运行 Nushell这类特殊场景仓库提供了所谓的 testbins 辅助可执行文件见 crates/testbins/。标准库nu-std的测试则是 Nushell 脚本位于 crates/nu-std/tests/通过toolkit test stdlib驱动执行——对应实现即 toolkit/checks.nu 中test stdlib对use crates/nu-std/testing.nu; testing run-tests --path crates/nu-std的调用。调试技巧开发阶段开启trace日志级别查看详细日志cargo run --release -- --log-level trace将 trace 日志重定向到文件再查看cargo run --release -- --log-level trace --log-target file open $($nu.temp-dir)/nu-($nu.pid).log【免费下载链接】nushellA new type of shell项目地址: https://gitcode.com/GitHub_Trending/nu/nushell创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考