subprocess.run wrappers cause code duplication
Bug #1710253 reported by
Robie Basak
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
git-ubuntu |
Triaged
|
Low
|
Nish Aravamudan |
Bug Description
I suggest that we refactor how we call subprocess (wrapper for logging) functions to avoid duplication like this in git_repository.py:
+ kwargs = {}
+ kwargs['quiet'] = False
+ if verbose:
+ # If we are redirecting stdout/stderr to the console, we
+ # do not need to have run() also emit it
+ kwargs['quiet'] = True
+ kwargs['stdout'] = None
+ kwargs['stderr'] = None
+ self.git_
Yeah, I think it makes sense for run() to take *different* parameters than subprocess, based upon what we actually need. In this case, we need quiet==True, so that run() doesn't output, but only because we want it to go to the console instead. So there should be a parameter like ouput_to_ console= True/False, rather than having the caller know about that implementation detail.