def unpin(self, work_dir):
    """Unpin chrome."""

    overlay = os.path.join(work_dir, 'overlay')
    print('Setting up working directory...')
    CloneWorkingRepo(overlay, OVERLAY_URL, OVERLAY, self.options.branch)
    print('Done')

    mask_file = os.path.join(overlay, MASK_FILE)
    if not os.path.exists(mask_file):
      raise Exception('Mask file not found. Is Chrome pinned?')

    git.CreateBranch(overlay, self.branch_name, track=True,
                     branch_point='origin/%s' % self.options.branch)

    git.RmPath(mask_file)
    git.Commit(overlay, self.CommitMessage('Chrome: Unpin chrome'))
    git.UploadCL(overlay, OVERLAY_URL, self.options.branch,
                 skip=self.options.dryrun)
Example #2
0
def RevertStableEBuild(dirname, rev):
    """Revert the stable ebuilds for a package back to a particular revision.

  Also add/remove the files in git.

  Args:
    dirname: Path to the ebuild directory.
    rev: Revision to revert back to.

  Returns:
    The name of the ebuild reverted to.
  """
    package = os.path.basename(dirname.rstrip(os.sep))
    pattern = '%s-*.ebuild' % package

    # Get rid of existing stable ebuilds.
    ebuilds = glob.glob(os.path.join(dirname, pattern))
    for ebuild in ebuilds:
        parts = SplitPVPath(ebuild)
        if parts.version != '9999':
            git.RmPath(ebuild)

    # Bring back the old stable ebuild.
    names = git.GetObjectAtRev(dirname, './', rev).split()
    names = fnmatch.filter(names, pattern)
    names = [
        name for name in names
        if SplitPVPath(os.path.join(dirname, name)).version != '9999'
    ]
    if not names:
        return None
    assert len(names) == 1
    name = names[0]
    git.RevertPath(dirname, name, rev)

    # Update the manifest.
    UpdateManifest(os.path.join(dirname, name))
    manifest_path = os.path.join(dirname, 'Manifest')
    if os.path.exists(manifest_path):
        git.AddPath(manifest_path)
    return os.path.join(dirname, name)
 def testRmPath(self):
     git.RmPath(self.fake_path)
     self.assertCommandContains(['rm'])
     self.assertCommandContains([self.fake_file])