diff options
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 1695e4c..0894f41 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -364,34 +364,33 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 364 | args.web.clone() | 364 | args.web.clone() |
| 365 | }; | 365 | }; |
| 366 | 366 | ||
| 367 | let earliest_unique_commit = match &args.earliest_unique_commit { | 367 | let earliest_unique_commit = if let Some(t) = &args.earliest_unique_commit { |
| 368 | Some(t) => t.clone(), | 368 | t.clone() |
| 369 | None => { | 369 | } else { |
| 370 | let mut earliest_unique_commit = if let Some(repo_ref) = &repo_ref { | 370 | let mut earliest_unique_commit = if let Some(repo_ref) = &repo_ref { |
| 371 | repo_ref.root_commit.clone() | 371 | repo_ref.root_commit.clone() |
| 372 | } else { | 372 | } else { |
| 373 | root_commit.to_string() | 373 | root_commit.to_string() |
| 374 | }; | 374 | }; |
| 375 | println!( | 375 | println!( |
| 376 | "the earliest unique commit helps with discoverability. It defaults to the root commit. Only change this if your repo has completely forked off an has formed its own identity." | 376 | "the earliest unique commit helps with discoverability. It defaults to the root commit. Only change this if your repo has completely forked off an has formed its own identity." |
| 377 | ); | 377 | ); |
| 378 | loop { | 378 | loop { |
| 379 | earliest_unique_commit = Interactor::default().input( | 379 | earliest_unique_commit = Interactor::default().input( |
| 380 | PromptInputParms::default() | 380 | PromptInputParms::default() |
| 381 | .with_prompt("earliest unique commit (to help with discoverability)") | 381 | .with_prompt("earliest unique commit (to help with discoverability)") |
| 382 | .with_default(earliest_unique_commit.clone()), | 382 | .with_default(earliest_unique_commit.clone()), |
| 383 | )?; | 383 | )?; |
| 384 | if let Ok(exists) = git_repo.does_commit_exist(&earliest_unique_commit) { | 384 | if let Ok(exists) = git_repo.does_commit_exist(&earliest_unique_commit) { |
| 385 | if exists { | 385 | if exists { |
| 386 | break earliest_unique_commit; | 386 | break earliest_unique_commit; |
| 387 | } | ||
| 388 | println!("commit does not exist on current repository"); | ||
| 389 | } else { | ||
| 390 | println!("commit id not formatted correctly"); | ||
| 391 | } | ||
| 392 | if earliest_unique_commit.len().ne(&40) { | ||
| 393 | println!("commit id must be 40 characters long"); | ||
| 394 | } | 387 | } |
| 388 | println!("commit does not exist on current repository"); | ||
| 389 | } else { | ||
| 390 | println!("commit id not formatted correctly"); | ||
| 391 | } | ||
| 392 | if earliest_unique_commit.len().ne(&40) { | ||
| 393 | println!("commit id must be 40 characters long"); | ||
| 395 | } | 394 | } |
| 396 | } | 395 | } |
| 397 | }; | 396 | }; |