Просмотр исходного кода

git-feature: display if a file is updated but unmerged (conflicted)

Dmitriy Olshevskiy 5 лет назад
Родитель
Сommit
45eade9a59
4 измененных файлов с 10 добавлено и 0 удалено
  1. 1 0
      src/fs/feature/git.rs
  2. 3 0
      src/fs/fields.rs
  3. 3 0
      src/output/render/git.rs
  4. 3 0
      src/style/colours.rs

+ 1 - 0
src/fs/feature/git.rs

@@ -282,6 +282,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_RENAMED)     => f::GitStatus::Renamed,
         s if s.contains(git2::Status::WT_TYPECHANGE)  => f::GitStatus::TypeChange,
         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::IGNORED)        => f::GitStatus::Ignored,
+        s if s.contains(git2::Status::CONFLICTED)     => f::GitStatus::Conflicted,
         _                                             => f::GitStatus::NotModified,
         _                                             => f::GitStatus::NotModified,
     }
     }
 }
 }

+ 3 - 0
src/fs/fields.rs

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

+ 3 - 0
src/output/render/git.rs

@@ -27,6 +27,7 @@ impl f::GitStatus {
             f::GitStatus::Renamed      => colours.renamed().paint("R"),
             f::GitStatus::Renamed      => colours.renamed().paint("R"),
             f::GitStatus::TypeChange   => colours.type_change().paint("T"),
             f::GitStatus::TypeChange   => colours.type_change().paint("T"),
             f::GitStatus::Ignored      => colours.ignored().paint("I"),
             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 renamed(&self) -> Style;
     fn type_change(&self) -> Style;
     fn type_change(&self) -> Style;
     fn ignored(&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 renamed(&self)      -> Style { Fixed(94).normal() }
         fn type_change(&self)  -> Style { Fixed(95).normal() }
         fn type_change(&self)  -> Style { Fixed(95).normal() }
         fn ignored(&self)      -> Style { Fixed(96).normal() }
         fn ignored(&self)      -> Style { Fixed(96).normal() }
+        fn conflicted(&self)   -> Style { Fixed(93).normal() }
     }
     }
 
 
 
 

+ 3 - 0
src/style/colours.rs

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