diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 24d0cdf10..6fd17a24b 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -537,7 +537,7 @@ Returns: (str) The URL of the remote Git repository, or None. Find and return the timestamp of the given commit. -— **def [ls\_remote](/recipes/recipe_modules/git/api.py#472)(self, url, ref, name=None, tags=True, branches=True, \*\*kwargs):** +— **def [ls\_remote](/recipes/recipe_modules/git/api.py#472)(self, url, ref, name=None, \*\*kwargs):** Request the head revision for a given ref using ls-remote. Raise a StepFailure if the ref does not exist, or more than one ref was found. @@ -546,8 +546,6 @@ Args: * url (str): url of remote repo to use as upstream. * ref (str): ref to query head revision. * name (str): Name of the infra step. - * tags (bool): Include tags. - * branches (bool): Include branches. Returns: A git revision. diff --git a/recipes/recipe_modules/git/api.py b/recipes/recipe_modules/git/api.py index aeb458eb6..1d4ea0f3c 100644 --- a/recipes/recipe_modules/git/api.py +++ b/recipes/recipe_modules/git/api.py @@ -469,7 +469,7 @@ class GitApi(recipe_api.RecipeApi): step_test_data=step_test_data) return [l.strip() for l in step_result.stdout.strip().splitlines()] - def ls_remote(self, url, ref, name=None, tags=True, branches=True, **kwargs): + def ls_remote(self, url, ref, name=None, **kwargs): """Request the head revision for a given ref using ls-remote. Raise a StepFailure if the ref does not exist, or more than one ref was found. @@ -477,20 +477,12 @@ class GitApi(recipe_api.RecipeApi): * url (str): url of remote repo to use as upstream. * ref (str): ref to query head revision. * name (str): Name of the infra step. - * tags (bool): Include tags. - * branches (bool): Include branches. Returns: A git revision. """ cwd = self.m.context.cwd or self.m.path.start_dir name = name or f'Retrieve revision for {ref}' - - cmd = ['ls-remote'] - if tags: - cmd.append('-t') - if branches: - cmd.append('-b') - cmd.extend([url, ref]) + cmd = ['ls-remote', url, ref] with self.m.context(cwd): result = self(*cmd, diff --git a/recipes/recipe_modules/git/tests/ls_remote.py b/recipes/recipe_modules/git/tests/ls_remote.py index af6432b16..c26502979 100644 --- a/recipes/recipe_modules/git/tests/ls_remote.py +++ b/recipes/recipe_modules/git/tests/ls_remote.py @@ -18,10 +18,8 @@ REPO_URL = 'https://chromium.googlesource.com/v8/v8' def RunSteps(api): url = api.properties.get('url', REPO_URL) ref = api.properties.get('ref', 'main') - tags = api.properties.get('tags', True) - branches = api.properties.get('branches', True) - result = api.git.ls_remote(url, ref, tags=tags, branches=branches) + result = api.git.ls_remote(url, ref) api.step.empty('revision', step_text=result) @@ -56,7 +54,7 @@ def GenTests(api): yield test( 'basic', - ['git', 'ls-remote', '-t', '-b', REPO_URL, 'main'], + ['git', 'ls-remote', REPO_URL, 'main'], mock_ls_remote('main', [('badc0ffee0ded', 'refs/heads/main')]), api.post_process( post.StepTextEquals, @@ -65,23 +63,9 @@ def GenTests(api): ), ) - yield test( - 'no-tags', - ['git', 'ls-remote', '-b', REPO_URL, 'main'], - api.properties(tags=False), - mock_ls_remote('main', [('badc0ffee0ded', 'refs/heads/main')]), - ) - - yield test( - 'no-branches', - ['git', 'ls-remote', '-t', REPO_URL, 'main'], - api.properties(branches=False), - mock_ls_remote('main', [('badc0ffee0ded', 'refs/heads/main')]), - ) - yield test( 'multiple-refs', - ['git', 'ls-remote', '-t', '-b', REPO_URL, '13.3.19'], + ['git', 'ls-remote', REPO_URL, '13.3.19'], api.properties(ref='13.3.19'), mock_ls_remote('13.3.19', [ ('badc0ffee0ded', 'refs/heads/13.3.19'), @@ -95,7 +79,7 @@ def GenTests(api): yield test( 'no-refs', - ['git', 'ls-remote', '-t', '-b', REPO_URL, '13.3'], + ['git', 'ls-remote', REPO_URL, '13.3'], api.properties(ref='13.3'), mock_ls_remote('13.3', []), api.post_process(post.StatusFailure),