Skip to content

feat: expose gitCoAuthor setting in settings.json and document it#1228

Merged
tanzhenxin merged 8 commits intoQwenLM:mainfrom
afarber:add-git-co-author
Dec 16, 2025
Merged

feat: expose gitCoAuthor setting in settings.json and document it#1228
tanzhenxin merged 8 commits intoQwenLM:mainfrom
afarber:add-git-co-author

Conversation

@afarber
Copy link
Copy Markdown
Contributor

@afarber afarber commented Dec 11, 2025

TLDR

Exposes the existing gitCoAuthor setting in settings.json so users can disable or customize the automatic Co-authored-by: trailer added to git commits.

Also fixes a bug, where the trailer was not being added when commands were prefixed with cd /path &&.

Dive Deeper

The gitCoAuthor feature automatically adds a Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> trailer to git commit messages made through Qwen Code. While the implementation existed in core (packages/core/src/tools/shell.ts), it was not exposed in the settings schema, meaning users had no way to disable or customize it.

This PR:

  • Adds git.gitCoAuthor to the settings schema with enabled, name, and email properties
  • Wires up the setting in the CLI config loader
  • Documents the setting in docs/cli/configuration.md
  • Fixes regex to detect git commit anywhere in command (not just at start)
  • Adds test cases for prefixed commands and multi-line commit messages

Bug Fix: The original regex /^git\s+commit/ required commands to START with "git commit", but Qwen often generates cd /path && git commit -m "...". Changed to /\bgit\s+commit\b/ to match anywhere.

Users can now disable it by adding to their ~/.qwen/settings.json:

  {
    "git": {
      "gitCoAuthor": {
        "enabled": false
      }
    }
  }

Reviewer Test Plan

  1. Build: npm run build
  2. Create a test repo:
mkdir -p /tmp/test-coauthor && cd /tmp/test-coauthor
git init && git config user.email "test@test.com" && git config user.name "Test"
echo "test" > test.txt && git add .
  1. Run qwen and ask it to commit the file
  2. Verify: git log -1 --format=%B | grep "Co-authored-by"
  3. To test disabling: add the config above, rebuild, and verify trailer is NOT added

Testing Matrix

🍏 🪟 🐧
npm run yes yes
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

None - this is a feature enhancement to expose existing functionality.

@xuewenjie123
Copy link
Copy Markdown
Collaborator

thanks for your contribution!
I followed the Reviewer Test Plan to test this PR on both Windows and macOS:
I set git.gitCoAuthor.enabled to true in ~/.qwen/settings.json, built and started Qwen from this branch using npm run build and npm run start, then used the Qwen CLI to modify code and make a commit.

However, on both platforms, the commit message still does NOT contain the Co-authored-by: Qwen-Coder qwen-coder@alibabacloud.com trailer.

I’ve confirmed that:

The config file exists at the correct path (~/.qwen/settings.json on macOS, %USERPROFILE%.qwen\settings.json on Windows)
The JSON structure is valid
The commit was triggered by the Qwen CLI (not a manual git commit)
Could it be that the co-author logic isn’t fully integrated into the CLI’s commit flow yet? Or is there a missing piece in config loading or trailer injection?

image image

@afarber
Copy link
Copy Markdown
Contributor Author

afarber commented Dec 12, 2025

Hi @xuewenjie123 thank you for the thorough testing and discovering the issue!

I have tried a commit (with a single line commit message) at my Ubuntu 25.04 computer by running these commands and the two Qwen prompts:

mkdir -p /tmp/test-coauthor
cd /tmp/test-coauthor
git init
git config user.email "test@test.com" 
git config user.name "Test"
echo "test" > test.txt
git add .

cd ~/src/qwen-code
npm ci
npm run build
npm run start

> Run "cd /tmp/test-coauthor && git status"
> Commit the text file

And I can confirm that the "Co-authored-by: ..." is indeed missing:

# cat ~/.qwen/settings.json 
{
  "security": {
    "auth": {
      "selectedType": "qwen-oauth"
    }
  },
  "$version": 2


# git log -1 --format=full
commit ac7ca59bd8a7977f667551e179b647ef5525797a (HEAD -> master)
Author: Test <test@test.com>
Commit: Test <test@test.com>

    Add test.txt file

Give me some time to investigate, then submit a fix and then I will ping you again.

@afarber
Copy link
Copy Markdown
Contributor Author

afarber commented Dec 12, 2025

Please update your git branch and try the tests again @xuewenjie123

The root cause have been that the "git commit" string is sometimes not at the beginning of that command string, but is rather prepended by "cd /some/folder &&" command.

I have fixed this and tested myself by issueing the Qwen prompt:

Go to the /tmp/test-coauthor folder, create another text file and then commit it

Here my Ubuntu 25.04 screenshot:

image

And then with the git log -1 --format=full command or better git log -1 --format=%B I can see that the line is now there:

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

@xuewenjie123
Copy link
Copy Markdown
Collaborator

Hi,
I just tried to reproduce the issue again on my end, and I'm still seeing the same behavior — the Co-authored-by: ... line is missing from the commit message. Let me know if you need any additional details from my side!
1765764196457_125CC529-BF3E-4871-8658-2B0E0342C179
1765764236951_3E836864-667F-4a47-851E-7269A75C106D

@tanzhenxin tanzhenxin self-requested a review December 15, 2025 09:45
@afarber
Copy link
Copy Markdown
Contributor Author

afarber commented Dec 15, 2025

Hi @xuewenjie123 thanks for testing, let's get this issue resolved!

I have improved the PR by making the code also accept the git calls like "git commit -am", but from your screenshot I see that this is not what you are using while testing, so this will not help here.

The new feature works for me on Ubuntu Linux and macOS Tahoe, but you are using Windows.

I have temporarily added more logs and you will be able to see them by pressing Ctrl+O in Qwen.

So please re-test by doing the following:

  1. Pull the latest changes on this git branch
  2. Issue the commands below:
mkdir -p /tmp/test-coauthor && cd /tmp/test-coauthor
git init && git config user.email "test@test.com" && git config user.name "Test"
echo "test" > test.txt && git add .
  1. Then go back to Qwen folder and issue "npm run build && npm run start"
  2. Submit the following Qwen prompt:
Run "git status" in /tmp/test-coauthor folder (yes, it is not the current folder) and then commit the new file
  1. Then use Ctrl+O and take screenshot of the new logs (see my screenshot below for comparison)
  2. Finally try "cd /tmp/test-coauthor && git log -1 --format=%B && cat ~/.qwen/settings.json" and copy-paste the output to me.

Below is the screenshot of my successful testing with macOS:

image
/tmp/test-coauthor (main) % git log -1 --format=%B 
Add test.txt file

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

/tmp/test-coauthor (main) % cat ~/.qwen/settings.json
{
  "security": {
    "auth": {
      "selectedType": "qwen-oauth"
    }
  },
  "$version": 2,
  "ui": {
    "theme": "GitHub Light"
  },
  "general": {
    "terminalBell": true
  }
}

@tanzhenxin tanzhenxin self-assigned this Dec 15, 2025
Copy link
Copy Markdown
Collaborator

@tanzhenxin tanzhenxin left a comment

Choose a reason for hiding this comment

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

LGTM!

@tanzhenxin tanzhenxin merged commit 850c52d into QwenLM:main Dec 16, 2025
14 checks passed
@afarber afarber deleted the add-git-co-author branch December 16, 2025 09:05
@afarber afarber mentioned this pull request Dec 23, 2025
@hypernewbie
Copy link
Copy Markdown

why is this default on? please default it off.

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.

4 participants