mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add option to filter git.remote_refs output
This can speed up how long it takes to run git ls-remote on repos with a lot of refs.
This commit is contained in:
parent
b004a1ace7
commit
bbcdcb719e
1 changed files with 18 additions and 2 deletions
|
@ -3813,15 +3813,23 @@ def remote_refs(url,
|
|||
https_pass=None,
|
||||
ignore_retcode=False,
|
||||
output_encoding=None,
|
||||
saltenv='base'):
|
||||
saltenv='base',
|
||||
**kwargs):
|
||||
'''
|
||||
.. versionadded:: 2015.8.0
|
||||
|
||||
Return the remote refs for the specified URL
|
||||
Return the remote refs for the specified URL by running ``git ls-remote``.
|
||||
|
||||
url
|
||||
URL of the remote repository
|
||||
|
||||
filter
|
||||
Optionally provide a ref name to ``git ls-remote``. This can be useful
|
||||
to make this function run faster on repositories with many
|
||||
branches/tags.
|
||||
|
||||
.. versionadded:: Fluorine
|
||||
|
||||
heads : False
|
||||
Restrict output to heads. Can be combined with ``tags``.
|
||||
|
||||
|
@ -3893,7 +3901,13 @@ def remote_refs(url,
|
|||
.. code-block:: bash
|
||||
|
||||
salt myminion git.remote_refs https://github.com/saltstack/salt.git
|
||||
salt myminion git.remote_refs https://github.com/saltstack/salt.git filter=develop
|
||||
'''
|
||||
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||
filter_ = kwargs.pop('filter', None)
|
||||
if kwargs:
|
||||
salt.utils.invalid_kwargs(kwargs)
|
||||
|
||||
command = ['git', 'ls-remote']
|
||||
if heads:
|
||||
command.append('--heads')
|
||||
|
@ -3906,6 +3920,8 @@ def remote_refs(url,
|
|||
https_only=True))
|
||||
except ValueError as exc:
|
||||
raise SaltInvocationError(exc.__str__())
|
||||
if filter_:
|
||||
command.append(filter_)
|
||||
output = _git_run(command,
|
||||
user=user,
|
||||
password=password,
|
||||
|
|
Loading…
Add table
Reference in a new issue