8000 Provide an example for signed commits · Issue #72 · gitext-rs/git2-ext · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Provide an example for signed commits #72
Open
@davinkevin

Description

@davinkevin

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 the commit function, which has to be of type Option<&dyn Sign>.

let signer = UserSign::from_config(&repo, &repo.config()?)
    .ok()
    .as_ref();

let new_oid = commit(
    &repo,
    &commit.author(),
    &commit.committer(),
    &message[..],
    &commit.tree()?,
    &[&repo.find_commit(parent_oid.unwrap_or(first_parent))?],
    signer
)?;

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0