Owner decision D23: Lutra runs fetch, pull (merge or rebase per the new git.pull.mode setting), push (upstream set on the first push) and clone through the user's git. Any HTTPS or SSH server works; sign-in stays with git's credential helper (its own window is allowed for network calls only) and the ssh agent. Terminal prompts stay off, ext:: is refused, and URL userinfo is redacted in every message, progress line and remote listing. - vcs: Call::network with a 30 min timeout, a stderr progress sink and a Cancel flag that kills git's process group; remote.rs with clone_repo, fetch, pull, push (--porcelain rejections), remotes and add/set-url/ remove; explained refusals (rejected push, sign-in, host key, not found, unreachable, no upstream, local changes, conflicts). - engine: git.fetch/pull/push/clone/cancel/remotes/remoteAdd/remoteSetUrl/ remoteRemove, one network call at a time, gitProgress events, gitChanged after changes. - ui: status-bar progress with Cancel and ahead/behind, vcs.fetch/pull/ push/clone/manageRemotes (Git menu, no default shortcuts), Clone Repository and Manage Remotes dialogs; desktop pick_dir IPC. - Tests against local bare repositories only (vcs 8, engine 3, Vitest 11) plus unit and property tests; docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.2 KiB
Rust
69 lines
2.2 KiB
Rust
//! Errors of the Git backend.
|
|
|
|
/// Why a Git operation failed.
|
|
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
|
|
pub enum VcsError {
|
|
/// No usable `git` was found: the setting names a missing file, or
|
|
/// `git` is not on `PATH`.
|
|
#[error("git was not found ({0})")]
|
|
NotFound(String),
|
|
/// The installed git is older than [`crate::MIN_VERSION`].
|
|
#[error("git {found} is too old; Lutra needs git {min} or newer")]
|
|
TooOld {
|
|
/// The version that was found.
|
|
found: String,
|
|
/// The minimum version.
|
|
min: String,
|
|
},
|
|
/// `git` could not be started.
|
|
#[error("git could not be started: {0}")]
|
|
Spawn(String),
|
|
/// git did not finish within the timeout and was stopped.
|
|
#[error("git did not finish within {seconds} s and was stopped")]
|
|
Timeout {
|
|
/// The timeout in seconds.
|
|
seconds: u64,
|
|
},
|
|
/// git wrote more than the output cap.
|
|
#[error("git's output is larger than {limit} bytes")]
|
|
TooLarge {
|
|
/// The cap in bytes.
|
|
limit: usize,
|
|
},
|
|
/// git refused or failed; the message is git's own (capped).
|
|
#[error("{0}")]
|
|
Git(String),
|
|
/// git's output could not be understood.
|
|
#[error("unexpected output from git: {0}")]
|
|
BadOutput(String),
|
|
/// A path from the caller is empty, absolute, leaves the project or
|
|
/// holds a character git cannot take.
|
|
#[error("invalid path: {0}")]
|
|
InvalidPath(String),
|
|
/// A branch name or revision from the caller is not valid.
|
|
#[error("invalid branch name: {0}")]
|
|
InvalidName(String),
|
|
/// A commit message is empty.
|
|
#[error("the commit message is empty")]
|
|
EmptyMessage,
|
|
/// The call was cancelled and git was stopped.
|
|
#[error("the Git operation was cancelled")]
|
|
Cancelled,
|
|
/// A remote URL or clone target from the caller is not valid.
|
|
#[error("{0}")]
|
|
InvalidInput(String),
|
|
}
|
|
|
|
impl VcsError {
|
|
/// Whether the error is the caller's fault (bad path, name or message)
|
|
/// rather than a failure of git.
|
|
pub fn is_invalid_input(&self) -> bool {
|
|
matches!(
|
|
self,
|
|
Self::InvalidPath(_)
|
|
| Self::InvalidName(_)
|
|
| Self::EmptyMessage
|
|
| Self::InvalidInput(_)
|
|
)
|
|
}
|
|
}
|