Open davinkevin opened 1 month ago
I do
self.sign.as_ref().map(|s| s as &dyn git2_ext::ops::Sign)
Would appreciate examples being added but likely not going to get to it myself for some time.
Thank you for the example @epage!
I solved my issue by doing this:
let signer = UserSign::from_config(&repo, &repo.config()?);
let sign = signer
.as_ref()
.map(|s| s as &dyn Sign)
.ok();
let oid = extCommit(
&repo,
&author,
&committer,
&message,
&tree,
&parent_refs[..],
sign,
)?;
The missing part was the first let
, which can't be inlined with the second one, because of the borrow checker (I'm kind of n00b in rust).
Hello 👋
Thank you for the project, it has been very helpful to understand how to do things with
git2-rs
.However, I struggled to use the function
commit
, especially for signed commits. I searched for example, but no example or test so far.My problem was related to transform the result of
UserSign::from_config(&repo, &repo.config()?)
into the expected parameter of thecommit
function, which has to be of typeOption<&dyn Sign>
.And with that, and many other tries, always a compiler error.
I found many things (example), but nothing trivial as the library is, so I prefer opening an issue in case of an error in the original code.
I just ask for a test or an example of this code.
Thank you!