Skip to content

Commit bb38146

Browse files
committed
Fixes commit signing ignoring git.enableCommitSigning
`getSigningConfig` only checked the repo's `commit.gpgsign`, so users who enabled signing solely via VS Code's `git.enableCommitSigning` (without `commit.gpgsign`) were reported as signing-disabled, and GitLens-driven commits (e.g. the Commit Composer) wouldn't sign. Threads the host override through `GitServiceConfig.signing.enabled` and falls back to it when `commit.gpgsign` is unset/false (it can only enable signing, never force it off). Regression from the standalone-packages refactor.
1 parent 0560395 commit bb38146

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
4646
### Fixed
4747

4848
- Fixes opening the _Commit Graph_ in multi root workspace to the correct repo ([#5276](https://github.com/gitkraken/vscode-gitlens/issues/5276))
49+
- Fixes commit signing not being detected as enabled when only VS Code's `git.enableCommitSigning` setting is on (without `commit.gpgsign` set in Git config) — GitLens-driven commits (e.g. the _Commit Composer_) now sign in this case
4950
- Fixes the `gitlens.advanced.similarityThreshold` setting being ignored when computing Git status — rename detection in status, working changes (WIP), and stash file lists used Git's default threshold (50%) instead of the configured value
5051
- Fixes the `gitlens.advanced.similarityThreshold` setting being ignored when listing changed files for a diff — rename detection used Git's default threshold (50%) instead of the configured value
5152
- Fixes force push from the _Push_ command always using `--force-with-lease` (and `--force-if-includes`) and ignoring VS Code's `git.useForcePushWithLease` and `git.useForcePushIfIncludes` settings — the confirmation could offer a plain `--force` while GitLens still pushed with lease; it now honors the configured preference

packages/git-cli/src/providers/config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,10 @@ export class ConfigGitSubProvider implements GitConfigSubProvider {
433433
const sshProgram = configMap.get('gpg.ssh.program');
434434
const allowedSignersFile = configMap.get('gpg.ssh.allowedsignersfile');
435435

436-
// Check if git config has commit signing enabled
437-
const isEnabled = parseGitBoolean(enabledRaw);
438-
439-
// Note: To override commit signing, pass it via the host/caller.
440-
// The library no longer reads a config for this.
436+
// Check if git config has commit signing enabled, falling back to the host-level override
437+
// (e.g. VS Code's `git.enableCommitSigning`) when `commit.gpgsign` is unset/false. The host
438+
// override can only enable signing, never force it off.
439+
const isEnabled = parseGitBoolean(enabledRaw) || this.context.config?.signing?.enabled === true;
441440

442441
return {
443442
enabled: isEnabled,

packages/git/src/context.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ export interface GitServiceConfig {
9696
*/
9797
readonly useForceIfIncludes?: boolean;
9898
};
99+
100+
/** Commit-signing preferences. */
101+
readonly signing?: {
102+
/**
103+
* Host-level override for whether commit signing is enabled (e.g. VS Code's `git.enableCommitSigning`).
104+
* When `true`, signing is treated as enabled even if the repo's `commit.gpgsign` is unset/false. It never
105+
* forces signing off.
106+
*/
107+
readonly enabled?: boolean;
108+
};
99109
}
100110

101111
/** Git command types that can produce conflicts. */

src/git/gitProviderContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export function createGitProviderContext(container: Container): GitServiceContex
5656
useForceIfIncludes: configuration.getCore('git.useForcePushIfIncludes') ?? true,
5757
};
5858
},
59+
get signing() {
60+
return {
61+
enabled: configuration.getCore('git.enableCommitSigning'),
62+
};
63+
},
5964
};
6065

6166
return {

0 commit comments

Comments
 (0)