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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/stgit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand All @@ -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" },
Expand Down
Loading