Skip to content

为commit命令实现-s参数的功能#1215

Merged
genedna merged 11 commits into
gitmono-dev:mainfrom
Flash0615:issue-1207-commit-s
Jul 12, 2025
Merged

为commit命令实现-s参数的功能#1215
genedna merged 11 commits into
gitmono-dev:mainfrom
Flash0615:issue-1207-commit-s

Conversation

@Flash0615

Copy link
Copy Markdown
Contributor

此 PR 完成了 r2cn 测试任务 #1207 ,为commit命令实现-s参数。

主要变更:

新增 -s/--signoff 选项,用于在提交信息中添加 Signed-off-by 签名;
签名信息自动读取 Git 配置中的 user.nameuser.email
签名将追加至提交消息末尾,并保持 Conventional Commits 规范的合规性;
test_parse_args() 中新增了 signoff 相关测试,覆盖以下场景:
-s--signoff 选项的解析;
--amend 等其他选项的兼容性;
CommitArgs 派生了 Default
新增对 UserConfig 的导入,用于读取用户信息。

影响范围:
完全向后兼容;
无新增依赖,仅使用现有配置系统。

该功能有助于满足 DCO 要求的项目使用场景。

@vercel

vercel Bot commented Jul 10, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 12, 2025 3:23pm

This comment was marked as outdated.

Signed-off-by: Haojun Xie <1678791451@qq.com>

This comment was marked as outdated.

@genedna

genedna commented Jul 11, 2025

Copy link
Copy Markdown
Collaborator

@Flash0615

新加入的参数在很多地方没有初始化,需要修复这个问题。

Signed-off-by: Haojun Xie <1678791451@qq.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new -s/--signoff flag to the commit command so users can automatically append a "Signed-off-by" line using their Git-configured name and email.

  • Introduces a signoff boolean flag in CommitArgs with a default of false.
  • Reads user.name and user.email from the existing config to format and append the signoff line.
  • Updates tests across commands to supply the new signoff field and adds parsing tests for the new flag.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
libra/tests/command/switch_test.rs Added signoff: false to existing CommitArgs in switch tests
libra/tests/command/commit_test.rs Added signoff: false and new parsing assertions for -s/--signoff
libra/tests/command/checkout_test.rs Added signoff: false to checkout command tests
libra/tests/command/branch_test.rs Added signoff: false to branch command tests
libra/src/command/commit.rs Imported UserConfig, derived Default, added signoff arg, and built commit_message with optional signoff
Comments suppressed due to low confidence (2)

libra/src/command/commit.rs:64

  • The format! macro won’t capture {user_name} and {user_email} without named parameters. Use either positional placeholders (format!("Signed-off-by: {} <{}>", user_name, user_email)) or provide named args (format!("Signed-off-by: {user_name} <{user_email}>", user_name=user_name, user_email=user_email)).
        let signoff_line = format!("Signed-off-by: {user_name} <{user_email}>");

if args.conventional && !check_conventional_commits_message(&args.message) {

//Prepare commit message
let commit_message = if args.signoff {

Copilot AI Jul 12, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You compute commit_message with the signoff, but later calls to format_commit_msg(&args.message, ...) still use args.message instead of commit_message. You need to pass commit_message into your commit creation functions so the signoff actually appears in the saved commit object.

Copilot uses AI. Check for mistakes.
@genedna

genedna commented Jul 12, 2025

Copy link
Copy Markdown
Collaborator

@genedna
genedna enabled auto-merge July 12, 2025 16:12
@genedna
genedna added this pull request to the merge queue Jul 12, 2025
Merged via the queue into gitmono-dev:main with commit e0bad33 Jul 12, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants