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

Method preliminary_checks

src/git_chain/operations.rs:325–373  ·  view source on GitHub ↗
(&self, chain_name: &str)

Source from the content-addressed store, hash-verified

323 Ok(())
324 }
325 pub fn preliminary_checks(&self, chain_name: &str) -> Result<(), Error> {
326 if !Chain::chain_exists(self, chain_name)? {
327 return Err(Error::from_str(&format!(
328 "Chain {} does not exist",
329 chain_name
330 )));
331 }
332
333 // invariant: chain_name chain exists
334 let chain = Chain::get_chain(self, chain_name)?;
335
336 // ensure root branch exists
337 if !self.git_branch_exists(&chain.root_branch)? {
338 return Err(Error::from_str(&format!(
339 "Root branch does not exist: {}",
340 chain.root_branch.bold()
341 )));
342 }
343
344 // ensure each branch exists
345 for branch in &chain.branches {
346 if !self.git_local_branch_exists(&branch.branch_name)? {
347 return Err(Error::from_str(&format!(
348 "Branch does not exist: {}",
349 branch.branch_name.bold()
350 )));
351 }
352 }
353
354 // ensure repository is in a clean state
355 match self.repo.state() {
356 RepositoryState::Clean => {
357 // safe to proceed
358 }
359 _ => {
360 return Err(Error::from_str(
361 "Repository needs to be in a clean state before merging.",
362 ));
363 }
364 }
365
366 if self.dirty_working_directory()? {
367 return Err(Error::from_str(
368 "You have uncommitted changes in your working directory.",
369 ));
370 }
371
372 Ok(())
373 }
374 pub fn pr(&self, chain_name: &str, draft: bool) -> Result<(), Error> {
375 check_gh_cli_installed()?;
376 if Chain::chain_exists(self, chain_name)? {

Callers 1

rebaseMethod · 0.80

Calls 3

git_branch_existsMethod · 0.80

Tested by

no test coverage detected