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

Method init_chain

src/git_chain/core.rs:187–223  ·  view source on GitHub ↗
(
        &self,
        chain_name: &str,
        root_branch: &str,
        branch_name: &str,
        sort_option: SortBranch,
    )

Source from the content-addressed store, hash-verified

185 }
186
187 pub fn init_chain(
188 &self,
189 chain_name: &str,
190 root_branch: &str,
191 branch_name: &str,
192 sort_option: SortBranch,
193 ) -> Result<(), Error> {
194 let results = Branch::get_branch_with_chain(self, branch_name)?;
195
196 match results {
197 BranchSearchResult::NotPartOfAnyChain => {
198 Branch::setup_branch(self, chain_name, root_branch, branch_name, &sort_option)?;
199
200 match Branch::get_branch_with_chain(self, branch_name)? {
201 BranchSearchResult::NotPartOfAnyChain => {
202 eprintln!("Unable to set up chain for branch: {}", branch_name.bold());
203 process::exit(1);
204 }
205 BranchSearchResult::Branch(branch) => {
206 println!("🔗 Succesfully set up branch: {}", branch_name.bold());
207 println!();
208 branch.display_status(self, false)?;
209 }
210 };
211 }
212 BranchSearchResult::Branch(branch) => {
213 eprintln!("❌ Unable to initialize branch to a chain.",);
214 eprintln!();
215 eprintln!("Branch already part of a chain: {}", branch_name.bold());
216 eprintln!("It is part of the chain: {}", branch.chain_name.bold());
217 eprintln!("With root branch: {}", branch.root_branch.bold());
218 process::exit(1);
219 }
220 };
221
222 Ok(())
223 }
224
225 pub fn remove_branch_from_chain(&self, branch_name: String) -> Result<(), Error> {
226 let results = Branch::get_branch_with_chain(self, &branch_name)?;

Callers 1

runFunction · 0.80

Calls 1

display_statusMethod · 0.80

Tested by

no test coverage detected