Skip to content

Commit 93724ba

Browse files
committed
Fix exec.exec return value handling for git show command
- Correctly capture exit code from exec.exec with ignoreReturnCode - Remove unnecessary .catch() that was never triggered - This fixes CI tests to properly detect missing baseline schemas
1 parent b6b081e commit 93724ba

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

dist/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ async function getSchemaFromBranch(branch, schemaFile) {
166166
const tempFile = path.join(os.tmpdir(), `schema-${branch.replace(/\//g, "-")}-${Date.now()}.sql`);
167167
// Create empty file first to ensure it exists
168168
fs.writeFileSync(tempFile, "");
169-
let exitCode = 0;
170-
await exec.exec("git", ["show", `${branch}:${schemaFile}`], {
169+
const exitCode = await exec.exec("git", ["show", `${branch}:${schemaFile}`], {
171170
silent: true,
172171
ignoreReturnCode: true,
173172
listeners: {
@@ -179,8 +178,6 @@ async function getSchemaFromBranch(branch, schemaFile) {
179178
core.debug(`git show stderr: ${data.toString()}`);
180179
},
181180
},
182-
}).catch((error) => {
183-
exitCode = error.exitCode || 1;
184181
});
185182
if (exitCode !== 0) {
186183
// If the file doesn't exist in the base branch, return empty schema

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ async function getSchemaFromBranch(branch: string, schemaFile: string): Promise<
141141
// Create empty file first to ensure it exists
142142
fs.writeFileSync(tempFile, "");
143143

144-
let exitCode = 0;
145-
await exec.exec("git", ["show", `${branch}:${schemaFile}`], {
144+
const exitCode = await exec.exec("git", ["show", `${branch}:${schemaFile}`], {
146145
silent: true,
147146
ignoreReturnCode: true,
148147
listeners: {
@@ -154,8 +153,6 @@ async function getSchemaFromBranch(branch: string, schemaFile: string): Promise<
154153
core.debug(`git show stderr: ${data.toString()}`);
155154
},
156155
},
157-
}).catch((error) => {
158-
exitCode = error.exitCode || 1;
159156
});
160157

161158
if (exitCode !== 0) {

0 commit comments

Comments
 (0)