diff options
Diffstat (limited to 'src/bin/ngit/sub_commands/init.rs')
| -rw-r--r-- | src/bin/ngit/sub_commands/init.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 2f34ecb..087fa14 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs | |||
| @@ -231,7 +231,10 @@ fn validate_hashtag(s: &str) -> Result<String> { | |||
| 231 | if trimmed.is_empty() { | 231 | if trimmed.is_empty() { |
| 232 | bail!("hashtag cannot be empty"); | 232 | bail!("hashtag cannot be empty"); |
| 233 | } | 233 | } |
| 234 | if !trimmed.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-') { | 234 | if !trimmed |
| 235 | .chars() | ||
| 236 | .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-') | ||
| 237 | { | ||
| 235 | bail!("hashtag can only contain lowercase letters (a-z), digits (0-9), and hyphens (-)"); | 238 | bail!("hashtag can only contain lowercase letters (a-z), digits (0-9), and hyphens (-)"); |
| 236 | } | 239 | } |
| 237 | if trimmed.starts_with('-') || trimmed.ends_with('-') { | 240 | if trimmed.starts_with('-') || trimmed.ends_with('-') { |
| @@ -246,15 +249,10 @@ fn validate_hashtag(s: &str) -> Result<String> { | |||
| 246 | /// Resolve the `hashtags` field from args or existing announcement. | 249 | /// Resolve the `hashtags` field from args or existing announcement. |
| 247 | fn resolve_hashtags(args_hashtag: &[String], state: &InitState) -> Result<Vec<String>> { | 250 | fn resolve_hashtags(args_hashtag: &[String], state: &InitState) -> Result<Vec<String>> { |
| 248 | if !args_hashtag.is_empty() { | 251 | if !args_hashtag.is_empty() { |
| 249 | return args_hashtag | 252 | return args_hashtag.iter().map(|h| validate_hashtag(h)).collect(); |
| 250 | .iter() | ||
| 251 | .map(|h| validate_hashtag(h)) | ||
| 252 | .collect(); | ||
| 253 | } | 253 | } |
| 254 | if let Some(rr) = state.repo_ref() { | 254 | if let Some(rr) = state.repo_ref() { |
| 255 | return Ok( | 255 | return Ok(latest_event_repo_ref(rr).map_or_else(|| rr.hashtags.clone(), |lr| lr.hashtags)); |
| 256 | latest_event_repo_ref(rr).map_or_else(|| rr.hashtags.clone(), |lr| lr.hashtags), | ||
| 257 | ); | ||
| 258 | } | 256 | } |
| 259 | Ok(vec![]) | 257 | Ok(vec![]) |
| 260 | } | 258 | } |