✨ git-status-all: ignore by file type (e.g. fuse.rclone)
This commit is contained in:
parent
d2315e857e
commit
3b21559014
1 changed files with 18 additions and 0 deletions
|
|
@ -12,9 +12,11 @@ import re
|
|||
import subprocess
|
||||
|
||||
import click
|
||||
import psutil
|
||||
|
||||
|
||||
# TODO config file (and defaults here)
|
||||
IGNORE_FS_TYPES = ['tmpfs', 'proc', 'sysfs', 'devpts', 'nfs', 'fuse.rclone']
|
||||
IGNORES = [
|
||||
r"\.sync",
|
||||
r"\.git/modules", # XXX check this again
|
||||
|
|
@ -23,8 +25,24 @@ IGNORES = [
|
|||
]
|
||||
|
||||
|
||||
mount_fs_map = {p.mountpoint: p.fstype for p in psutil.disk_partitions(all=True)}
|
||||
|
||||
|
||||
def get_fs_type(path):
|
||||
path = os.path.realpath(path)
|
||||
while path != '/':
|
||||
if path in mount_fs_map:
|
||||
return mount_fs_map[path]
|
||||
path = os.path.dirname(path)
|
||||
return mount_fs_map.get('/', 'unknown')
|
||||
|
||||
|
||||
def git_directories(startdir) -> Path:
|
||||
for dirpath, dirnames, _ in os.walk(startdir):
|
||||
fs_type = get_fs_type(dirpath)
|
||||
if fs_type in IGNORE_FS_TYPES:
|
||||
dirnames.clear()
|
||||
continue
|
||||
if any(re.search(ignore, dirpath) for ignore in IGNORES):
|
||||
continue
|
||||
if set(["info", "objects", "refs"]).issubset(set(dirnames)):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue