Git - add the ability to disable commit signing (#291822)

This commit is contained in:
Ladislau Szomoru
2026-01-30 20:45:00 +01:00
committed by GitHub
parent 17969fbf25
commit bae323865a
3 changed files with 14 additions and 5 deletions

View File

@@ -177,6 +177,11 @@ export interface CommitOptions {
all?: boolean | 'tracked';
amend?: boolean;
signoff?: boolean;
/**
* true - sign the commit
* false - do not sign the commit
* undefined - use the repository/global git config
*/
signCommit?: boolean;
empty?: boolean;
noVerify?: boolean;

View File

@@ -2306,7 +2306,6 @@ export class CommandCenter {
}
let enableSmartCommit = config.get<boolean>('enableSmartCommit') === true;
const enableCommitSigning = config.get<boolean>('enableCommitSigning') === true;
let noStagedChanges = repository.indexGroup.resourceStates.length === 0;
let noUnstagedChanges = repository.workingTreeGroup.resourceStates.length === 0;
@@ -2380,8 +2379,9 @@ export class CommandCenter {
}
}
// enable signing of commits if configured
opts.signCommit = enableCommitSigning;
// Enable signing of commits if the setting is enabled. If the setting is not enabled,
// we set the option to undefined so that we let git use the repository/global config.
opts.signCommit = config.get<boolean>('enableCommitSigning') === true ? true : undefined;
if (config.get<boolean>('alwaysSignOff')) {
opts.signoff = true;

View File

@@ -2073,8 +2073,12 @@ export class Repository {
args.push('--signoff');
}
if (opts.signCommit) {
args.push('-S');
if (opts.signCommit !== undefined) {
if (opts.signCommit) {
args.push('-S');
} else {
args.push('--no-gpg-sign');
}
}
if (opts.empty) {