Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: Allow passing arguments to git status/diff #718

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,10 @@ def __init__(self):
super().__init__(
'diff',
'"git diff" for one or more projects',
'Runs "git diff" on each of the specified projects.')
'''Runs "git diff" on each of the specified projects.
Unknown arguments are passed to "git diff".''',
accepts_unknown_args=True,
)

def do_add_parser(self, parser_adder):
parser = self._parser(parser_adder,
Expand All @@ -783,7 +786,7 @@ def do_add_parser(self, parser_adder):
help='show changes relative to the manifest revision')
return parser

def do_run(self, args, ignored):
def do_run(self, args, user_args):
self.die_if_no_git()

failed = []
Expand All @@ -798,6 +801,7 @@ def do_run(self, args, ignored):
cp = project.git(['diff', f'--src-prefix={project.path}/',
f'--dst-prefix={project.path}/',
'--exit-code'] + color + merge_base,
extra_args=user_args,
capture_stdout=True, capture_stderr=True,
check=False)
if cp.returncode == 0:
Expand All @@ -817,7 +821,10 @@ def __init__(self):
super().__init__(
'status',
'"git status" for one or more projects',
"Runs 'git status' for each of the specified projects.")
'''Runs "git status" for each of the specified projects.
Unknown arguments are passed to "git status".''',
accepts_unknown_args=True,
)

def do_add_parser(self, parser_adder):
parser = self._parser(parser_adder,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,13 @@ def test_diff(west_init_tmpdir):

cmd('diff')
cmd('diff --manifest')
cmd('diff --stat')

# Neither should it fail after fetching one or both projects

cmd('update net-tools')
cmd('diff')
cmd('diff --stat')

cmd('update Kconfiglib')

Expand All @@ -351,11 +353,13 @@ def test_status(west_init_tmpdir):
# Status with no projects cloned shouldn't fail

cmd('status')
cmd('status --short --branch')

# Neither should it fail after fetching one or both projects

cmd('update net-tools')
cmd('status')
cmd('status --short --branch')

cmd('update Kconfiglib')

Expand Down
Loading