feat(libra): 为 log 命令添加 --oneline 参数,实现单行简洁格式显示提交历史 #1227#1230
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
zh66778
commented
Jul 14, 2025
zh66778
force-pushed
the
libra-log-oneline
branch
from
July 14, 2025 17:23
329022f to
c5ac77d
Compare
Collaborator
|
@zh66778 , Clippy 检查还有错误: |
Collaborator
|
@zh66778 , |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new --oneline flag to the libra log command for displaying each commit on a single line with an abbreviated hash and the first line of its message.
- Introduces
onelineboolean inLogArgsand implements conditional formatting inexecute. - Adds
test_log_onelineto verify the one-line output logic. - Updates documentation to describe the new
--onelineoption.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| libra/src/command/log.rs | Added oneline flag and one-line formatting branch in execute |
| libra/tests/command/mod.rs | Imported LogArgs into the tests module |
| libra/tests/command/log_test.rs | Added test_log_oneline to cover the new oneline behavior |
| aria/contents/docs/libra/command/log/index.mdx | Documented the --oneline option in the CLI docs |
Comments suppressed due to low confidence (2)
libra/tests/command/log_test.rs:131
- [nitpick] Consider capturing and asserting the full oneline-formatted output by invoking the
executefunction and capturing stdout. This end-to-end check will ensure the new flag’s behavior (including newline and formatting) is validated.
async fn test_log_oneline() {
libra/src/command/log.rs:93
- The oneline branch builds the output without a trailing newline. On Unix this causes entries to run together; consider adding a newline (e.g., use
format!("{}\n", ...)or usewriteln!) to ensure each commit is printed on its own line.
format!("{} {}", short_hash.yellow(), msg)
zh66778
force-pushed
the
libra-log-oneline
branch
from
July 15, 2025 08:23
5292620 to
cc3887f
Compare
zh66778
force-pushed
the
libra-log-oneline
branch
from
July 15, 2025 08:32
cc3887f to
89c9c13
Compare
Collaborator
|
@zh66778 ,
|
zh66778
force-pushed
the
libra-log-oneline
branch
from
July 15, 2025 08:40
89c9c13 to
eff7a32
Compare
- Fix LogArgs import error in log_test.rs by adding proper import to mod.rs - Resolve clippy uninlined_format_args warnings across multiple files - Update format strings to use direct variable interpolation Fixes: gitmono-dev#1227 Signed-off-by: zh667 <linzhi66778@gmail.com>
zh66778
force-pushed
the
libra-log-oneline
branch
from
July 15, 2025 08:54
7352c85 to
3ca2931
Compare
genedna
approved these changes
Jul 15, 2025
liuyangjuncong20202570
pushed a commit
to liuyangjuncong20202570/mega
that referenced
this pull request
Jul 20, 2025
…-dev#1230) - Fix LogArgs import error in log_test.rs by adding proper import to mod.rs - Resolve clippy uninlined_format_args warnings across multiple files - Update format strings to use direct variable interpolation Fixes: gitmono-dev#1227 Signed-off-by: zh667 <linzhi66778@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
此 PR 完成了 r2cn 测试任务 #1277,为 libra log 命令添加 --oneline 参数
功能描述
为 libra log 命令实现 --oneline 参数,显示简化的单行提交历史格式,兼容 git log --oneline 行为。
实现方案
在 LogArgs 结构体中添加 oneline 布尔字段,使用 clap 的 #[clap(long)] 注解
在 execute 函数中实现条件格式化逻辑:
oneline 格式:7位短哈希(黄色)+ 提交消息首行
保持原有详细格式不变
兼容现有 -n/--number 参数,可组合使用
测试覆盖
添加 test_log_oneline 测试用例
验证短哈希长度为7个字符
确保提交消息解析正确
测试与 --number 参数的组合使用
文档更新
更新 aria/contents/docs/libra/command/log/index.mdx
添加 --oneline 参数说明和功能描述
相关Issue
Closes #1227