worktree_io/issue/
impls.rs1use super::IssueRef;
2
3impl IssueRef {
4 #[must_use]
6 pub fn workspace_dir_name(&self) -> String {
7 match self {
8 Self::GitHub { number, .. } | Self::GitLab { number, .. } => {
9 format!("issue-{number}")
10 }
11 Self::Adhoc { name, .. } => name.clone(),
12 Self::Linear { id, .. } => format!("linear-{id}"),
13 Self::AzureDevOps { id, .. } => format!("workitem-{id}"),
14 Self::Jira { issue_key, .. } => format!("jira-{}", issue_key.to_lowercase()),
15 Self::Local { display_number, .. } => format!("issue-{display_number}"),
16 }
17 }
18
19 #[must_use]
21 pub fn branch_name(&self) -> String {
22 self.workspace_dir_name()
23 }
24
25 #[must_use]
31 pub fn clone_url(&self) -> String {
32 match self {
33 Self::GitHub { owner, repo, .. }
34 | Self::Linear { owner, repo, .. }
35 | Self::Jira { owner, repo, .. }
36 | Self::Adhoc { owner, repo, .. } => {
37 format!("https://github.com/{owner}/{repo}.git")
38 }
39 Self::GitLab { owner, repo, .. } => {
40 format!("https://gitlab.com/{owner}/{repo}.git")
41 }
42 Self::AzureDevOps {
43 org, project, repo, ..
44 } => {
45 format!("https://dev.azure.com/{org}/{project}/_git/{repo}")
46 }
47 Self::Local { .. } => {
48 unreachable!("clone_url is never called for IssueRef::Local")
49 }
50 }
51 }
52
53 #[must_use]
62 pub fn multi_dir_name(&self) -> String {
63 match self {
64 Self::GitHub { repo, number, .. } | Self::GitLab { repo, number, .. } => {
65 format!("{repo}-{number}")
66 }
67 Self::Adhoc { repo, name, .. } => format!("{repo}-{name}"),
68 Self::Linear { repo, id, .. } => format!("{repo}-{id}"),
69 Self::AzureDevOps { repo, id, .. } => format!("{repo}-{id}"),
70 Self::Jira {
71 repo, issue_key, ..
72 } => {
73 format!("{repo}-{}", issue_key.to_lowercase())
74 }
75 Self::Local { .. } => {
76 unreachable!("multi_dir_name is not supported for IssueRef::Local")
77 }
78 }
79 }
80}