diff --git a/.centy/issues/e8702478-704b-4ea0-90e0-9c7d3d86cdb3.md b/.centy/issues/e8702478-704b-4ea0-90e0-9c7d3d86cdb3.md index 37b11ef..8f1cdcf 100644 --- a/.centy/issues/e8702478-704b-4ea0-90e0-9c7d3d86cdb3.md +++ b/.centy/issues/e8702478-704b-4ea0-90e0-9c7d3d86cdb3.md @@ -4,7 +4,7 @@ displayNumber: 44 status: closed priority: 2 createdAt: 2026-03-06T23:31:38.608232+00:00 -updatedAt: 2026-03-18T12:15:35.630876+00:00 +updatedAt: 2026-03-21T19:32:58.060883+00:00 --- # Open worktree by owner/name with random branch name diff --git a/src/issue/parse/dispatch.rs b/src/issue/parse/dispatch.rs deleted file mode 100644 index b7b8d5b..0000000 --- a/src/issue/parse/dispatch.rs +++ /dev/null @@ -1,93 +0,0 @@ -use anyhow::{bail, Result}; - -use crate::issue::{DeepLinkOptions, IssueRef}; - -impl IssueRef { - /// Parse any of the supported input formats: - /// - `https://github.com/owner/repo/issues/42` - /// - `worktree://open?owner=X&repo=Y&issue=42` - /// - `worktree://open?url=` - /// - `worktree://open?owner=X&repo=Y&linear_id=` - /// - `owner/repo#42` - /// - `owner/repo@` - /// - `centy:` (context-aware: finds nearest `.centy/` ancestor) - /// - `gh:` (context-aware: resolves against the `origin` GitHub remote) - /// - /// # Errors - /// - /// Returns an error if `s` does not match any supported format or if the - /// extracted values (e.g. issue number) are invalid. - pub fn parse(s: &str) -> Result { - let s = s.trim(); - - if s.starts_with("worktree://") { - let (issue, _opts) = super::worktree_url::parse_worktree_url(s)?; - return Ok(issue); - } - - if s.starts_with("https://github.com") || s.starts_with("http://github.com") { - return super::github::parse_github_url(s); - } - - if s.starts_with("https://dev.azure.com") || s.starts_with("http://dev.azure.com") { - return super::azure::parse_azure_devops_url(s); - } - - if s.starts_with("https://gitlab.com") || s.starts_with("http://gitlab.com") { - return super::gitlab::parse_gitlab_url(s); - } - - if s.contains(".atlassian.net/browse/") { - return super::jira::parse_jira_browse_url(s); - } - - if s.starts_with("centy:") { - return super::centy::parse_centy(s); - } - - if s.starts_with("gh:") { - return super::gh::parse_gh(s); - } - - if s.starts_with("gl:") { - return super::gitlab::parse_gl(s); - } - - if let Some(result) = super::shorthand::try_parse_shorthand(s) { - return result; - } - - bail!( - "Could not parse issue reference: {s:?}\n\ - Supported formats:\n\ - - https://github.com/owner/repo/issues/42\n\ - - https://gitlab.com/owner/repo/-/issues/42\n\ - - https://dev.azure.com/org/project/_workitems/edit/42\n\ - - worktree://open?owner=owner&repo=repo&issue=42\n\ - - worktree://open?owner=owner&repo=repo&linear_id=\n\ - - worktree://open?org=org&project=project&repo=repo&work_item_id=42\n\ - - worktree://open?jira_host=host&jira_issue_key=PROJ-42&owner=owner&repo=repo\n\ - - worktree://open?gitlab_host=gitlab.com&owner=owner&repo=repo&issue=42\n\ - - owner/repo#42\n\ - - owner/repo@\n\ - - org/project/repo!42\n\ - - centy:\n\ - - gh:\n\ - - gl:" - ) - } - - /// Like [`parse`] but also returns any [`DeepLinkOptions`] embedded in a - /// `worktree://` URL (e.g. the `editor` query param). - /// - /// # Errors - /// - /// Returns an error if `s` cannot be parsed as a valid issue reference. - pub fn parse_with_options(s: &str) -> Result<(Self, DeepLinkOptions)> { - let s = s.trim(); - if s.starts_with("worktree://") { - return super::worktree_url::parse_worktree_url(s); - } - Ok((Self::parse(s)?, DeepLinkOptions::default())) - } -} diff --git a/src/issue/parse/params.rs b/src/issue/parse/params.rs deleted file mode 100644 index 9f1b6b6..0000000 --- a/src/issue/parse/params.rs +++ /dev/null @@ -1,17 +0,0 @@ -/// Query parameters accumulated while parsing a `worktree://` URL. -#[derive(Default)] -pub(super) struct UrlParams { - pub(super) owner: Option, - pub(super) repo: Option, - pub(super) issue_num: Option, - pub(super) linear_id: Option, - pub(super) url_param: Option, - pub(super) editor: Option, - pub(super) ado_org: Option, - pub(super) ado_project: Option, - pub(super) ado_repo: Option, - pub(super) ado_work_item_id: Option, - pub(super) jira_host: Option, - pub(super) jira_issue_key: Option, - pub(super) gitlab_host: Option, -}