[git] add ignore_submodules option to status command in git_common.py

The `git addf` function implemented in the CL given below needs the ability to
ignore submodules in the output of `status`. Therefore, I am adding a flag to
the status command in `git_common` that resembles the git command line flag.

https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4771336

Change-Id: I447c0dc853014ef49562f3130b22d038912011c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4771343
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gregory Nisbet <gregorynisbet@google.com>
changes/43/4771343/6
Greg NISBET 2 years ago committed by LUCI CQ
parent de6bc6620a
commit 923bcf8635

@ -871,9 +871,13 @@ def is_dirty_git_tree(cmd):
return False
def status():
def status(ignore_submodules=None):
"""Returns a parsed version of git-status.
Args:
ignore_submodules (str|None): "all", "none", or None.
None is equivalent to "none".
Returns a generator of (current_name, (lstat, rstat, src)) pairs where:
* current_name is the name of the file
* lstat is the left status code letter from git-status
@ -881,6 +885,11 @@ def status():
* src is the current name of the file, or the original name of the file
if lstat == 'R'
"""
ignore_submodules = ignore_submodules or 'none'
assert ignore_submodules in (
'all', 'none'), f'ignore_submodules value {ignore_submodules} is invalid'
stat_entry = collections.namedtuple('stat_entry', 'lstat rstat src')
def tokenizer(stream):
@ -909,7 +918,12 @@ def status():
src = dest
yield (dest, stat_entry(lstat, rstat, src))
return parser(tokenizer(run_stream('status', '-z', bufsize=-1)))
return parser(
tokenizer(
run_stream('status',
'-z',
f'--ignore-submodules={ignore_submodules}',
bufsize=-1)))
def squash_current_branch(header=None, merge_base=None):

Loading…
Cancel
Save