MCPcopy Create free account
hub / github.com/dashed/git-chain / prune

Method prune

src/chain.rs:337–354  ·  view source on GitHub ↗
(&self, git_chain: &GitChain, dry_run: bool)

Source from the content-addressed store, hash-verified

335 }
336
337 pub fn prune(&self, git_chain: &GitChain, dry_run: bool) -> Result<Vec<String>, Error> {
338 let mut pruned_branches = vec![];
339 for branch in self.branches.clone() {
340 // branch is an ancestor of the root branch if:
341 // - it is the root branch, or
342 // - the branch is a commit that occurs before the root branch.
343 if git_chain.is_ancestor(&branch.branch_name, &self.root_branch)? {
344 let branch_name = branch.branch_name.clone();
345
346 if !dry_run {
347 branch.remove_from_chain(git_chain)?;
348 }
349
350 pruned_branches.push(branch_name);
351 }
352 }
353 Ok(pruned_branches)
354 }
355
356 pub fn rename(self, git_chain: &GitChain, new_chain_name: &str) -> Result<(), Error> {
357 // invariant: new_chain_name chain does not exist

Callers 1

runFunction · 0.45

Calls 3

is_ancestorMethod · 0.80
remove_from_chainMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected