1use std::path::Path;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum GitError {
7 #[error("not a git repository: {0}")]
8 NotARepo(String),
9 #[error("git command failed: {0}")]
10 CommandFailed(String),
11 #[error("worktree error: {0}")]
12 WorktreeError(String),
13 #[error("IO error: {0}")]
14 Io(#[from] std::io::Error),
15}
16
17pub trait GitPort {
18 fn is_git_repo(&self, path: &Path) -> Result<bool, GitError>;
19 fn get_github_remote(&self, path: &Path) -> Result<Option<String>, GitError>;
20 fn create_worktree(
21 &self,
22 repo_path: &Path,
23 worktree_path: &Path,
24 branch: &str,
25 create_branch: bool,
26 ) -> Result<(), GitError>;
27 fn remove_worktree(&self, repo_path: &Path, worktree_path: &Path) -> Result<(), GitError>;
28 fn current_branch(&self, path: &Path) -> Result<String, GitError>;
29 fn get_pr_branch(&self, pr_url: &str) -> Result<String, GitError>;
30}