Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ check_git_configuration() {
"Set repository-local user.name and user.email before committing."
fi

sign_enabled="$(git_config commit.gpgsign)"
sign_enabled="$(git -C "${REPO_ROOT}" config --get --type=bool commit.gpgsign 2>/dev/null || true)"
if ! sign_format="$(git -C "${REPO_ROOT}" config --get gpg.format 2>/dev/null)"; then
sign_format="openpgp"
fi
Expand Down
44 changes: 43 additions & 1 deletion test/dev-setup-doctor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,18 @@ fi`,
if [ "\${FAKE_GIT_IDENTITY_MISSING:-}" = "1" ]; then exit 1; fi
echo "contributor@example.com"
;;
*" config --get --type=bool commit.gpgsign "*)
if [ "\${FAKE_GIT_SIGNING_MISSING:-}" = "1" ]; then exit 1; fi
if [ "\${FAKE_GIT_SIGNING_UNSET:-}" = "1" ]; then exit 1; fi
if [ "\${FAKE_GIT_SIGNING_INVALID:-}" = "1" ]; then
echo "fatal: bad boolean config value" >&2
exit 128
fi
echo "\${FAKE_GIT_SIGNING_BOOL-true}"
;;
*" config --get commit.gpgsign "*)
if [ "\${FAKE_GIT_SIGNING_MISSING:-}" = "1" ]; then exit 1; fi
echo "true"
echo "1"
;;
Comment thread
prekshivyas marked this conversation as resolved.
*" config --get gpg.format "*)
if [ "\${FAKE_GIT_SIGN_FORMAT_UNSET:-}" = "1" ]; then exit 1; fi
Expand Down Expand Up @@ -444,6 +453,39 @@ describe("contributor environment doctor", () => {
expect(result.output).toContain("Git pre-push hook is missing");
});

it.each([
["disabled", { FAKE_GIT_SIGNING_BOOL: "false" }],
["unset", { FAKE_GIT_SIGNING_UNSET: "1" }],
["invalid", { FAKE_GIT_SIGNING_INVALID: "1" }],
])("rejects %s commit signing", (_scenario, env) => {
const fixture = createFixture();

const result = runDoctor(fixture, env);

expect(result.status).toBe(1);
expect(result.output).toContain("Git commit signing is incomplete");
expect(result.output).not.toContain("Git commit signing configured");
expect(result.output).not.toContain("Ready to create a feature branch.");
});

it.each([
["true", "commit.gpgsign=true"],
["yes", "commit.gpgsign=yes"],
["on", "commit.gpgsign=on"],
["1", "commit.gpgsign=1"],
["uppercase", "commit.gpgsign=TRUE"],
["valueless", "commit.gpgsign"],
])("lets Git normalize the %s commit-signing spelling", (_scenario, configArg) => {
const result = spawnSync(
"git",
["-c", configArg, "config", "--get", "--type=bool", "commit.gpgsign"],
{ encoding: "utf-8" },
);

expect(result.status).toBe(0);
expect(result.stdout.trim()).toBe("true");
});

it("rejects an unsupported git signing format with a precise remediation", () => {
const fixture = createFixture();

Expand Down
Loading