9from recipe_engine
import recipe_api
10from recipe_engine
import config_types
17 """The default location for cached persistent checkouts."""
18 return self.m.vars.cache_dir.join(
'work')
21 """Fail if git is not obtained from CIPD."""
22 script = self.resource(
'assert_git_cipd.py')
24 self.m.step,
'Assert that Git is from CIPD', cmd=[
'python3', script])
26 def git(self, checkout_root):
27 """Run the steps to perform a pure-git checkout without DEPS."""
29 skia_dir = checkout_root.join(
'skia')
31 self.m.properties[
'repository'], dir_path=skia_dir,
32 ref=self.m.properties[
'revision'], submodules=
False)
33 if self.m.vars.is_trybot:
34 self.m.
git(
'fetch',
'origin', self.m.properties[
'patch_ref'])
35 self.m.
git(
'checkout',
'FETCH_HEAD')
36 self.m.
git(
'rebase', self.m.properties[
'revision'])
37 return self.m.properties[
'revision']
40 skip_patch=False, override_revision=None):
41 """Run the steps to obtain a checkout using bot_update.
44 checkout_root: Root directory where the code will be synced.
45 gclient_cache: Optional, directory of the gclient cache.
46 skip_patch: Ignore changelist/patchset when syncing the Skia repo.
50 gclient_cache = self.m.vars.cache_dir.join(
'git')
55 cfg_kwargs[
'CACHE_DIR'] = gclient_cache
59 self.m.file.ensure_directory(
'makedirs checkout_path', checkout_root)
62 gclient_cfg = self.m.gclient.make_config(**cfg_kwargs)
64 main_repo = self.m.properties[
'repository']
65 main_name = self.m.path.basename(main_repo)
66 if main_name.endswith(
'.git'):
67 main_name = main_name[:-
len(
'.git')]
68 main = gclient_cfg.solutions.add()
72 main.revision = (override_revision
or
73 self.m.properties.get(
'revision')
or 'origin/main')
74 m = gclient_cfg.got_revision_mapping
75 m[main_name] =
'got_revision'
76 patch_root = main_name
78 if self.m.properties.get(
'patch_repo'):
79 patch_repo = self.m.properties[
'patch_repo']
80 patch_root = patch_repo.split(
'/')[-1]
81 if patch_root.endswith(
'.git'):
82 patch_root = patch_root[:-4]
86 entries_file = checkout_root.join(
'.gclient_entries')
87 if self.m.path.exists(entries_file)
or self._test_data.enabled:
88 self.m.file.remove(
'remove %s' % entries_file,
93 patch_ref = self.m.properties.get(
'patch_ref')
94 if patch_ref
and not skip_patch:
95 patch_refs = [
'%s@%s:%s' % (self.m.properties[
'patch_repo'],
96 self.m.properties[
'revision'],
99 self.m.gclient.c = gclient_cfg
100 with self.m.context(cwd=checkout_root):
102 update_step = self.m.bot_update.ensure_checkout(
103 patch_root=patch_root,
109 patch_refs=patch_refs,
112 download_topics=
True,
115 return update_step.presentation.properties[
'got_revision']
def default_checkout_root(self)
def git(self, checkout_root)
def bot_update(self, checkout_root, gclient_cache=None, skip_patch=False, override_revision=None)
def assert_git_is_from_cipd(self)