Skip to content

Commit e2d8059

Browse files
AndreiIurkoavafanasiev
authored andcommitted
🐛 QD-13112 fix ignore of ignoreReturnCode option in git operations
1 parent 8d427a3 commit e2d8059

7 files changed

Lines changed: 19 additions & 5 deletions

File tree

gitlab/dist/qodana-gitlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51859,7 +51859,7 @@ var require_utils5 = __commonJS({
5185951859
function gitOutput(args_1) {
5186051860
return __awaiter2(this, arguments, void 0, function* (args, ignoreReturnCode = false) {
5186151861
const result = yield execAsync("git", args, true);
51862-
if (result.returnCode !== 0 && !ignoreReturnCode) {
51862+
if (result.returnCode !== 0 && ignoreReturnCode) {
5186351863
console.warn(`Git command failed: git ${args.join(" ")}
5186451864
Exit code: ${result.returnCode}
5186551865
Stdout: ${result.stdout}

gitlab/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async function gitOutput(
124124
ignoreReturnCode = false
125125
): Promise<CommandOutput> {
126126
const result = await execAsync('git', args, true)
127-
if (result.returnCode !== 0 && !ignoreReturnCode) {
127+
if (result.returnCode !== 0 && ignoreReturnCode) {
128128
console.warn(
129129
`Git command failed: git ${args.join(' ')}\nExit code: ${result.returnCode}\nStdout: ${result.stdout}\nStderr: ${result.stderr}`
130130
)

scan/dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135129,6 +135129,7 @@ var require_utils10 = __commonJS({
135129135129
if (output.exitCode === 0) {
135130135130
return output.stdout.trim();
135131135131
} else {
135132+
core2.warning("Qodana needs git history to extract merge-base. Please specify fetch-depth: 0 in your workflow.");
135132135133
return pr.base.sha;
135133135134
}
135134135135
}
@@ -135482,7 +135483,7 @@ ${comment_tag_pattern}`;
135482135483
return __awaiter3(this, arguments, void 0, function* (args, options = {}) {
135483135484
const originalIgnoreReturnCode = options.ignoreReturnCode;
135484135485
const result = yield exec.getExecOutput("git", args, Object.assign(Object.assign({}, options), { ignoreReturnCode: true }));
135485-
if (result.exitCode !== 0 && !originalIgnoreReturnCode) {
135486+
if (result.exitCode !== 0 && originalIgnoreReturnCode) {
135486135487
core2.warning(`Git command failed: git ${args.join(" ")}
135487135488
Exit code: ${result.exitCode}
135488135489
Stdout: ${result.stdout}

scan/src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ async function getPrSha(): Promise<string> {
121121
if (output.exitCode === 0) {
122122
return output.stdout.trim()
123123
} else {
124+
core.warning(
125+
'Qodana needs git history to extract merge-base. Please specify fetch-depth: 0 in your workflow.'
126+
)
124127
return pr.base.sha
125128
}
126129
}
@@ -660,7 +663,7 @@ async function gitOutput(
660663
...options,
661664
ignoreReturnCode: true
662665
})
663-
if (result.exitCode !== 0 && !originalIgnoreReturnCode) {
666+
if (result.exitCode !== 0 && originalIgnoreReturnCode) {
664667
core.warning(
665668
`Git command failed: git ${args.join(' ')}\nExit code: ${result.exitCode}\nStdout: ${result.stdout}\nStderr: ${result.stderr}`
666669
)

vsts/QodanaScan/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81361,6 +81361,11 @@ Stderr: ${result2.stderr}`);
8136181361
if (result2.stdout.startsWith("[command]")) {
8136281362
result2.stdout = result2.stdout.slice(result2.stdout.indexOf(" ") + 1).replace(args.join(" "), "").trim();
8136381363
}
81364+
if (result2.exitCode !== 0) {
81365+
tl2.warning(`Git command git ${args.join(" ")} failed:
81366+
Stdout: ${result2.stdout}
81367+
Stderr: ${result2.stderr}`);
81368+
}
8136481369
return result2;
8136581370
});
8136681371
}

vsts/src/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ async function gitOutput(
315315
.replace(args.join(' '), '')
316316
.trim()
317317
}
318+
if (result.exitCode !== 0) {
319+
tl.warning(
320+
`Git command git ${args.join(' ')} failed:\nStdout: ${result.stdout}\nStderr: ${result.stderr}`
321+
)
322+
}
318323
return result
319324
}
320325

vsts/vss-extension.dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1,
33
"id": "qodana-dev",
44
"name": "Qodana (Dev)",
5-
"version": "2025.2.334",
5+
"version": "2025.2.335",
66
"publisher": "JetBrains",
77
"targets": [
88
{

0 commit comments

Comments
 (0)