diff options
author | nfnty <git@nfnty.se> | 2015-10-08 15:11:13 +0200 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2016-02-08 04:43:04 +0100 |
commit | 7485cd37f6f9f7addd482c33a50a224ded46d443 (patch) | |
tree | 2e8949a4f2c5468f66bea995cf3456fc070a3ff1 | |
parent | cb3654b6de9ead90e63c160b8bdf8ea1d485f95d (diff) | |
download | ranger-7485cd37f6f9f7addd482c33a50a224ded46d443.tar.gz |
VCS: Return all statuses (including ignored) from get_status_allfiles
-rw-r--r-- | ranger/ext/vcs/git.py | 14 | ||||
-rw-r--r-- | ranger/ext/vcs/vcs.py | 67 |
2 files changed, 25 insertions, 56 deletions
diff --git a/ranger/ext/vcs/git.py b/ranger/ext/vcs/git.py index 93150588..c97cc9e5 100644 --- a/ranger/ext/vcs/git.py +++ b/ranger/ext/vcs/git.py @@ -160,8 +160,8 @@ class Git(Vcs): """Returs a dict (path: status) for paths not in sync. Strips trailing '/' from dirs""" statuses = {} skip = False - for line in self._git(['status', '--porcelain', '-z'], catchout=True, bytes=True)\ - .decode('utf-8').split('\x00')[:-1]: + for line in self._git(['status', '--ignored', '--porcelain', '-z'], + catchout=True, bytes=True).decode('utf-8').split('\x00')[:-1]: if skip: skip = False continue @@ -170,16 +170,6 @@ class Git(Vcs): skip = True return statuses - def get_ignore_allfiles(self): - """Returns a set of all the ignored files in the repo. Strips trailing '/' from dirs.""" - return set( - os.path.normpath(p) - for p in self._git( - ['ls-files', '--others', '--ignored', '--exclude-standard', '-z'], - catchout=True, bytes=True - ).decode('utf-8').split('\x00')[:-1] - ) - def get_remote_status(self): """Checks the status of the repo regarding sync state with remote branch""" try: diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py index 6e092b4d..73ac68cc 100644 --- a/ranger/ext/vcs/vcs.py +++ b/ranger/ext/vcs/vcs.py @@ -41,13 +41,13 @@ class Vcs(object): vcsname = None # Possible status responses in order of importance - FILE_STATUS = ( + DIR_STATUS = ( 'conflict', 'untracked', 'deleted', 'changed', 'staged', - 'ignored', + # 'ignored', 'sync', 'none', 'unknown', @@ -144,30 +144,28 @@ class Vcs(object): def update(self, directoryobject): """Update repository""" + root = self if self.is_root else directoryobject.fm.get_directory(self.root).vcs + root.head = root.get_info(root.HEAD) + root.branch = root.get_branch() + root.remotestatus = root.get_remote_status() + root.status = root.get_status_allfiles() + if self.is_root: - self.head = self.get_info(self.HEAD) - self.branch = self.get_branch() - self.remotestatus = self.get_remote_status() - self.status = self.get_status_allfiles() - self.ignored = self.get_ignore_allfiles() directoryobject.vcspathstatus = self.get_root_status() else: - root = directoryobject.fm.get_directory(self.root) - self.head = root.vcs.head = root.vcs.get_info(root.vcs.HEAD) - self.branch = root.vcs.branch = root.vcs.get_branch() - self.status = root.vcs.status = root.vcs.get_status_allfiles() - self.ignored = root.vcs.ignored = root.vcs.get_ignore_allfiles() - directoryobject.vcspathstatus = root.vcs.get_path_status( + self.head = root.head + self.branch = root.branch + self.status = root.status + directoryobject.vcspathstatus = root.get_path_status( self.path, is_directory=True) def update_child(self, directoryobject): """After update() for subdirectories""" - root = directoryobject.fm.get_directory(self.root) - self.head = root.vcs.head - self.branch = root.vcs.branch - self.status = root.vcs.status - self.ignored = root.vcs.ignored - directoryobject.vcspathstatus = root.vcs.get_path_status( + root = directoryobject.fm.get_directory(self.root).vcs + self.head = root.head + self.branch = root.branch + self.status = root.status + directoryobject.vcspathstatus = root.get_path_status( self.path, is_directory=True) # Repo creation @@ -245,10 +243,8 @@ class Vcs(object): def get_root_status(self): """Returns the status of root""" - statuses = set( - status for path, status in self.status.items() - ) - for status in self.FILE_STATUS: + statuses = set(status for path, status in self.status.items()) + for status in self.DIR_STATUS: if status in statuses: return status return 'sync' @@ -260,30 +256,17 @@ class Vcs(object): # check if relpath or its parents has a status tmppath = relpath while tmppath: - if tmppath in self.ignored: - return 'ignored' - elif tmppath in self.status: + if tmppath in self.status: return self.status[tmppath] tmppath = os.path.dirname(tmppath) # check if path contains some file in status if is_directory: - statuses = set( - status for subpath, status in self.status.items() - if subpath.startswith(relpath + '/') - ) - for status in self.FILE_STATUS: + statuses = set(status for subpath, status in self.status.items() + if subpath.startswith(relpath + '/')) + for status in self.DIR_STATUS: if status in statuses: return status - - # check if all subpaths are ignored - for root, _, files in os.walk(path): - for filename in files: - if os.path.relpath(os.path.join(root, filename), self.root) \ - not in self.ignored: - return 'sync' - return 'ignored' - return 'sync' def get_status_allfiles(self): @@ -291,10 +274,6 @@ class Vcs(object): Paths are given relative to the root. Strips trailing '/' from dirs.""" raise NotImplementedError - def get_ignore_allfiles(self): - """Returns a set of all the ignored files in the repo. Strips trailing '/' from dirs.""" - raise NotImplementedError - def get_remote_status(self): """Checks the status of the entire repo""" raise NotImplementedError |