MCPcopy Index your code
hub / github.com/HairlessVillager/minecommit / commit

Method commit

minecommit/src/lib.rs:59–95  ·  view source on GitHub ↗
(
        self,
        parents: Vec<String>,
        message: &str,
        r#ref: Option<String>,
        author_name: Option<&str>,
        author_email: Option<&str>,
    )

Source from the content-addressed store, hash-verified

57 }
58
59 pub fn commit(
60 self,
61 parents: Vec<String>,
62 message: &str,
63 r#ref: Option<String>,
64 author_name: Option<&str>,
65 author_email: Option<&str>,
66 ) -> Result<Vec<String>> {
67 let save = LocalFsOdb::from_dir(self.save_dir.to_owned());
68 let mut git = if let Some(from) = parents.first() {
69 LocalGitOdb::from_commit(self.storage_dir.to_owned(), from.clone())
70 } else {
71 LocalGitOdb::new(self.storage_dir.to_owned())
72 }?;
73
74 let mut processed = HashSet::new();
75 for crafter in CrafterImpl::get_crafters(self.extra_patterns, self.ignore_patterns) {
76 processed.extend(crafter.flatten(&save, &mut git)?);
77 }
78
79 let unprocessed = save
80 .glob("**/*")?
81 .into_iter()
82 .filter(|item| !processed.contains(item))
83 .collect::<Vec<_>>();
84
85 let commit = git.commit(parents.as_slice(), message, author_name, author_email)?;
86
87 if let Some(r#ref) = r#ref {
88 let cmd = git_cmd(self.storage_dir.to_owned(), ["update-ref", &r#ref, &commit]);
89 exec(cmd, None).context("failed to run update-ref")?;
90 log::info!("{:?} -> {commit}", r#ref);
91 } else {
92 log::warn!("Dangling commit {commit}");
93 }
94 Ok(unprocessed)
95 }
96
97 pub fn checkout(self, commit: String) -> Result<()> {
98 let mut save = LocalFsOdb::from_dir(self.save_dir.to_owned());

Callers 2

perform_commitFunction · 0.45
mainFunction · 0.45

Calls 4

git_cmdFunction · 0.85
execFunction · 0.85
flattenMethod · 0.45
globMethod · 0.45

Tested by

no test coverage detected