( maybe_config: Result<Config, AppError>, name: &str, git: Option<String>, after_workon: Option<String>, after_clone: Option<String>, override_path: Option<String>, )
| 106 | } |
| 107 | |
| 108 | pub fn update_entry( |
| 109 | maybe_config: Result<Config, AppError>, |
| 110 | name: &str, |
| 111 | git: Option<String>, |
| 112 | after_workon: Option<String>, |
| 113 | after_clone: Option<String>, |
| 114 | override_path: Option<String>, |
| 115 | ) -> Result<(), AppError> { |
| 116 | let config: Config = maybe_config?; |
| 117 | if name.starts_with("http") || name.starts_with("git@") { |
| 118 | Err(AppError::UserError(format!( |
| 119 | "{} looks like a repo URL and not like a project name, please fix", |
| 120 | name |
| 121 | ))) |
| 122 | } else if !config.projects.contains_key(name) { |
| 123 | Err(AppError::UserError(format!("Project key {} does not exists. Can not update.", name))) |
| 124 | } else { |
| 125 | let old_project_config: Project = config.projects.get(name).expect("Already checked in the if above").clone(); |
| 126 | config::write_project(&Project { |
| 127 | git: git.unwrap_or(old_project_config.git), |
| 128 | name: old_project_config.name, |
| 129 | after_clone: after_clone.or(old_project_config.after_clone), |
| 130 | after_workon: after_workon.or(old_project_config.after_workon), |
| 131 | override_path: override_path.or(old_project_config.override_path), |
| 132 | tags: old_project_config.tags, |
| 133 | bare: old_project_config.bare, |
| 134 | trusted: old_project_config.trusted, |
| 135 | additional_remotes: old_project_config.additional_remotes, |
| 136 | project_config_path: old_project_config.project_config_path, |
| 137 | })?; |
| 138 | Ok(()) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | pub fn ls(maybe_config: Result<Config, AppError>, tags: &BTreeSet<String>) -> Result<(), AppError> { |
| 143 | let config = maybe_config?; |
no test coverage detected