mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-27 15:20:34 +08:00
Port over all git relevant parts of the radicle-link repository[0]. The packages that are kept are: * git-ext * git-ref-format * git-trailers * link-git * macros * std-ext * test -- only the portions that test the above The development and testing scripts are also added for local and CI testing. [0]: https://github.com/radicle-dev/radicle-link/ Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
28 lines
791 B
Rust
28 lines
791 B
Rust
// Copyright © 2019-2020 The Radicle Foundation <hello@radicle.foundation>
|
|
//
|
|
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
|
|
// Linking Exception. For full terms see the included LICENSE file.
|
|
|
|
use git_ref_format::Qualified;
|
|
|
|
#[tracing::instrument(skip(repo))]
|
|
pub fn create_commit(
|
|
repo: &git2::Repository,
|
|
on_branch: Qualified,
|
|
) -> Result<git2::Oid, git2::Error> {
|
|
let empty_tree = {
|
|
let mut index = repo.index()?;
|
|
let oid = index.write_tree()?;
|
|
repo.find_tree(oid).unwrap()
|
|
};
|
|
let author = git2::Signature::now("The Animal", "animal@muppets.com").unwrap();
|
|
repo.commit(
|
|
Some(on_branch.as_str()),
|
|
&author,
|
|
&author,
|
|
"Initial commit",
|
|
&empty_tree,
|
|
&[],
|
|
)
|
|
}
|