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

Side by Side Diff: recipe_engine/package.py

Issue 2720853002: Fix GitBackend.checkout (Closed)
Patch Set: tests Created 3 years, 9 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
OLDNEW
1 # Copyright 2015 The LUCI Authors. All rights reserved. 1 # Copyright 2015 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 import copy 5 import copy
6 import difflib 6 import difflib
7 import logging 7 import logging
8 import operator 8 import operator
9 import os 9 import os
10 import subprocess 10 import subprocess
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if self.backend.repo_type != package_pb2.DepSpec.GIT: 213 if self.backend.repo_type != package_pb2.DepSpec.GIT:
214 buf.repo_type = self.backend.repo_type 214 buf.repo_type = self.backend.repo_type
215 215
216 return buf 216 return buf
217 217
218 def updates(self, context, other_revision=None): 218 def updates(self, context, other_revision=None):
219 """Returns a list of all updates to the branch since the revision this 219 """Returns a list of all updates to the branch since the revision this
220 repo spec refers to. 220 repo spec refers to.
221 """ 221 """
222 raw_updates = self.raw_updates( 222 raw_updates = self.raw_updates(
223 context, (other_revision or self.backend.branch_spec(self.branch))) 223 context, (other_revision or 'refs/heads/' + self.branch))
224 updates = [] 224 updates = []
225 for rev in raw_updates: 225 for rev in raw_updates:
226 # TODO(somebody): 'info' is not used. 226 # TODO(somebody): 'info' is not used.
227 info = self._get_commit_info(rev, context) 227 info = self._get_commit_info(rev, context)
228 updates.append(GitRepoSpec( 228 updates.append(GitRepoSpec(
229 self.project_id, 229 self.project_id,
230 self.repo, 230 self.repo,
231 self.branch, 231 self.branch,
232 rev, 232 rev,
233 self.path, 233 self.path,
(...skipping 21 matching lines...) Expand all
255 paths.extend([subdir + os.path.sep, self.proto_file(context).path]) 255 paths.extend([subdir + os.path.sep, self.proto_file(context).path])
256 256
257 return self.backend.updates( 257 return self.backend.updates(
258 self.repo, self.revision, checkout_dir, context.allow_fetch, 258 self.repo, self.revision, checkout_dir, context.allow_fetch,
259 other_revision, paths) 259 other_revision, paths)
260 260
261 def get_more_recent_revision(self, context, r1, r2): 261 def get_more_recent_revision(self, context, r1, r2):
262 """Returns the more recent revision.""" 262 """Returns the more recent revision."""
263 self.checkout(context) 263 self.checkout(context)
264 if context.allow_fetch: 264 if context.allow_fetch:
265 self.run_git(context, 'fetch') 265 self.run_git(context, 'fetch', self.repo, 'refs/heads/master')
Paweł Hajdan Jr. 2017/02/28 08:44:33 Similarly I'm worried about assumptions r1 and r2
266 args = [ 266 args = [
267 'rev-list', 267 'rev-list',
268 '%s...%s' % (r1, r2), # Note three dots (...) here. 268 '%s...%s' % (r1, r2), # Note three dots (...) here.
269 ] 269 ]
270 return self.run_git(context, *args).strip().split('\n')[0] 270 return self.run_git(context, *args).strip().split('\n')[0]
271 271
272 def _get_commit_info(self, rev, context): 272 def _get_commit_info(self, rev, context):
273 checkout_dir = self._dep_dir(context) 273 checkout_dir = self._dep_dir(context)
274 metadata = self.backend.commit_metadata( 274 metadata = self.backend.commit_metadata(
275 self.repo, rev, checkout_dir, context.allow_fetch) 275 self.repo, rev, checkout_dir, context.allow_fetch)
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 >>> d = { 'x': 1, 'y': 2 } 683 >>> d = { 'x': 1, 'y': 2 }
684 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items()) 684 >>> sorted(_updated(d, { 'y': 3, 'z': 4 }).items())
685 [('x', 1), ('y', 3), ('z', 4)] 685 [('x', 1), ('y', 3), ('z', 4)]
686 >>> sorted(d.items()) 686 >>> sorted(d.items())
687 [('x', 1), ('y', 2)] 687 [('x', 1), ('y', 2)]
688 """ 688 """
689 689
690 d = copy.copy(d) 690 d = copy.copy(d)
691 d.update(updates) 691 d.update(updates)
692 return d 692 return d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698