Skip to content

Commit 0b6a6b2

Browse files
committed
⚡️ Don't retry when set allow_amend fails
1 parent 441ac60 commit 0b6a6b2

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/utils.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,23 @@ export async function getCommitMessage(
7272
// set allow-amend to true
7373
const cmd = `${gptcommit} config set --local allow_amend true`;
7474
channel.appendLine(`COMMAND: ${cmd}`);
75-
execSync(cmd, {cwd: repo.rootUri.fsPath});
76-
// try again
77-
getCommitMessage(config, repo, context, channel).then((msg) => {
78-
resolve(msg);
79-
}).catch((err) => {
80-
reject(err);
81-
});
75+
let setAmendSuccess = true;
76+
try {
77+
const setAmendOut = execSync(cmd, {cwd: repo.rootUri.fsPath}).toString();
78+
channel.appendLine(`STDOUT: ${setAmendOut}`);
79+
} catch (error) {
80+
setAmendSuccess = false;
81+
channel.appendLine(`ERROR: ${error}`);
82+
reject("Failed to set allow_amend to true");
83+
}
84+
if (setAmendSuccess) {
85+
// try again
86+
getCommitMessage(config, repo, context, channel).then((msg) => {
87+
resolve(msg);
88+
}).catch((err) => {
89+
reject(err);
90+
});
91+
}
8292
} else if (err || stderr) {
8393
if (config.debug) {
8494
channel.appendLine(`DEBUG: gptcommit failed with error: ${err} | ${stderr}`);

0 commit comments

Comments
 (0)