def _create_checkout(self): """Creates a checkout to use for cherry-picking. This creates a checkout similarly to git-new-workdir. Most of the .git directory is shared with the |self._parent_repo| using symlinks. This differs from git-new-workdir in that the config is forked instead of shared. This is so the new workdir can be a sparse checkout without affecting |self._parent_repo|. """ parent_git_dir = os.path.join( self._parent_repo, self._run_git_command(['rev-parse', '--git-dir']).strip()) self._workdir = tempfile.mkdtemp(prefix='drover_%s_' % self._branch) logging.debug('Creating checkout in %s', self._workdir) git_dir = os.path.join(self._workdir, '.git') git_common.make_workdir_common(parent_git_dir, git_dir, self.FILES_TO_LINK, self.FILES_TO_COPY, mk_symlink) self._run_git_command(['config', 'core.sparsecheckout', 'true']) with open(os.path.join(git_dir, 'info', 'sparse-checkout'), 'w') as f: f.write('/codereview.settings') branch_name = os.path.split(self._workdir)[-1] self._run_git_command( ['checkout', '-b', branch_name, self._branch_ref]) self._branch_name = branch_name
def _create_checkout(self): """Creates a checkout to use for cherry-picking. This creates a checkout similarly to git-new-workdir. Most of the .git directory is shared with the |self._parent_repo| using symlinks. This differs from git-new-workdir in that the config is forked instead of shared. This is so the new workdir can be a sparse checkout without affecting |self._parent_repo|. """ parent_git_dir = os.path.abspath(self._run_git_command( ['rev-parse', '--git-dir']).strip()) self._workdir = tempfile.mkdtemp(prefix='drover_%s_' % self._branch) logging.debug('Creating checkout in %s', self._workdir) git_dir = os.path.join(self._workdir, '.git') git_common.make_workdir_common(parent_git_dir, git_dir, self.FILES_TO_LINK, self.FILES_TO_COPY, mk_symlink) self._run_git_command(['config', 'core.sparsecheckout', 'true']) with open(os.path.join(git_dir, 'info', 'sparse-checkout'), 'w') as f: f.write('codereview.settings') branch_name = os.path.split(self._workdir)[-1] self._run_git_command(['checkout', '-b', branch_name, self._branch_ref]) self._branch_name = branch_name