Skip to content

Commit af0604e

Browse files
committed
fix: enhance Cursor and Qoder detection in SSH and DevContainer environments
This commit improves the detection logic for Cursor and Qoder IDEs by adding pattern matching for environment variables VSCODE_GIT_ASKPASS_MAIN and BROWSER that contain '.cursor-server' or '.qoder-server' substrings. This fixes issues where the IDE detection was not working properly in SSH and DevContainer environments. The changes include: 1. Added new environment variable patterns in envConfigs for Cursor and Qoder detection 2. Enhanced getCoDevelopedBy function to support substring pattern matching 3. Added comprehensive tests to verify the new detection logic This ensures that users working in remote development environments (SSH, DevContainer) will have proper Co-developed-by trailers added to their commits when using Cursor or Qoder. Change-Id: Ieb98755b1c0aa178b49484b2cdc613c11f90df39 Co-developed-by: Qoder <noreply@qoder.com>
1 parent dfb020b commit af0604e

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

src/commands/exec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ const envConfigs: [string, string][] = [
1919
['__CFBundleIdentifier=dev.kiro.desktop', 'Kiro <noreply@kiro.dev>'],
2020
['VSCODE_BRAND=Qoder', 'Qoder <noreply@qoder.com>'],
2121
['__CFBundleIdentifier=com.qoder.ide', 'Qoder <noreply@qoder.com>'], // Use this unstable variable until Qoder has a better one
22+
// Check env variables for IDEs in remove development environments
23+
['VSCODE_GIT_ASKPASS_MAIN=*.cursor-server*', 'Cursor <noreply@cursor.com>'],
24+
['BROWSER=*.cursor-server*', 'Cursor <noreply@cursor.com>'],
25+
['VSCODE_GIT_ASKPASS_MAIN=*.qoder-server*', 'Qoder <noreply@qoder.com>'],
26+
['BROWSER=*.qoder-server*', 'Qoder <noreply@qoder.com>'],
2227
];
2328

2429
/**
@@ -302,6 +307,21 @@ function getCoDevelopedBy(): string {
302307
// Continue to next configuration if value is falsy
303308
continue;
304309
}
310+
311+
// For pattern matching cases (starts and ends with *, e.g., "*.cursor-server*")
312+
if (
313+
expectedValue &&
314+
expectedValue.startsWith('*') &&
315+
expectedValue.endsWith('*') &&
316+
expectedValue.length > 2
317+
) {
318+
// Extract the pattern between the asterisks
319+
const pattern = expectedValue.substring(1, expectedValue.length - 1);
320+
if (actualValue.includes(pattern)) {
321+
return coDevelopedBy;
322+
}
323+
continue;
324+
}
305325
}
306326

307327
// Return empty string if none of the environment configurations match

test/commands/exec.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,33 @@ describe('exec command utilities', () => {
737737
process.env.CLAUDECODE = '';
738738
expect(getCoDevelopedBy()).toBe('');
739739
});
740+
741+
// Enhanced tests for Cursor and Qoder detection
742+
it('should return Cursor CoDevelopedBy when VSCODE_GIT_ASKPASS_MAIN contains .cursor-server', () => {
743+
clearCoDevelopedByEnvVars();
744+
process.env.VSCODE_GIT_ASKPASS_MAIN =
745+
'/home/user/.cursor-server/bin/askpass-main.js';
746+
expect(getCoDevelopedBy()).toBe('Cursor <noreply@cursor.com>');
747+
});
748+
749+
it('should return Cursor CoDevelopedBy when BROWSER contains .cursor-server', () => {
750+
clearCoDevelopedByEnvVars();
751+
process.env.BROWSER = '/home/user/.cursor-server/bin/helpers/browser.sh';
752+
expect(getCoDevelopedBy()).toBe('Cursor <noreply@cursor.com>');
753+
});
754+
755+
it('should return Qoder CoDevelopedBy when VSCODE_GIT_ASKPASS_MAIN contains .qoder-server', () => {
756+
clearCoDevelopedByEnvVars();
757+
process.env.VSCODE_GIT_ASKPASS_MAIN =
758+
'/home/user/.qoder-server/bin/askpass-main.js';
759+
expect(getCoDevelopedBy()).toBe('Qoder <noreply@qoder.com>');
760+
});
761+
762+
it('should return Qoder CoDevelopedBy when BROWSER contains .qoder-server', () => {
763+
clearCoDevelopedByEnvVars();
764+
process.env.BROWSER = '/home/user/.qoder-server/bin/helpers/browser.sh';
765+
expect(getCoDevelopedBy()).toBe('Qoder <noreply@qoder.com>');
766+
});
740767
});
741768

742769
describe('hasCoDevelopedBy', () => {

0 commit comments

Comments
 (0)