From f7a060afe6bb4c77819b30d91bd857491e16ad35 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 18 Aug 2016 04:04:45 -0400 Subject: [PATCH] Try to reduce open files for large directories (#32) --- gitup/update.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gitup/update.py b/gitup/update.py index 0b15431..64991eb 100644 --- a/gitup/update.py +++ b/gitup/update.py @@ -195,20 +195,20 @@ def _run_command(repo, command): def _dispatch_multi(base, paths, callback, *args): """Apply the callback to all git repos in the list of paths.""" - repos = [] + valid = [] for path in paths: try: - repo = Repo(path) + Repo(path) except (exc.InvalidGitRepositoryError, exc.NoSuchPathError): continue - repos.append(repo) + valid.append(path) base = os.path.abspath(base) - suffix = "" if len(repos) == 1 else "s" - print(BOLD + base, "({0} repo{1}):".format(len(repos), suffix)) + suffix = "" if len(valid) == 1 else "s" + print(BOLD + base, "({0} repo{1}):".format(len(valid), suffix)) - for repo in sorted(repos, key=lambda r: os.path.split(r.working_dir)[1]): - callback(repo, *args) + for path in sorted(valid, key=os.path.basename): + callback(Repo(path), *args) def _dispatch(path, callback, *args): """Apply a callback function on each valid repo in the given path.