Commit 2fddb956 authored by Ryan Tseng's avatar Ryan Tseng Committed by Commit Bot

[git recipe_module] Add tags flag for fetch

Some projects that use the git module (eg flutter) require tags.

Bug:  870558
Change-Id: Idae50ef5c8a092e5f0109b6c14c562268a2ad236
Reviewed-on: https://chromium-review.googlesource.com/c/1274245Reviewed-by: 's avatarJao-ke Chin-Lee <jchinlee@chromium.org>
Commit-Queue: Ryan Tseng <hinoka@chromium.org>
parent 83bd7f4c
......@@ -401,7 +401,7 @@ Returns:
Return a git command step.
&mdash; **def [bundle\_create](/recipes/recipe_modules/git/api.py#370)(self, bundle_path, rev_list_args=None, \*\*kwargs):**
&mdash; **def [bundle\_create](/recipes/recipe_modules/git/api.py#374)(self, bundle_path, rev_list_args=None, \*\*kwargs):**
Run 'git bundle create' on a Git repository.
......@@ -415,7 +415,7 @@ Args:
Outputs the contents of a file at a given revision.
&mdash; **def [checkout](/recipes/recipe_modules/git/api.py#110)(self, url, ref=None, dir_path=None, recursive=False, submodules=True, submodule_update_force=False, keep_paths=None, step_suffix=None, curl_trace_file=None, can_fail_build=True, set_got_revision=False, remote_name=None, display_fetch_size=None, file_name=None, submodule_update_recursive=True, use_git_cache=False, progress=True):**
&mdash; **def [checkout](/recipes/recipe_modules/git/api.py#110)(self, url, ref=None, dir_path=None, recursive=False, submodules=True, submodule_update_force=False, keep_paths=None, step_suffix=None, curl_trace_file=None, can_fail_build=True, set_got_revision=False, remote_name=None, display_fetch_size=None, file_name=None, submodule_update_recursive=True, use_git_cache=False, progress=True, tags=False):**
Performs a full git checkout and returns sha1 of checked out revision.
......@@ -449,11 +449,12 @@ Args:
"git fetch origin" or "git push origin".
* arbitrary refs such refs/whatever/not-fetched-by-default-to-cache
progress (bool): wether to show progress for fetch or not
tags (bool): Also fetch tags.
Returns: If the checkout was successful, this returns the commit hash of
the checked-out-repo. Otherwise this returns None.
&mdash; **def [config\_get](/recipes/recipe_modules/git/api.py#343)(self, prop_name, \*\*kwargs):**
&mdash; **def [config\_get](/recipes/recipe_modules/git/api.py#347)(self, prop_name, \*\*kwargs):**
Returns: (str) The Git config output, or None if no output was generated.
......@@ -478,7 +479,7 @@ Returns:
Fetches all tags from the remote.
&mdash; **def [get\_remote\_url](/recipes/recipe_modules/git/api.py#360)(self, remote_name=None, \*\*kwargs):**
&mdash; **def [get\_remote\_url](/recipes/recipe_modules/git/api.py#364)(self, remote_name=None, \*\*kwargs):**
Returns: (str) The URL of the remote Git repository, or None.
......@@ -486,11 +487,11 @@ Args:
remote_name: (str) The name of the remote to query, defaults to 'origin'.
kwargs: Forwarded to '__call__'.
&mdash; **def [get\_timestamp](/recipes/recipe_modules/git/api.py#315)(self, commit='HEAD', test_data=None, \*\*kwargs):**
&mdash; **def [get\_timestamp](/recipes/recipe_modules/git/api.py#319)(self, commit='HEAD', test_data=None, \*\*kwargs):**
Find and return the timestamp of the given commit.
&mdash; **def [new\_branch](/recipes/recipe_modules/git/api.py#383)(self, branch, name=None, upstream=None, \*\*kwargs):**
&mdash; **def [new\_branch](/recipes/recipe_modules/git/api.py#387)(self, branch, name=None, upstream=None, \*\*kwargs):**
Runs git new-branch on a Git repository, to be used before git cl upload.
......@@ -500,7 +501,7 @@ Args:
upstream (str): to origin/master.
kwargs: Forwarded to '__call__'.
&mdash; **def [rebase](/recipes/recipe_modules/git/api.py#324)(self, name_prefix, branch, dir_path, remote_name=None, \*\*kwargs):**
&mdash; **def [rebase](/recipes/recipe_modules/git/api.py#328)(self, name_prefix, branch, dir_path, remote_name=None, \*\*kwargs):**
Run rebase HEAD onto branch
Args:
......
......@@ -114,7 +114,7 @@ class GitApi(recipe_api.RecipeApi):
set_got_revision=False, remote_name=None,
display_fetch_size=None, file_name=None,
submodule_update_recursive=True,
use_git_cache=False, progress=True):
use_git_cache=False, progress=True, tags=False):
"""Performs a full git checkout and returns sha1 of checked out revision.
Args:
......@@ -147,6 +147,7 @@ class GitApi(recipe_api.RecipeApi):
"git fetch origin" or "git push origin".
* arbitrary refs such refs/whatever/not-fetched-by-default-to-cache
progress (bool): wether to show progress for fetch or not
tags (bool): Also fetch tags.
Returns: If the checkout was successful, this returns the commit hash of
the checked-out-repo. Otherwise this returns None.
......@@ -248,6 +249,9 @@ class GitApi(recipe_api.RecipeApi):
fetch_env['GIT_CURL_VERBOSE'] = '1'
fetch_stderr = self.m.raw_io.output(leak_to=curl_trace_file)
if tags:
fetch_args.append('--tags')
fetch_step_name = 'git fetch%s' % step_suffix
if display_fetch_size:
count_objects_before_fetch = self.count_objects(
......
[
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[depot_tools::git]/resources/git_setup.py",
"--path",
"[START_DIR]/src",
"--url",
"https://chromium.googlesource.com/chromium/src.git"
],
"name": "git setup"
},
{
"cmd": [
"git",
"retry",
"fetch",
"origin",
"master",
"--recurse-submodules",
"--progress",
"--tags"
],
"cwd": "[START_DIR]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:<PATH>"
},
"infra_step": true,
"name": "git fetch"
},
{
"cmd": [
"git",
"checkout",
"-f",
"FETCH_HEAD"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git checkout"
},
{
"cmd": [
"git",
"rev-parse",
"HEAD"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "read revision",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
"cmd": [
"git",
"clean",
"-f",
"-d",
"-x"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git clean"
},
{
"cmd": [
"git",
"submodule",
"sync"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "submodule sync"
},
{
"cmd": [
"git",
"submodule",
"update",
"--init",
"--recursive"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "submodule update"
},
{
"cmd": [
"git",
"-c",
"foo=bar",
"count-objects",
"-v"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "count-objects",
"stdout": "/path/to/tmp/"
},
{
"cmd": [
"git",
"config",
"--get",
"remote.origin.url"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git config remote.origin.url",
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_TEXT@foo@@@"
]
},
{
"cmd": [
"git",
"show",
"HEAD",
"--format=%at",
"-s"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git show",
"stdout": "/path/to/tmp/"
},
{
"cmd": [
"git",
"fetch",
"origin",
"--tags"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git fetch tags"
},
{
"cmd": [
"git",
"status"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git status"
},
{
"cmd": [
"git",
"status"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git status can_fail_build"
},
{
"cmd": [
"git",
"status"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git status cannot_fail_build"
},
{
"cmd": [
"git",
"new-branch",
"refactor"
],
"cwd": "[START_DIR]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:<PATH>"
},
"infra_step": true,
"name": "git new-branch refactor"
},
{
"cmd": [
"git",
"new-branch",
"feature",
"--upstream",
"refactor"
],
"cwd": "[START_DIR]/src",
"env": {
"PATH": "RECIPE_PACKAGE_REPO[depot_tools]:<PATH>"
},
"infra_step": true,
"name": "git new-branch feature"
},
{
"cmd": [
"git",
"rebase",
"origin/master"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "my repo rebase"
},
{
"cmd": [
"git",
"bundle",
"create",
"[START_DIR]/all.bundle",
"--all"
],
"cwd": "[START_DIR]/src",
"infra_step": true,
"name": "git bundle"
},
{
"name": "$result",
"recipe_result": null,
"status_code": 0
}
]
\ No newline at end of file
......@@ -38,7 +38,8 @@ def RunSteps(api):
display_fetch_size=api.properties.get('display_fetch_size'),
file_name=api.properties.get('checkout_file_name'),
submodule_update_recursive=submodule_update_recursive,
use_git_cache=api.properties.get('use_git_cache'))
use_git_cache=api.properties.get('use_git_cache'),
tags=api.properties.get('tags'))
assert retVal == "deadbeef", (
"expected retVal to be %r but was %r" % ("deadbeef", retVal))
......@@ -93,6 +94,7 @@ def RunSteps(api):
def GenTests(api):
yield api.test('basic')
yield api.test('basic_tags') + api.properties(tags=True)
yield api.test('basic_ref') + api.properties(revision='refs/foo/bar')
yield api.test('basic_branch') + api.properties(revision='refs/heads/testing')
yield api.test('basic_hash') + api.properties(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment