diff options
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index f7e1ee0..8f9ff0d 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -66,9 +66,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 66 | None | 66 | None |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | let repo_ref = if let Some(repo_coordinates) = repo_coordinates { | 69 | let repo_ref = if let Some(repo_coordinates) = repo_coordinates.clone() { |
| 70 | fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; | 70 | fetching_with_report(git_repo_path, &client, &repo_coordinates).await?; |
| 71 | Some(get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?) | 71 | if let Ok(repo_ref) = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await { |
| 72 | Some(repo_ref) | ||
| 73 | } else { | ||
| 74 | None | ||
| 75 | } | ||
| 72 | } else { | 76 | } else { |
| 73 | None | 77 | None |
| 74 | }; | 78 | }; |
| @@ -95,6 +99,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 95 | .with_prompt("name") | 99 | .with_prompt("name") |
| 96 | .with_default(if let Some(repo_ref) = &repo_ref { | 100 | .with_default(if let Some(repo_ref) = &repo_ref { |
| 97 | repo_ref.name.clone() | 101 | repo_ref.name.clone() |
| 102 | } else if let Some(repo_coordinates) = repo_coordinates.clone() { | ||
| 103 | if let Some(coordinate) = repo_coordinates.iter().next() { | ||
| 104 | coordinate.identifier.clone() | ||
| 105 | } else { | ||
| 106 | String::new() | ||
| 107 | } | ||
| 98 | } else { | 108 | } else { |
| 99 | String::new() | 109 | String::new() |
| 100 | }), | 110 | }), |
| @@ -108,6 +118,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { | |||
| 108 | .with_prompt("identifier") | 118 | .with_prompt("identifier") |
| 109 | .with_default(if let Some(repo_ref) = &repo_ref { | 119 | .with_default(if let Some(repo_ref) = &repo_ref { |
| 110 | repo_ref.identifier.clone() | 120 | repo_ref.identifier.clone() |
| 121 | } else if let Some(repo_coordinates) = repo_coordinates.clone() { | ||
| 122 | if let Some(coordinate) = repo_coordinates.iter().next() { | ||
| 123 | coordinate.identifier.clone() | ||
| 124 | } else { | ||
| 125 | String::new() | ||
| 126 | } | ||
| 111 | } else { | 127 | } else { |
| 112 | let fallback = name | 128 | let fallback = name |
| 113 | .clone() | 129 | .clone() |