Skip to content

Commit a9f0821

Browse files
committed
Enhance placeholder to show diffs from the merge base when comparing to the current branch
1 parent 776ecb9 commit a9f0821

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

packages/vscode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat (CWC)",
4-
"description": "Initialize your favorite chatbot, then apply the response with a single click",
5-
"version": "1.149.0",
4+
"description": "Connect your editor with 10+ chatbots",
5+
"version": "1.150.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "npm run compile",

packages/vscode/src/utils/replace-changes-placeholder/replace-changes-placeholder.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ export const replace_changes_placeholder = async (
3535
}
3636

3737
try {
38-
const diff = execSync(`git diff ${branch_name}`, {
38+
// Get current branch name
39+
const current_branch = execSync('git rev-parse --abbrev-ref HEAD', {
40+
cwd: target_folder.uri.fsPath
41+
}).toString().trim()
42+
43+
// If comparing to same branch, use merge-base to show changes since branch point
44+
const diff_command = current_branch == branch_name ? `git diff $(git merge-base HEAD origin/${branch_name})` : `git diff ${branch_name}`
45+
const diff = execSync(diff_command, {
3946
cwd: target_folder.uri.fsPath
4047
}).toString()
4148

@@ -74,7 +81,14 @@ export const replace_changes_placeholder = async (
7481
}
7582

7683
try {
77-
const diff = execSync(`git diff ${branch_name}`, {
84+
// Get current branch name
85+
const current_branch = execSync('git rev-parse --abbrev-ref HEAD', {
86+
cwd: repository.rootUri.fsPath
87+
}).toString().trim()
88+
89+
// If comparing to same branch, use merge-base to show changes since branch point
90+
const diff_command = current_branch == branch_name ? `git diff $(git merge-base HEAD origin/${branch_name})` : `git diff ${branch_name}`
91+
const diff = execSync(diff_command, {
7892
cwd: repository.rootUri.fsPath
7993
}).toString()
8094

0 commit comments

Comments
 (0)