An open-source, faster Devin alternative
TypeScript
prepare-commit-msg: --no-divider, so a --- line in a message does not move the Session trailer
Igor Zalutski via Computerbb47439ca753
diff --git a/computer/hooks/knowledge/prepare-commit-msg b/computer/hooks/knowledge/prepare-commit-msgindex 0716f538..835d0e85 100755--- a/computer/hooks/knowledge/prepare-commit-msg+++ b/computer/hooks/knowledge/prepare-commit-msg@@ -17,5 +17,7 @@ msg=$1[ -n "$msg" ] && [ -f "$msg" ] || exit 0# Nothing written yet (an editor will open next): leave it, so an empty message still aborts the commit.[ -n "$(git stripspace --strip-comments <"$msg" 2>/dev/null)" ] || exit 0-git interpret-trailers --in-place --if-exists addIfDifferent --trailer "Session: $id" "$msg" >/dev/null 2>&1+# --no-divider: a `---` line in the message is text, not the start of a patch; the trailer goes at the+# end, where `git log` (and the Work index) read trailers.+git interpret-trailers --in-place --no-divider --if-exists addIfDifferent --trailer "Session: $id" "$msg" >/dev/null 2>&1exit 0diff --git a/computer/src/workspaces/knowledge-hooks.test.ts b/computer/src/workspaces/knowledge-hooks.test.tsindex cb39b308..3bb8dc03 100644--- a/computer/src/workspaces/knowledge-hooks.test.ts+++ b/computer/src/workspaces/knowledge-hooks.test.ts@@ -159,6 +159,15 @@ describe('prepare-commit-msg', () => {expect(git(session, ['log', '-1', '--format=%B'])).toBe('Track mine\n\nWith a body.\n\nSession: cs_s1');});+ it('puts the trailer at the end of a message with a --- line in it', () => {+ put(session, { 'docs/divider.md': 'x\n' });+ git(session, ['add', '-A']);+ git(session, ['commit', '-q', '-m', 'Divider\n\nAbove the line.\n---\nBelow the line.'], id);+ expect(git(session, ['log', '-1', '--format=%B'])).toBe('Divider\n\nAbove the line.\n---\nBelow the line.\n\nSession: cs_s1');+ expect(trailers(session)).toEqual(['cs_s1']);+ git(session, ['reset', '-q', '--hard', 'HEAD~1']);+ });+it('adds nothing without SP_SESSION_ID, or with one that is not an id', () => {put(session, { 'docs/x.md': 'x\n' });git(session, ['add', '-A']);