Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: scripts/slave/recipe_modules/git_clone_bundler/api.py

Issue 1101673005: Extract functions from path recipe module so that step can depend on it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import hashlib 5 import hashlib
6 6
7 from slave import recipe_api 7 from slave import recipe_api
8 8
9 """ 9 """
10 The 'git_clone_bundler' creates and uploads 'clone.bundle' packages to 10 The 'git_clone_bundler' creates and uploads 'clone.bundle' packages to
(...skipping 12 matching lines...) Expand all
23 23
24 @property 24 @property
25 def bundle_dir(self): 25 def bundle_dir(self):
26 return self.base_path.join('bundles') 26 return self.base_path.join('bundles')
27 27
28 @staticmethod 28 @staticmethod
29 def _hashname(base): 29 def _hashname(base):
30 return hashlib.md5(base).hexdigest() 30 return hashlib.md5(base).hexdigest()
31 31
32 def _setup(self): 32 def _setup(self):
33 self.m.path.rmtree('old bundles', self.bundle_dir) 33 self.m.file.rmtree('old bundles', self.bundle_dir)
34 self.m.path.makedirs('bundles', self.bundle_dir) 34 self.m.file.makedirs('bundles', self.bundle_dir)
35 35
36 def _bundle(self, git_path, gs_bucket, gs_subpath, refs, name, 36 def _bundle(self, git_path, gs_bucket, gs_subpath, refs, name,
37 unauthenticated_url): 37 unauthenticated_url):
38 """ 38 """
39 Creates a Git bundle from a Git repository and uploads it to Google Storage. 39 Creates a Git bundle from a Git repository and uploads it to Google Storage.
40 40
41 Args: 41 Args:
42 git_path: (Path) The path of the Git repository to bundle. 42 git_path: (Path) The path of the Git repository to bundle.
43 gs_bucket: (str) The name of the Google Storage bucket. 43 gs_bucket: (str) The name of the Google Storage bucket.
44 gs_subpath: (str) The path within the Google Storage bucket. 44 gs_subpath: (str) The path within the Google Storage bucket.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 that repository's bundle was uploaded. 120 that repository's bundle was uploaded.
121 """ 121 """
122 self._setup() 122 self._setup()
123 123
124 # Checkout the repository. 124 # Checkout the repository.
125 checkout_root = self.base_path.join( 125 checkout_root = self.base_path.join(
126 'repo', 126 'repo',
127 hashlib.md5(repo_manifest_url).hexdigest()) 127 hashlib.md5(repo_manifest_url).hexdigest())
128 128
129 # Initialize the 'repo' checkout. 129 # Initialize the 'repo' checkout.
130 self.m.path.makedirs('repo', checkout_root) 130 self.m.file.makedirs('repo', checkout_root)
131 self.m.repo.init(repo_manifest_url, cwd=checkout_root) 131 self.m.repo.init(repo_manifest_url, cwd=checkout_root)
132 self.m.repo.sync('--no-clone-bundle', cwd=checkout_root) 132 self.m.repo.sync('--no-clone-bundle', cwd=checkout_root)
133 133
134 # The repository list produces absolute paths, so we want to convert our 134 # The repository list produces absolute paths, so we want to convert our
135 # 'checkout_root' to an absolute path for relative path calculation. 135 # 'checkout_root' to an absolute path for relative path calculation.
136 abs_checkout_root = self.m.path.abspath(checkout_root) 136 abs_checkout_root = self.m.path.abspath(checkout_root)
137 errors = [] 137 errors = []
138 bundle_map = {} 138 bundle_map = {}
139 visited = set() 139 visited = set()
140 for path, name in self.m.repo.list(cwd=checkout_root): 140 for path, name in self.m.repo.list(cwd=checkout_root):
(...skipping 17 matching lines...) Expand all
158 except self.m.step.StepFailure as e: 158 except self.m.step.StepFailure as e:
159 result = self.m.step.active_result 159 result = self.m.step.active_result
160 result.presentation.step_text = 'Exception: %s' % (e,) 160 result.presentation.step_text = 'Exception: %s' % (e,)
161 result.presentation.status = self.m.step.FAILURE 161 result.presentation.status = self.m.step.FAILURE
162 errors.append(e) 162 errors.append(e)
163 163
164 if errors: 164 if errors:
165 raise self.m.step.StepFailure("Encountered %d bundler failure(s)" % ( 165 raise self.m.step.StepFailure("Encountered %d bundler failure(s)" % (
166 len(errors,))) 166 len(errors,)))
167 return bundle_map 167 return bundle_map
OLDNEW
« no previous file with comments | « scripts/slave/recipe_modules/git_clone_bundler/__init__.py ('k') | scripts/slave/recipe_modules/path/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698