From 839ca42632efe72502a1b21056d5498c81caecc7 Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Thu, 26 Oct 2023 12:53:05 +0200 Subject: [PATCH] use run-context-manager in gitworktree.py --- datalad_next/iter_collections/gitworktree.py | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/datalad_next/iter_collections/gitworktree.py b/datalad_next/iter_collections/gitworktree.py index a2dee1b58..e2448f1cd 100644 --- a/datalad_next/iter_collections/gitworktree.py +++ b/datalad_next/iter_collections/gitworktree.py @@ -23,10 +23,9 @@ from datalad_next.runners import ( DEVNULL, LineSplitter, - ThreadedRunner, StdOutCaptureGeneratorProtocol, ) - +from datalad_next.runners.run import run from .utils import ( FileSystemItem, FileSystemItemType, @@ -250,8 +249,7 @@ def _lsfiles_line2props( def _git_ls_files(path, *args): - # we use a plain runner to avoid the overhead of a GitRepo instance - runner = ThreadedRunner( + with run( cmd=[ 'git', 'ls-files', # we rely on zero-byte splitting below @@ -261,12 +259,12 @@ def _git_ls_files(path, *args): ], protocol_class=StdOutCaptureGeneratorProtocol, stdin=DEVNULL, - # run in the directory we want info on cwd=path, - ) - line_splitter = LineSplitter('\0', keep_ends=False) - # for each command output chunk received by the runner - for content in runner.run(): - # for each zerobyte-delimited "line" in the output - for line in line_splitter.process(content.decode('utf-8')): - yield line + ) as r: + # we use a plain runner to avoid the overhead of a GitRepo instance + line_splitter = LineSplitter('\0', keep_ends=False) + # for each command output chunk received by the runner + for content in r: + # for each zerobyte-delimited "line" in the output + for line in line_splitter.process(content.decode('utf-8')): + yield line