-
Notifications
You must be signed in to change notification settings - Fork 69
此 PR 完成了 r2cn 测试任务 #177,列出分支时过滤出包含/不包含指定提交的分支 #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
此 PR 完成了 r2cn 测试任务 #177,列出分支时过滤出包含/不包含指定提交的分支 #190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR extends Libra’s branch command with Git-like branch filtering capabilities by adding --contains / --no-contains (aliases --with / --without), enabling listing branches based on commit reachability from each branch tip.
Changes:
- Add CLI flags and listing logic to filter local/remote branches by whether they contain specified commits.
- Introduce reusable filtering helpers (
filter_branches,commit_contains) and add an integration test covering key flag combinations. - Update multiple tests/call sites for the new
BranchArgsfields and the newlist_branchessignature; refresh README and Cargo.lock.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/command/branch.rs |
Adds --contains/--no-contains args, updates listing flow, and implements commit-reachability filtering. |
tests/command/branch_test.rs |
Adds a comprehensive integration test for the new branch filtering behavior. |
tests/command/checkout_test.rs |
Updates call site for the new list_branches(mode, contains, no_contains) signature. |
tests/command/reset_test.rs |
Extends BranchArgs construction with new contains/no_contains fields. |
tests/command/mod.rs |
Re-exports filter_branches for integration tests. |
tests/command/show_test.rs |
Minor CLI invocation refactor (args([...])). |
tests/command/remote_test.rs |
Minor string formatting simplification in branch lookup. |
tests/command/init_test.rs |
Simplifies error mapping using io::Error::other. |
tests/command/index_pack_test.rs |
Minor iterator/refactor improvements in parsing helpers and path reads. |
src/internal/ai/agent/chat.rs |
Simplifies test-side pattern matching for user message handling. |
README.md |
Marks --contains as supported in Libra in the compatibility table. |
Cargo.lock |
Large dependency lockfile refresh accompanying the change. |
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5be226ee8e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
…ranch` - implement `--contains` / `--no-contains` (aliases: `--with` / `--without`) - add unit tests - run fmt and clippy Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
…filter Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
…tains entry Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
… an error Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.
f751e07 to
49ea1c3
Compare
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
- Remove `default_value="true"` from `--list` flag - Replace panic with default branch listing behavior when no arguments provided - Aligns with Git behavior: `libra branch` now lists local branches by default Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
ac80407 to
d2a5e48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
…parsing Signed-off-by: chimes-of-freedom <yaoshunyu@whu.edu.cn>
|
@genedna 您好,GitHub 的自动检查似乎有问题, |
功能描述
参照 Git 为 libra 的
branch命令实现--contains/--no-contains(别名--with/--without)参数,可在列出分支时过滤出包含/不包含指定提交的分支。--contains指定的提交,要求过滤出其 tip commit 的祖先提交包含该提交的分支;--no-contians制定的提交,要求过滤出其 tip commit 的祖先提交不包含该提交的分支;--contains和--no-contians的情形,要求过滤出 至少满足一个--contains条件且满足所有--no-contains条件 的分支。实现方案
以下实现均在
src/command/branch.rs中定义。--contains和--no-contains参数。list_branches()函数签名,增加commits_contains和commits_no_contains参数,同步修改所有调用处代码。list_branches()中处理 本地分支和远程分支的部分,使之仅仅是得到local_branches和remote_branches两个Vec,并在函数末尾增加打印非空Vec的逻辑。commit_contains(),检查给定的branch是否包含给定commits中至少一个:遍历commits,对于每一个目标提交,对branch的 tip commit 进行 BFS 以确认branch是否包含目标提交,一旦找到一个目标提交被branch包含则返回true,否则返回false(包括commits为空时)。filter_branches()实现对给定branches的过滤:便利branches,对于每个branch调用 2 次commit_contains()分别检查是否包含--contains和--no-contains指定的一系列提交之一,进而判断是否保留该分支,最后通过retain()过滤branches。list_branches()得到local_branches和remote_branches后、打印分支集之前插入对filter_branches()的调用,对本地分支集和远程分支集分别进行过滤。测试方案
以下测试均在
tests/command/branch_test.rs::test_branch_contains_commit_filter()中定义。filter_branches()以便检查测试结果。测试结果
cargo clippy --all-targets --all-features -- -D warnings检查。cargo +nightly fmt --all --check检查。cargo test检查。cargo build/cargo buckal build/buck2 run //:libra成功。