@sonar-autofix/core 0.0.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +11 -3
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -91,6 +91,12 @@ class CoreOrchestrator {
|
|
|
91
91
|
try {
|
|
92
92
|
// Step 1: Create a working branch
|
|
93
93
|
const branchName = this.config.git?.branch || 'sonar-autofix';
|
|
94
|
+
// Capture the base branch BEFORE switching to the working branch,
|
|
95
|
+
// so the PR targets the branch the CLI was actually running on
|
|
96
|
+
// (unless an explicit base branch is configured).
|
|
97
|
+
const baseBranch =
|
|
98
|
+
this.config.git?.baseBranch ||
|
|
99
|
+
(await this.gitClient.getCurrentBranch());
|
|
94
100
|
if (!this.dryRun) {
|
|
95
101
|
await this.gitClient.createBranch(branchName);
|
|
96
102
|
console.log(`✓ Created branch: ${branchName}`);
|
|
@@ -139,8 +145,9 @@ class CoreOrchestrator {
|
|
|
139
145
|
fixedInIteration++;
|
|
140
146
|
console.log(` ✓ ${filePath} fixed successfully`);
|
|
141
147
|
} else {
|
|
142
|
-
console.log(` ✗ ${filePath} could not be fixed
|
|
148
|
+
console.log(` ✗ ${filePath} could not be fixed`);
|
|
143
149
|
if (!this.dryRun && this.restoreOnFail) {
|
|
150
|
+
console.log(` ✗ ${filePath} could not be fixed — restoring original`);
|
|
144
151
|
await this.gitClient.restoreFile(filePath);
|
|
145
152
|
}
|
|
146
153
|
}
|
|
@@ -184,6 +191,7 @@ class CoreOrchestrator {
|
|
|
184
191
|
const prUrl = await this.gitClient.createPullRequest(
|
|
185
192
|
'fix(sonar): automatically resolve Sonar issues',
|
|
186
193
|
this.buildPRBody(totalFixed, iteration),
|
|
194
|
+
baseBranch,
|
|
187
195
|
);
|
|
188
196
|
console.log(`✓ Pull Request created: ${prUrl}`);
|
|
189
197
|
}
|
|
@@ -434,7 +442,7 @@ Return ONLY the complete fixed file content, wrapped in a code block.`;
|
|
|
434
442
|
* Build a descriptive PR body
|
|
435
443
|
*/
|
|
436
444
|
buildPRBody(totalFixed, iterations) {
|
|
437
|
-
return
|
|
445
|
+
return `Automated Sonar Issue Fixes
|
|
438
446
|
|
|
439
447
|
This PR was automatically generated by **sonar-autofix**.
|
|
440
448
|
|
|
@@ -455,7 +463,7 @@ This PR was automatically generated by **sonar-autofix**.
|
|
|
455
463
|
- Please review the changes carefully before merging.
|
|
456
464
|
|
|
457
465
|
---
|
|
458
|
-
*Generated by [sonar-autofix]
|
|
466
|
+
*Generated by [sonar-autofix]`;
|
|
459
467
|
}
|
|
460
468
|
|
|
461
469
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonar-autofix/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Core orchestrator for the Sonar Autofix tool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"author": "Sonar Autofix Team",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sonar-autofix/sonar-client": "^0.0
|
|
19
|
-
"@sonar-autofix/llm-client": "^0.0
|
|
20
|
-
"@sonar-autofix/git-client": "^0.0
|
|
18
|
+
"@sonar-autofix/sonar-client": "^0.2.0",
|
|
19
|
+
"@sonar-autofix/llm-client": "^0.2.0",
|
|
20
|
+
"@sonar-autofix/git-client": "^0.2.0"
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|