jj/docs
Anton Bulakh c99c97c646 sign: Add templater methods to show signature info
Disclaimer: this is the work of @necauqua and @julienvincent (see
#3141). I simply materialized the changes by rebasing them on latest
`main` and making the necessary adjustments to pass CI.

---

I had to fix an issue in `TestSignatureBackend::sign()`.

The following test was failing:
```
---- test_signature_templates::test_signature_templates stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: signature_templates
Source: cli/tests/test_signature_templates.rs:28
────────────────────────────────────────────────────────────────────────────────
Expression: stdout
────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────
    0     0 │ @  Commit ID: 05ac066d05701071af20e77506a0f2195194cbc9
    1     1 │ │  Change ID: qpvuntsmwlqtpsluzzsnyyzlmlwvmlnu
    2     2 │ │  Author: Test User <test.user@example.com> (2001-02-03 08:05:07)
    3     3 │ │  Committer: Test User <test.user@example.com> (2001-02-03 08:05:07)
    4       │-│  Signature: Good test signature
          4 │+│  Signature: Bad test signature
    5     5 │ │
    6     6 │ │      (no description set)
    7     7 │ │
    8     8 │ ◆  Commit ID: 0000000000000000000000000000000000000000
────────────┴───────────────────────────────────────────────────────────────────
```

Print debugging revealed that the signature was bad, because of a
missing trailing `\n` in `TestSignatureBackend::sign()`.

```diff
diff --git a/lib/src/test_signing_backend.rs b/lib/src/test_signing_backend.rs
index d47fef1086..0ba249e358 100644
--- a/lib/src/test_signing_backend.rs
+++ b/lib/src/test_signing_backend.rs
@@ -59,6 +59,8 @@
         let key = (!key.is_empty()).then_some(std::str::from_utf8(key).unwrap().to_owned());

         let sig = self.sign(data, key.as_deref())?;
+        dbg!(&std::str::from_utf8(&signature).unwrap());
+        dbg!(&std::str::from_utf8(&sig).unwrap());
         if sig == signature {
             Ok(Verification::new(
                 SigStatus::Good,
```

```
[lib/src/test_signing_backend.rs:62:9] &std::str::from_utf8(&signature).unwrap() = \"--- JJ-TEST-SIGNATURE ---\\nKEY: \\n5300977ff3ecda4555bd86d383b070afac7b7459c07f762af918943975394a8261d244629e430c8554258904f16dd9c18d737f8969f2e7d849246db0d93cc004\\n\"
[lib/src/test_signing_backend.rs:63:9] &std::str::from_utf8(&sig).unwrap() = \"--- JJ-TEST-SIGNATURE ---\\nKEY: \\n5300977ff3ecda4555bd86d383b070afac7b7459c07f762af918943975394a8261d244629e430c8554258904f16dd9c18d737f8969f2e7d849246db0d93cc004\"
```

Thankfully, @yuja pointed out that libgit2 appends a trailing newline
(see bfb7613d5d).

Co-authored-by: necauqua <him@necauq.ua>
Co-authored-by: julienvincent <m@julienvincent.io>
2025-01-04 13:24:08 +01:00
..
design docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
governance docs: introduce temporary governance voting process 2024-09-12 15:19:46 -07:00
technical docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
bookmarks.md docs: Use "branch" consistently when talking about Git's branches 2025-01-03 10:54:00 -06:00
cli-reference.md docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
code-of-conduct.md
community_tools.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
config.md sign: Add templater methods to show signature info 2025-01-04 13:24:08 +01:00
config.toml
conflicts.md docs: explain long conflict markers 2024-12-25 20:34:40 -06:00
contributing.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
design_doc_blueprint.md docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
design_docs.md docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
FAQ.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
filesets.md
git-comparison.md docs: git blame comparison 2024-11-19 09:58:28 -08:00
git-compatibility.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
github.md docs: Git does not use bookmarks 2024-12-19 20:59:45 -08:00
glossary.md docs: try to clarify that changes are not a first-class concept 2024-11-16 14:20:37 -08:00
index.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
install-and-setup.md Add a paragraph on how to install jj completions into Powershell. 2025-01-02 10:52:55 -06:00
operation-log.md bookmarks: update some leftover uses of the word "branch" 2024-09-11 19:19:31 -07:00
related-work.md
revsets.md docs: fix typo in builtin_immutable_heads() description 2024-12-31 19:24:36 -06:00
roadmap.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
sapling-comparison.md
templates.md sign: Add templater methods to show signature info 2025-01-04 13:24:08 +01:00
testimonials.md docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
tutorial.md tutorial: fix conflict formatting issue 2024-11-25 16:47:59 -06:00
windows.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00
working-copy.md docs/cli: update URLs to from martinvonz user to jj-vcs org 2024-12-17 12:44:44 -08:00