spacedentist / spr

Submit pull requests for individual, amendable, rebaseable commits to GitHub
https://getcord.github.io/spr/
MIT License
378 stars 33 forks source link

`spr diff` doesn't GPG sign commits. #64

Open sven-of-cord opened 2 years ago

sven-of-cord commented 2 years ago

@joneshf reported this in #61

  • In fact, it will remove the GPG signature when it does whatever changes it does to update the commit.
jduan-highnote commented 1 year ago

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

dukeofcool199 commented 7 months ago

does this plan on getting addressed?

balena-zh commented 6 months ago

Same here!

davinkevin commented 1 month ago

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

davinkevin commented 3 weeks ago

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.