Builds a validated filter from raw optional argument strings.
(
branch: Option<&str>,
worktree: Option<&str>,
commit: Option<&str>,
)
| 225 | impl GitScopeFilter { |
| 226 | /// Builds a validated filter from raw optional argument strings. |
| 227 | pub fn from_args( |
| 228 | branch: Option<&str>, |
| 229 | worktree: Option<&str>, |
| 230 | commit: Option<&str>, |
| 231 | ) -> Result<Self, GitCorrelationError> { |
| 232 | let branch = branch |
| 233 | .map(str::trim) |
| 234 | .filter(|value| !value.is_empty()) |
| 235 | .map(str::to_string); |
| 236 | let worktree = worktree |
| 237 | .map(str::trim) |
| 238 | .filter(|value| !value.is_empty()) |
| 239 | .map(normalize_worktree); |
| 240 | let commit = match commit.map(str::trim).filter(|value| !value.is_empty()) { |
| 241 | Some(value) => Some(parse_commit_sha(value)?), |
| 242 | None => None, |
| 243 | }; |
| 244 | Ok(Self { |
| 245 | branch, |
| 246 | worktree, |
| 247 | commit, |
| 248 | }) |
| 249 | } |
| 250 | |
| 251 | pub const fn is_empty(&self) -> bool { |
| 252 | self.branch.is_none() && self.worktree.is_none() && self.commit.is_none() |
nothing calls this directly
no test coverage detected