Kaynağa Gözat

Add SubdirGitRepoStatus variant to Columns (#730)

	modified:   src/output/table.rs
alpn 5 yıl önce
ebeveyn
işleme
22a1b29167
1 değiştirilmiş dosya ile 18 ekleme ve 0 silme
  1. 18 0
      src/output/table.rs

+ 18 - 0
src/output/table.rs

@@ -104,6 +104,10 @@ impl Columns {
             columns.push(Column::GitStatus);
         }
 
+        if self.subdir_git_repos {
+            columns.push(Column::SubdirGitRepoStatus);
+        }
+
         columns
     }
 }
@@ -121,6 +125,7 @@ pub enum Column {
     HardLinks,
     Inode,
     GitStatus,
+    SubdirGitRepoStatus,
     Octal,
 }
 
@@ -159,6 +164,7 @@ impl Column {
             Self::HardLinks     => "Links",
             Self::Inode         => "inode",
             Self::GitStatus     => "Git",
+            Self::SubdirGitRepoStatus => "Repo",
             Self::Octal         => "Octal",
         }
     }
@@ -401,6 +407,9 @@ impl<'a, 'f> Table<'a> {
             Column::GitStatus => {
                 self.git_status(file).render(self.theme)
             }
+            Column::SubdirGitRepoStatus => {
+                self.subdir_git_repo_status(file).render(self.theme)
+            }
             Column::Octal => {
                 self.octal_permissions(file).render(self.theme.ui.octal)
             }
@@ -428,6 +437,15 @@ impl<'a, 'f> Table<'a> {
             .unwrap_or_default()
     }
 
+    fn subdir_git_repo_status(&self, file: &File<'_>) -> f::SubdirGitRepo {
+        debug!("Getting subdir repo status for path {:?}", file.path);
+
+        if file.is_directory(){
+            return f::SubdirGitRepo::from_path(&file.path);
+        }
+        f::SubdirGitRepo {status : f::SubdirGitRepoStatus::NotDir}
+    }
+
     pub fn render(&self, row: Row) -> TextCell {
         let mut cell = TextCell::default();