Merge pull request #678 from olshevskiy87/display_git_status_conflicted

git-feature: display if a file is updated but unmerged (conflicted)
This commit is contained in:
Benjamin Sago 2020-10-08 22:10:33 +01:00 committed by GitHub
commit cba2070924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 0 deletions

View File

@ -281,6 +281,7 @@ fn working_tree_status(status: git2::Status) -> f::GitStatus {
s if s.contains(git2::Status::WT_RENAMED) => f::GitStatus::Renamed,
s if s.contains(git2::Status::WT_TYPECHANGE) => f::GitStatus::TypeChange,
s if s.contains(git2::Status::IGNORED) => f::GitStatus::Ignored,
s if s.contains(git2::Status::CONFLICTED) => f::GitStatus::Conflicted,
_ => f::GitStatus::NotModified,
}
}

View File

@ -201,6 +201,9 @@ pub enum GitStatus {
/// A file thats ignored (that matches a line in .gitignore)
Ignored,
/// A file that's updated but unmerged.
Conflicted,
}
/// A files complete Git status. Its possible to make changes to a file, add

View File

@ -27,6 +27,7 @@ impl f::GitStatus {
f::GitStatus::Renamed => colours.renamed().paint("R"),
f::GitStatus::TypeChange => colours.type_change().paint("T"),
f::GitStatus::Ignored => colours.ignored().paint("I"),
f::GitStatus::Conflicted => colours.conflicted().paint("U"),
}
}
}
@ -40,6 +41,7 @@ pub trait Colours {
fn renamed(&self) -> Style;
fn type_change(&self) -> Style;
fn ignored(&self) -> Style;
fn conflicted(&self) -> Style;
}
@ -63,6 +65,7 @@ pub mod test {
fn renamed(&self) -> Style { Fixed(94).normal() }
fn type_change(&self) -> Style { Fixed(95).normal() }
fn ignored(&self) -> Style { Fixed(96).normal() }
fn conflicted(&self) -> Style { Fixed(93).normal() }
}

View File

@ -104,6 +104,7 @@ pub struct Git {
pub renamed: Style,
pub typechange: Style,
pub ignored: Style,
pub conflicted: Style,
}
impl Colours {
@ -168,6 +169,7 @@ impl Colours {
renamed: Yellow.normal(),
typechange: Purple.normal(),
ignored: Style::default().dimmed(),
conflicted: Red.normal(),
},
punctuation: Fixed(244).normal(),
@ -394,6 +396,7 @@ impl render::GitColours for Colours {
fn renamed(&self) -> Style { self.git.renamed }
fn type_change(&self) -> Style { self.git.typechange }
fn ignored(&self) -> Style { self.git.ignored }
fn conflicted(&self) -> Style { self.git.conflicted }
}
impl render::GroupColours for Colours {