mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 03:22:59 +00:00
c99c97c646
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
|
||
---|---|---|
.. | ||
common | ||
cli-reference@.md.snap | ||
runner.rs | ||
test_abandon_command.rs | ||
test_absorb_command.rs | ||
test_acls.rs | ||
test_advance_bookmarks.rs | ||
test_alias.rs | ||
test_backout_command.rs | ||
test_bookmark_command.rs | ||
test_builtin_aliases.rs | ||
test_commit_command.rs | ||
test_commit_template.rs | ||
test_completion.rs | ||
test_concurrent_operations.rs | ||
test_config_command.rs | ||
test_copy_detection.rs | ||
test_debug_command.rs | ||
test_describe_command.rs | ||
test_diff_command.rs | ||
test_diffedit_command.rs | ||
test_duplicate_command.rs | ||
test_edit_command.rs | ||
test_evolog_command.rs | ||
test_file_annotate_command.rs | ||
test_file_chmod_command.rs | ||
test_file_show_command.rs | ||
test_file_track_untrack_commands.rs | ||
test_fix_command.rs | ||
test_generate_md_cli_help.rs | ||
test_git_clone.rs | ||
test_git_colocated.rs | ||
test_git_fetch.rs | ||
test_git_import_export.rs | ||
test_git_init.rs | ||
test_git_private_commits.rs | ||
test_git_push.rs | ||
test_git_remotes.rs | ||
test_git_submodule.rs | ||
test_gitignores.rs | ||
test_global_opts.rs | ||
test_help_command.rs | ||
test_immutable_commits.rs | ||
test_init_command.rs | ||
test_interdiff_command.rs | ||
test_log_command.rs | ||
test_new_command.rs | ||
test_next_prev_commands.rs | ||
test_operations.rs | ||
test_parallelize_command.rs | ||
test_rebase_command.rs | ||
test_repo_change_report.rs | ||
test_resolve_command.rs | ||
test_restore_command.rs | ||
test_revset_output.rs | ||
test_root.rs | ||
test_shell_completion.rs | ||
test_show_command.rs | ||
test_simplify_parents_command.rs | ||
test_sparse_command.rs | ||
test_split_command.rs | ||
test_squash_command.rs | ||
test_status_command.rs | ||
test_tag_command.rs | ||
test_templater.rs | ||
test_undo.rs | ||
test_unsquash_command.rs | ||
test_util_command.rs | ||
test_working_copy.rs | ||
test_workspaces.rs |