Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GitCommandError: Cmd('git') failed due to: exit code(1) when execute 'grep' with regex #1074

Closed
Labels
@rmahdav

Description

@rmahdav

Hi,

I am trying to execute a grep command with regex using the execute() function. A part of my code is:

for item in toggles:    files_result = Repo.execute(["git", "grep", "--files-with-matches", "\"config.isEnabled([[:space:]*]'" + item + "'[[:space:]*])\""])

I am getting the following error:

---------------------------------------------------------------------------GitCommandError                           Traceback (most recent call last)<ipython-input-82-f4329c19384f> in <module>      3       4 for item in toggles:----> 5     files_result = Repo.execute(["git", "grep", "--files-with-matches", "\"config.isEnabled([[:space:]*]'" + item + "'[[:space:]*])\""])      6     files = files_result.splitlines()      7 /opt/anaconda3/lib/python3.8/site-packages/git/cmd.py in execute(self, command, istream, with_extended_output, with_exceptions, as_process, output_stream, stdout_as_string, kill_after_timeout, with_stdout, universal_newlines, shell, env, max_chunk_size, **subprocess_kwargs)    820     821         if with_exceptions and status != 0:--> 822             raise GitCommandError(command, status, stderr_value, stdout_value)    823     824         if isinstance(stdout_value, bytes) and stdout_as_string:  # could also be output_streamGitCommandError: Cmd('git') failed due to: exit code(1)  cmdline: git grep --files-with-matches "config.isEnabled([[:space:]*]'async-payments'[[:space:]*])"

However, when I rungit grep --files-with-matches "config.isEnabled([[:space:]*]'async-payments'[[:space:]*])" in the command line, it works.

I appreciate any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp