diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e493f1..54bf60c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ repository. Changes up to that version are documented in its ## [Unreleased] +### Fixed + +- Pound symbols in commit titles aren't interpreted as comments anymore, and are rendered literally (instead of stripped). + ## [1.1.0] - 2026-09-30 ### Changed diff --git a/src/stgit.ts b/src/stgit.ts index cbe9d6e..520e907 100644 --- a/src/stgit.ts +++ b/src/stgit.ts @@ -229,14 +229,15 @@ export function formatCommitDescription(description: string, commitMessage: stri return hasBody ? `${description} […]` : description; } -class StGitPatch extends Patch { +export class StGitPatch extends Patch { static fromSeries(line: string, commitMessage: string, reader: RepoReader): Patch { const empty = line[0] === "0"; const kind = line[1] === "-" ? "-" : "+"; const symbol = line[1] as "+" | "-" | ">"; const sha = line.slice(3, 43); - const label = line.slice(44).split("#")[0].trim(); - const desc = (line.split("#")[1] ?? "").trim(); + const [name, ...description] = line.slice(44).split("#"); + const label = name.trim(); + const desc = description.join("#").trim(); const patch = new this(reader, formatCommitDescription(desc, commitMessage), label, kind, empty, symbol); patch.sha = sha; return patch; diff --git a/src/test/runTest.ts b/src/test/runTest.ts index 77ea852..2d610d1 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -20,7 +20,7 @@ async function main() { launchArgs: ["--disable-extensions"], }); } catch (err) { - console.error("Failed to run tests"); + console.error("Failed to run tests", err); process.exit(1); } } diff --git a/src/test/suite/extension.test.ts b/src/test/suite/extension.test.ts index 10b0526..5a39634 100644 --- a/src/test/suite/extension.test.ts +++ b/src/test/suite/extension.test.ts @@ -6,7 +6,7 @@ import * as vscode from "vscode"; import { findHunkTargetLine, HunkTarget } from "../../diff-mode"; import { RepoReader } from "../../repo-reader"; import { correspondingLine } from "../../stage-selection"; -import { formatCommitDescription, History, WorkTree } from "../../stgit"; +import { formatCommitDescription, History, StGitPatch, WorkTree } from "../../stgit"; suite("Extension Test Suite", () => { vscode.window.showInformationMessage("Start all tests."); @@ -21,6 +21,19 @@ suite("Extension Test Suite", () => { assert.strictEqual(formatCommitDescription("Title", "Title\n\n \n"), "Title"); }); + test("Preserves hashes in patch descriptions", () => { + const reader = new RepoReader( + { topLevelDir: "/repo" }, + { + run: async () => "", + runCommand: async () => ({ stdout: "", stderr: "", ecode: 0 }), + }, + ); + const subject = "Fix #123 and #456"; + const patch = StGitPatch.fromSeries(` > ${"a".repeat(40)} fix-bug # ${subject}`, `${subject}\n`, reader); + assert.strictEqual(patch.description, subject); + }); + test("Shows the work-tree expansion state in its header", async () => { const reader = new RepoReader( { topLevelDir: "/repo" },