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

Make use of xargs for Repo().ignored function #1790

Open
@ericwb

Description

@ericwb

In my use case, I wish to utilize theRepo class functionignored() to filter out a potentially larger list of files. The issue is that somethings this list of files is way too large. For example:

The command line max argument size is defined as noted here:

$ getconf ARG_MAX1048576

However, my code is going beyond that maximum because the git repos I have chosen have lots of ignorable files.

I get this error:

Traceback (most recent call last):  File "/Users/ericwb/workspace/bandit/.tox/py312/bin/bandit", line 8, in <module>    sys.exit(main())             ^^^^^^  File "/Users/ericwb/workspace/bandit/bandit/cli/main.py", line 657, in main    b_mgr.discover_files(args.targets, args.recursive, args.excluded_paths)  File "/Users/ericwb/workspace/bandit/bandit/core/manager.py", line 252, in discover_files    ignore_list = repo.ignored(*files)                  ^^^^^^^^^^^^^^^^^^^^  File "/Users/ericwb/workspace/bandit/.tox/py312/lib/python3.12/site-packages/git/repo/base.py", line 878, in ignored    proc: str = self.git.check_ignore(*paths)                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/ericwb/workspace/bandit/.tox/py312/lib/python3.12/site-packages/git/cmd.py", line 736, in <lambda>    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/ericwb/workspace/bandit/.tox/py312/lib/python3.12/site-packages/git/cmd.py", line 1316, in _call_process    return self.execute(call, **exec_kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/Users/ericwb/workspace/bandit/.tox/py312/lib/python3.12/site-packages/git/cmd.py", line 988, in execute    proc = Popen(           ^^^^^^  File "/Users/ericwb/.pyenv/versions/3.12.1/lib/python3.12/subprocess.py", line 1026, in __init__    self._execute_child(args, executable, preexec_fn, close_fds,  File "/Users/ericwb/.pyenv/versions/3.12.1/lib/python3.12/subprocess.py", line 1950, in _execute_child    raise child_exception_type(errno_num, err_msg, err_filename)OSError: [Errno 7] Argument list too long: 'git'

If I was using the command line, I'd take advantage of xargs to split the argument size below the max and repeatedly callgit check-ignore. For reference:https://stackoverflow.com/questions/2381241/what-is-the-subprocess-popen-max-length-of-the-args-parameter

While I can do the splitting of the list in my Python code, I believe it makes more sense that the library designed to call command lines does it itself. And maybe it doesn't make sense for all commands, be do believexargs would work well forgit check-ignore

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp