spr icon indicating copy to clipboard operation
spr copied to clipboard

`spr diff` doesn't GPG sign commits.

Open sven-of-cord opened this issue 2 years ago • 6 comments

@joneshf reported this in #61

  • In fact, it will remove the GPG signature when it does whatever changes it does to update the commit.

sven-of-cord avatar Jun 13 '22 14:06 sven-of-cord

Yeah, this is a blocker for us because we require signed commits :(

jduan-highnote avatar Dec 01 '22 00:12 jduan-highnote

does this plan on getting addressed?

dukeofcool199 avatar Dec 13 '23 20:12 dukeofcool199

Same here!

balena-zh avatar Dec 22 '23 21:12 balena-zh

So sad, it's a really wonderful tool but no support for it is a deal breaker. Any way to bypass it?

davinkevin avatar Jun 13 '24 10:06 davinkevin

I managed to "fix" it using git2-ext dependency and some glue code (aka; copy-paste because I struggled to use the interface provided by the library).

I've tested the generated binary, and it was working successfully 🎉.

I've included in the git.rs file, the following function:

    pub fn commit(
        repo: &git2::Repository,
        author: &git2::Signature<'_>,
        committer: &git2::Signature<'_>,
        message: &str,
        tree: &git2::Tree<'_>,
        parents: &[&git2::Commit<'_>],
        sign: Option<impl Sign>,
    ) -> std::result::Result<Oid, git2::Error> {
        if let Some(sign) = sign {
            let content = repo.commit_create_buffer(author, committer, message, tree, parents)?;
            let content = std::str::from_utf8(&content).unwrap();
            let signed = sign.sign(content)?;
            repo.commit_signed(content, &signed, None)
        } else {
            repo.commit(None, author, committer, message, tree, parents)
        }
    }

And every repo.commit call has been replaced by this:

let new_oid = Self::commit(
  &repo,
  …
  UserSign::from_config(&repo, &repo.config()?).ok()
)?;

I've not been able to use the built-in commit function from git2-ext due to types incompatibility (see issue)

The complete modification is available in that branch

Without this issue, I think a PR would be trivial to do to improve the project.

davinkevin avatar Jun 19 '24 18:06 davinkevin