Skip to main content

worktree_io/issue/
impls.rs

1use super::IssueRef;
2
3impl IssueRef {
4    /// Directory name used inside the bare clone for this worktree.
5    #[must_use]
6    pub fn workspace_dir_name(&self) -> String {
7        match self {
8            Self::GitHub { number, .. } => format!("issue-{number}"),
9            Self::Linear { id, .. } => format!("linear-{id}"),
10            Self::AzureDevOps { id, .. } => format!("workitem-{id}"),
11            Self::Local { display_number, .. } => format!("issue-{display_number}"),
12        }
13    }
14
15    /// Git branch name for this issue worktree.
16    #[must_use]
17    pub fn branch_name(&self) -> String {
18        self.workspace_dir_name()
19    }
20
21    /// HTTPS clone URL for the repository.
22    ///
23    /// # Panics
24    ///
25    /// Always panics for `IssueRef::Local` — local repos are never cloned.
26    #[must_use]
27    pub fn clone_url(&self) -> String {
28        match self {
29            Self::GitHub { owner, repo, .. } | Self::Linear { owner, repo, .. } => {
30                format!("https://github.com/{owner}/{repo}.git")
31            }
32            Self::AzureDevOps {
33                org, project, repo, ..
34            } => {
35                format!("https://dev.azure.com/{org}/{project}/_git/{repo}")
36            }
37            Self::Local { .. } => {
38                unreachable!("clone_url is never called for IssueRef::Local")
39            }
40        }
41    }
42}