瀏覽代碼

Merge branch 'main' into Add-more-tests

MartinFillon 2 年之前
父節點
當前提交
2c1d37ec41
共有 6 個文件被更改,包括 53 次插入11 次删除
  1. 28 0
      .github/workflows/apt.yml
  2. 2 2
      .github/workflows/unit-tests.yml
  3. 13 0
      README.md
  4. 1 1
      src/fs/feature/git.rs
  5. 8 7
      src/fs/file.rs
  6. 1 1
      src/output/file_name.rs

+ 28 - 0
.github/workflows/apt.yml

@@ -0,0 +1,28 @@
+name: Apt Installation
+on:
+  schedule:
+    - cron: '0 0 * * *'
+  push:
+    branches: [ main ]
+    paths:
+      - 'deb.asc'
+      - '.github/workflows/apt.yml'
+  pull_request:
+    branches: [ main ]
+    paths:
+      - 'deb.asc'
+      - '.github/workflows/apt.yml'
+jobs:
+  apt_installation:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Install eza via apt repo
+        run: |
+          wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo tee /etc/apt/trusted.gpg.d/gierens.asc && \
+          echo "deb http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list && \
+          sudo apt update && \
+          sudo apt install -y eza
+      - name: Run eza
+        run: eza
+      - name: Open man page
+        run: man eza | cat

+ 2 - 2
.github/workflows/unit-tests.yml

@@ -4,14 +4,14 @@ on:
   push:
     branches: [ main ]
     paths:
-      - '.github/workflows/*'
+      - '.github/workflows/unit-tests.yml'
       - 'src/**'
       - 'Cargo.*'
       - build.rs
   pull_request:
     branches: [ main ]
     paths:
-      - '.github/workflows/*'
+      - '.github/workflows/unit-tests.yml'
       - 'src/**'
       - 'Cargo.*'
       - build.rs

+ 13 - 0
README.md

@@ -196,6 +196,19 @@ To install eza, run:
 sudo port install eza
 ```
 
+### Scoop (Windows)
+
+[![Windows package](https://repology.org/badge/version-for-repo/scoop/eza.svg)](https://repology.org/project/eza/versions)
+
+
+Eza is available from [Scoop](https://scoop.sh/#/apps?q=eza&id=a52070d25f94bbcc884f80bef53eb47ed1268198).
+
+To install eza, run:
+
+```shell
+scoop install eza
+```
+
 ---
 Click sections to expand.
 

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

@@ -332,7 +332,7 @@ fn reorient(path: &Path) -> PathBuf {
 
 #[cfg(windows)]
 fn reorient(path: &Path) -> PathBuf {
-    let unc_path = path.canonicalize().unwrap();
+    let unc_path = path.canonicalize().unwrap_or_else(|_| path.to_path_buf());
     // On Windows UNC path is returned. We need to strip the prefix for it to work.
     let normal_path = unc_path.as_os_str().to_str().unwrap().trim_start_matches("\\\\?\\");
     PathBuf::from(normal_path)

+ 8 - 7
src/fs/file.rs

@@ -83,7 +83,8 @@ pub struct File<'dir> {
     pub extended_attributes: Vec<Attribute>,
 
     /// The absolute value of this path, used to look up mount points.
-    pub absolute_path: PathBuf,}
+    pub absolute_path: Option<PathBuf>,
+}
 
 impl<'dir> File<'dir> {
     pub fn from_args<PD, FN>(path: PathBuf, parent_dir: PD, filename: FN, deref_links: bool) -> io::Result<File<'dir>>
@@ -98,7 +99,7 @@ impl<'dir> File<'dir> {
         let metadata   = std::fs::symlink_metadata(&path)?;
         let is_all_all = false;
         let extended_attributes = File::gather_extended_attributes(&path);
-        let absolute_path = std::fs::canonicalize(&path)?;
+        let absolute_path = std::fs::canonicalize(&path).ok();
 
         Ok(File { name, ext, path, metadata, parent_dir, is_all_all, deref_links, extended_attributes, absolute_path })
     }
@@ -112,7 +113,7 @@ impl<'dir> File<'dir> {
         let is_all_all = true;
         let parent_dir = Some(parent_dir);
         let extended_attributes = File::gather_extended_attributes(&path);
-        let absolute_path = std::fs::canonicalize(&path)?;
+        let absolute_path = std::fs::canonicalize(&path).ok();
 
         Ok(File { path, parent_dir, metadata, ext, name: ".".into(), is_all_all, deref_links: false, extended_attributes, absolute_path })
     }
@@ -125,7 +126,7 @@ impl<'dir> File<'dir> {
         let is_all_all = true;
         let parent_dir = Some(parent_dir);
         let extended_attributes = File::gather_extended_attributes(&path);
-        let absolute_path = std::fs::canonicalize(&path)?;
+        let absolute_path = std::fs::canonicalize(&path).ok();
 
         Ok(File { path, parent_dir, metadata, ext, name: "..".into(), is_all_all, deref_links: false, extended_attributes, absolute_path })
     }
@@ -253,7 +254,7 @@ impl<'dir> File<'dir> {
     /// Whether this file is a mount point
     pub fn is_mount_point(&self) -> bool {
         if cfg!(target_os = "linux") && self.is_directory() {
-            return ALL_MOUNTS.contains_key(&self.absolute_path);
+            return self.absolute_path.as_ref().is_some_and(|p|ALL_MOUNTS.contains_key(p));
         }
         false
     }
@@ -261,7 +262,7 @@ impl<'dir> File<'dir> {
     /// The filesystem device and type for a mount point
     pub fn mount_point_info(&self) -> Option<&MountedFs> {
         if cfg!(target_os = "linux") {
-            return ALL_MOUNTS.get(&self.absolute_path);
+            return self.absolute_path.as_ref().and_then(|p|ALL_MOUNTS.get(p));
         }
         None
     }
@@ -324,7 +325,7 @@ impl<'dir> File<'dir> {
                     is_all_all: false,
                     deref_links: self.deref_links,
                     extended_attributes,
-                    absolute_path
+                    absolute_path: Some(absolute_path)
                 };
                 FileTarget::Ok(Box::new(file))
             }

+ 1 - 1
src/output/file_name.rs

@@ -350,7 +350,7 @@ impl<'a, 'dir, C: Colours> FileName<'a, 'dir, C> {
 
         let mut display_hyperlink = false;
         if self.options.embed_hyperlinks == EmbedHyperlinks::On {
-            if let Some(abs_path) = self.file.path.canonicalize().unwrap().as_os_str().to_str() {
+            if let Some(abs_path) = self.file.absolute_path.as_ref().and_then(|p| p.as_os_str().to_str()) {
                 bits.insert(0, ANSIString::from(format!(
                     "{}file://{}{}{}",
                     HYPERLINK_START,