40 skip_patch=False, override_revision=None):
41 """Run the steps to obtain a checkout using bot_update.
42
43 Args:
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.
47 """
48 self.assert_git_is_from_cipd()
49 if not gclient_cache:
50 gclient_cache = self.m.vars.cache_dir.join('git')
51
52 cfg_kwargs = {}
53
54
55 cfg_kwargs['CACHE_DIR'] = gclient_cache
56
57
58
59 self.m.file.ensure_directory('makedirs checkout_path', checkout_root)
60
61
62 gclient_cfg = self.m.gclient.make_config(**cfg_kwargs)
63
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()
69 main.name = main_name
70 main.managed = False
71 main.url = main_repo
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
77 patch_repo = main.url
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]
83
84
85
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,
89 entries_file)
90
91
92 patch_refs = None
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'],
97 patch_ref)]
98
99 self.m.gclient.c = gclient_cfg
100 with self.m.context(cwd=checkout_root):
101
102 update_step = self.m.bot_update.ensure_checkout(
103 patch_root=patch_root,
104
105
106
107
108 patch=True,
109 patch_refs=patch_refs,
110
111
112 download_topics=True,
113 )
114
115 return update_step.presentation.properties['got_revision']