up_rs/tasks/git/errors.rs
1//! Git errors.
2use camino::Utf8PathBuf;
3use displaydoc::Display;
4use git2::MergeAnalysis;
5use git2::MergePreference;
6use std::io;
7use thiserror::Error;
8
9#[allow(clippy::doc_markdown)]
10#[derive(Error, Debug, Display)]
11/// Errors thrown by the Git task.
12pub enum GitError {
13 /// Failed to update git repo at `{path}`.
14 GitUpdate {
15 /// The path we failed to update.
16 path: Utf8PathBuf,
17 },
18 /// Failed to create directory `{path}`
19 CreateDirError {
20 /// The path we failed to create.
21 path: Utf8PathBuf,
22 /// Source error.
23 source: io::Error,
24 },
25 /// Must specify at least one remote.
26 NoRemotes,
27 /// Current branch is not valid UTF-8
28 InvalidBranchError,
29 /// Branch list error
30 BranchError {
31 /// Source error.
32 source: git2::Error,
33 },
34 /// No default head branch set, and couldn't calculate one.
35 NoHeadSet,
36 /// Remote name unset.
37 RemoteNameMissing,
38 /// Couldn't find remote {name}
39 RemoteNotFound {
40 /// Remote name.
41 name: String,
42 /// Source error.
43 source: git2::Error,
44 },
45 /** Repo has uncommitted changes, refusing to update. Status:
46 * {status}
47 */
48 UncommittedChanges {
49 /// Git status of uncommitted changes.
50 status: String,
51 },
52 /// Fetch failed for remote `{remote}`.{extra_info}
53 FetchFailed {
54 /// Git remote name.
55 remote: String,
56 /// Source error.
57 source: git2::Error,
58 /// Extra info or hints about why fetch failed.
59 extra_info: String,
60 },
61 /// Couldn`t find oid for branch `{branch_name}`.
62 NoOidFound {
63 /// Git branch name.
64 branch_name: String,
65 },
66 /// Couldn`t convert oid `{oid}` into a commit.
67 NoCommitFound {
68 /// Reference name.
69 oid: String,
70 /// Source error.
71 source: git2::Error,
72 },
73 /// Failed to merge `{merge_rev}` (`{merge_ref}`) into `{branch}`.
74 Merge {
75 /// Git branch.
76 branch: String,
77 /// Reference we tried to merge.
78 merge_ref: String,
79 /// Git revisision we tried to merge.
80 merge_rev: String,
81 },
82 /// Fast-forward merge failed. Analysis: {analysis:?}
83 CannotFastForwardMerge {
84 /// Reason fast-forward merge failed.
85 analysis: MergeAnalysis,
86 /// Merge preference.
87 preference: MergePreference,
88 },
89 /// Failed to find current git directory.
90 NoGitDirFound,
91}