use std::path::PathBuf;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("not a git repository (or any parent up to mount point)")]
NotARepository,
#[error("rung not initialized in this repository - run `rung init` first")]
NotInitialized,
#[error("branch not found: {0}")]
BranchNotFound(String),
#[error("invalid branch name '{name}': {reason}")]
InvalidBranchName {
name: String,
reason: String,
},
#[error("branch '{0}' is not part of a rung stack")]
NotInStack(String),
#[error("cyclic dependency detected: {0}")]
CyclicDependency(String),
#[error("parent branch '{parent}' for '{branch}' no longer exists")]
OrphanedBranch { branch: String, parent: String },
#[error("conflict in {file} while syncing {branch}")]
ConflictDetected { branch: String, file: String },
#[error("rebase failed for branch '{0}': {1}")]
RebaseFailed(String, String),
#[error("no backup found - nothing to undo")]
NoBackupFound,
#[error("sync already in progress - run `rung sync --continue` or `rung sync --abort`")]
SyncInProgress,
#[error("sync failed: {0}")]
SyncFailed(String),
#[error("failed to parse {file}: {message}")]
StateParseError { file: PathBuf, message: String },
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("toml error: {0}")]
Toml(#[from] toml::de::Error),
#[error("git error: {0}")]
Git(#[from] rung_git::Error),
#[error("absorb error: {0}")]
Absorb(String),
}