def __init__(self, path, tracking_branch, remote='origin'): tracking_branch = 'refs/remotes/%s/%s' % ( remote, git.StripRefs(tracking_branch), ) attrs = dict(local_path=path, path=path, tracking_branch=tracking_branch) self.checkout = git.ProjectCheckout(attrs)
def setUp(self): self.fake_unversioned_patchable = git.ProjectCheckout( dict(name='chromite', path='src/chromite', revision='remotes/for/master')) self.fake_unversioned_unpatchable = git.ProjectCheckout( dict(name='chromite', path='src/platform/somethingsomething/chromite', # Pinned to a SHA1. revision='1deadbeeaf1deadbeeaf1deadbeeaf1deadbeeaf')) self.fake_versioned_patchable = git.ProjectCheckout( dict(name='chromite', path='src/chromite', revision='1deadbeeaf1deadbeeaf1deadbeeaf1deadbeeaf', upstream='remotes/for/master')) self.fake_versioned_unpatchable = git.ProjectCheckout( dict(name='chromite', path='src/chromite', revision='1deadbeeaf1deadbeeaf1deadbeeaf1deadbeeaf', upstream='1deadbeeaf1deadbeeaf1deadbeeaf1deadbeeaf'))
def setUp(self): self.path, self.project, self.branch = 'mydir', 'my/project', 'mybranch' self.tracking_branch = 'kernel' self.patches = ['%s:%s' % (self.project, self.branch)] self.manifest = mock.MagicMock() attrs = dict(tracking_branch=self.tracking_branch, local_path=self.path, remote='cros') checkout = git.ProjectCheckout(attrs) self.PatchObject( self.manifest, 'FindCheckouts', return_value=[checkout] )
def testResultForBadConfigFile(self): """Test whether the return is None when handle a malformat config file.""" build_root = 'foo/build/root' change = self.GetPatches(how_many=1) self.PatchObject(git.ManifestCheckout, 'Cached') self.PatchObject(cros_patch.GitRepoPatch, 'GetCheckout', return_value=git.ProjectCheckout(attrs={})) self.PatchObject(git.ProjectCheckout, 'GetPath') with osutils.TempDir(set_global=True) as tempdir: path = os.path.join(tempdir, 'COMMIT-QUEUE.ini') osutils.WriteFile(path, 'foo\n') self.PatchObject(triage_lib, '_GetConfigFileForChange', return_value=path) result = triage_lib.GetOptionForChange(build_root, change, 'a', 'b') self.assertEqual(None, result)