1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::{io, path::PathBuf};

use displaydoc::Display;
use git2::{MergeAnalysis, MergePreference};
use thiserror::Error;

#[derive(Error, Debug, Display)]
/// Errors thrown by the Git task.
pub enum GitError {
    /// Failed to update git repo at '{path}'.
    GitUpdate { path: PathBuf },
    /// Failed to create directory '{path}'
    CreateDirError { path: PathBuf, source: io::Error },
    /// Must specify at least one remote.
    NoRemotes,
    /// Current branch is not valid UTF-8
    InvalidBranchError,
    /// Branch list error
    BranchError { source: git2::Error },
    /// No default head branch set, and couldn't calculate one.
    NoHeadSet,
    /// Remote name unset.
    RemoteNameMissing,
    /** Repo has uncommitted changes, refusing to update. Status:
     * {status}
     */
    UncommittedChanges { status: String },
    /// Fetch failed for remote '{remote}'.{extra_info}
    FetchFailed {
        remote: String,
        source: git2::Error,
        extra_info: String,
    },
    /// Couldn't find oid for branch '{branch_name}'.
    NoOidFound { branch_name: String },
    /// Couldn't convert oid '{oid}' into a commit.
    NoCommitFound { oid: String, source: git2::Error },
    /// Failed to merge {merge_rev} ({merge_ref}) into {branch}.
    Merge {
        branch: String,
        merge_ref: String,
        merge_rev: String,
    },
    /// Fast-forward merge failed. Analysis: {analysis:?}
    CannotFastForwardMerge {
        analysis: MergeAnalysis,
        preference: MergePreference,
    },
    /// Failed to find current git directory.
    NoGitDirFound,
}