Exemple #1
0
def get_temp_project(origin=None, repo_path=BARE_REPO_PATH):
    if origin:
        prefix_path = get_repo_root()
        temp_repo_path = tempfile.mkdtemp(suffix=".git",
                                          prefix="test_",
                                          dir=prefix_path)
        project_name = temp_repo_path[len(prefix_path) + 1:][:-4]
        project = CodeDoubanProject.add(project_name,
                                        TEMP_PROJECT_OWNER,
                                        TEMP_PROJECT_DESCRIPTION,
                                        fork_from=origin.id,
                                        create_trac=False)
        return project

    prefix_path = get_repo_root()
    temp_repo_path = tempfile.mkdtemp(suffix=".git",
                                      prefix="test_",
                                      dir=prefix_path)
    project_name = temp_repo_path[len(prefix_path) + 1:][:-4]
    project = CodeDoubanProject.add(project_name, TEMP_PROJECT_OWNER,
                                    TEMP_PROJECT_DESCRIPTION)

    shutil.rmtree(temp_repo_path)
    repo = Jagare(repo_path)
    repo.clone(temp_repo_path, bare=True)

    return project
Exemple #2
0
def get_temp_project(origin=None, repo_path=BARE_REPO_PATH):
    if origin:
        prefix_path = get_repo_root()
        temp_repo_path = tempfile.mkdtemp(suffix=".git",
                                          prefix="test_",
                                          dir=prefix_path)
        project_name = temp_repo_path[len(prefix_path) + 1:][:-4]
        project = CodeDoubanProject.add(project_name,
                                        TEMP_PROJECT_OWNER,
                                        TEMP_PROJECT_DESCRIPTION,
                                        fork_from=origin.id,
                                        create_trac=False)
        return project

    prefix_path = get_repo_root()
    temp_repo_path = tempfile.mkdtemp(suffix=".git",
                                      prefix="test_",
                                      dir=prefix_path)
    project_name = temp_repo_path[len(prefix_path) + 1:][:-4]
    project = CodeDoubanProject.add(project_name, TEMP_PROJECT_OWNER,
                                    TEMP_PROJECT_DESCRIPTION)

    shutil.rmtree(temp_repo_path)
    repo = Jagare(repo_path)
    repo.clone(temp_repo_path, bare=True)

    return project
Exemple #3
0
    def test_project_stat(self):
        store.execute("delete from codedouban_projects where project_id < 5")
        project_rs = get_all_project()
        assert len(project_rs) == 0
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 0

        project_name = "project"
        project = CodeDoubanProject.add(project_name,
                                        owner_id="test1",
                                        summary="test",
                                        product="fire")
        git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
        ok_(os.path.exists(git_path))
        project_rs = get_all_project()
        assert len(project_rs) == 1
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 0

        project_fork = project.fork('project_test_fork', 'test_fork')
        project_rs = get_all_project()
        assert len(project_rs) == 2
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 1

        project.delete()
        project_fork.delete()
Exemple #4
0
 def loadCache(self, proj_name, key, n_author):
     try:
         data = beansdb.get(key, None)
         if data:
             self.cache = pickle.loads(zlib.decompress(data))
             if len(self.cache.get('authors')) != n_author:
                 self.cache = {}
     except Exception:
         self.cache = {}
     if not self.cache:
         path = os.path.join(get_repo_root(), 'statscache')
         try:
             f = open(os.path.join(path, '%s.cache' % proj_name), 'rb')
             self.cache = pickle.loads(zlib.decompress(f.read()))
             f.close()
         except Exception:
             self.cache = {}
     if self.cache:
         self.changes_by_date_by_author = self.cache.get(
             'changes_by_date_by_author', {})
         self.changes_by_date = self.cache.get('changes_by_date', {})
         self.authors = self.cache.get('authors', {})
         self.total_commits = self.cache.get('total_commits', 0)
         self.year_week_act = self.cache.get('year_week', defaultdict(int))
         self.year_week_act_peak = self.cache.get('year_week_peak', 0)
         self.total_lines = self.cache.get('total_lines', 0)
         self.total_lines_added = self.cache.get('total_lines_added', 0)
         self.total_lines_removed = self.cache.get('total_lines_removed', 0)
Exemple #5
0
 def test_create_git_repo(self):
     git_path = os.path.join(get_repo_root(), 'abc.git')
     CodeDoubanProject.create_git_repo(git_path)
     assert os.path.exists(git_path)
     info_file = os.path.join(git_path, 'refs')
     assert os.path.exists(info_file)
     shutil.rmtree(git_path)
Exemple #6
0
 def saveCache(self, proj_name, key):
     proj_name = proj_name.replace('/', '_')
     self.cache['authors'] = self.authors
     self.cache['changes_by_date_by_author'] = self.changes_by_date_by_author  # noqa
     self.cache['total_commits'] = self.total_commits
     self.cache['changes_by_date'] = self.changes_by_date
     self.cache['year_week'] = self.year_week_act
     self.cache['year_week_peak'] = self.year_week_act_peak
     self.cache['total_lines'] = self.total_lines
     self.cache['total_lines_added'] = self.total_lines_added
     self.cache['total_lines_removed'] = self.total_lines_removed
     data = zlib.compress(pickle.dumps(self.cache))
     path = os.path.join(get_repo_root(), 'statscache/')
     if not os.path.exists(path):
         os.makedirs(path)
     tmp_name = os.path.join(path + '%s.cache.tmp' % proj_name)
     oldname = os.path.join(path + '%s.cache' % proj_name)
     try:
         os.remove(oldname)
     except OSError:
         pass
     f = open(tmp_name, 'wb')
     f.write(data)
     f.close()
     os.rename(tmp_name, oldname)
     try:
         beansdb.set(key, data)
     except Exception:
         pass
Exemple #7
0
 def loadCache(self, proj_name, key, n_author):
     try:
         data = beansdb.get(key, None)
         if data:
             self.cache = pickle.loads(zlib.decompress(data))
             if len(self.cache.get('authors')) != n_author:
                 self.cache = {}
     except Exception:
         self.cache = {}
     if not self.cache:
         path = os.path.join(get_repo_root(), 'statscache')
         try:
             f = open(os.path.join(path, '%s.cache' % proj_name), 'rb')
             self.cache = pickle.loads(zlib.decompress(f.read()))
             f.close()
         except Exception:
             self.cache = {}
     if self.cache:
         self.changes_by_date_by_author = self.cache.get(
             'changes_by_date_by_author', {})
         self.changes_by_date = self.cache.get('changes_by_date', {})
         self.authors = self.cache.get('authors', {})
         self.total_commits = self.cache.get('total_commits', 0)
         self.year_week_act = self.cache.get('year_week', defaultdict(int))
         self.year_week_act_peak = self.cache.get('year_week_peak', 0)
         self.total_lines = self.cache.get('total_lines', 0)
         self.total_lines_added = self.cache.get('total_lines_added', 0)
         self.total_lines_removed = self.cache.get('total_lines_removed', 0)
Exemple #8
0
 def test_create_git_repo(self):
     git_path = os.path.join(get_repo_root(), "abc.git")
     CodeDoubanProject.create_git_repo(git_path)
     assert os.path.exists(git_path)
     info_file = os.path.join(git_path, "refs")
     assert os.path.exists(info_file)
     shutil.rmtree(git_path)
Exemple #9
0
    def test_project_stat(self):
        store.execute("delete from codedouban_projects where project_id < 5")
        project_rs = get_all_project()
        assert len(project_rs) == 0
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 0

        project_name = "project"
        project = CodeDoubanProject.add(
            project_name, owner_id="test1", summary="test", product="fire")
        git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
        ok_(os.path.exists(git_path))
        project_rs = get_all_project()
        assert len(project_rs) == 1
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 0

        project_fork = project.fork('project_test_fork', 'test_fork')
        project_rs = get_all_project()
        assert len(project_rs) == 2
        project_fork_count = len(filter(lambda x: x[1] is not None,
                                        project_rs))
        assert project_fork_count == 1

        project.delete()
        project_fork.delete()
Exemple #10
0
 def saveCache(self, proj_name, key):
     proj_name = proj_name.replace('/', '_')
     self.cache['authors'] = self.authors
     self.cache[
         'changes_by_date_by_author'] = self.changes_by_date_by_author  # noqa
     self.cache['total_commits'] = self.total_commits
     self.cache['changes_by_date'] = self.changes_by_date
     self.cache['year_week'] = self.year_week_act
     self.cache['year_week_peak'] = self.year_week_act_peak
     self.cache['total_lines'] = self.total_lines
     self.cache['total_lines_added'] = self.total_lines_added
     self.cache['total_lines_removed'] = self.total_lines_removed
     data = zlib.compress(pickle.dumps(self.cache))
     path = os.path.join(get_repo_root(), 'statscache/')
     if not os.path.exists(path):
         os.makedirs(path)
     tmp_name = os.path.join(path + '%s.cache.tmp' % proj_name)
     oldname = os.path.join(path + '%s.cache' % proj_name)
     try:
         os.remove(oldname)
     except OSError:
         pass
     f = open(tmp_name, 'wb')
     f.write(data)
     f.close()
     os.rename(tmp_name, oldname)
     try:
         beansdb.set(key, data)
     except Exception:
         pass
Exemple #11
0
    def test_create_project(self):
        project_name = "project"
        project = CodeDoubanProject.add(
            project_name, owner_id="test1", summary="test", product="fire")

        git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
        ok_(os.path.exists(git_path))
        project.delete()
Exemple #12
0
 def test_rename_bad_project(self):
     pname1 = 'project10'
     pname2 = '/dad13/'
     proj_owner = 'admin_user'
     p = CodeDoubanProject.add(pname1, owner_id=proj_owner,
                               summary="test", product="fire")
     assert p.rename(pname2) is False
     git_path = os.path.join(get_repo_root(), '%s.git' % pname1)
     ok_(os.path.exists(git_path))
Exemple #13
0
 def __init__(self, builder, project_id):
     self.builder = builder
     self.project_id = project_id
     prj = CodeDoubanProject.get(project_id)
     self.docs_dir = os.path.join(get_repo_root(),
                                  prj.name + DOC_EXT, builder)
     self.config = _builder_conf(project_id, builder)
     self.dir = self.config['dir']
     self.temp_dir = None
     self.temp_dir_root = None
Exemple #14
0
 def test_rename_project(self):
     pname1 = 'project8'
     pname2 = 'project9'
     proj_owner = 'admin_user'
     p = CodeDoubanProject.add(pname1, owner_id=proj_owner,
                               summary="test", product="fire")
     p.rename(pname2)
     assert p.name == pname2
     git_path = os.path.join(get_repo_root(), '%s.git' % pname2)
     ok_(os.path.exists(git_path))
Exemple #15
0
 def test_create(self):
     git_path = os.path.join(get_repo_root(), 'test_create.git')
     assert not os.path.exists(
         git_path), "git_path should not exist prior repo creation"
     CodeDoubanProject.create_git_repo(git_path)
     assert os.path.exists(
         git_path), "create_git_repo should create git_path"
     refs_file = os.path.join(git_path, 'refs')
     assert os.path.exists(refs_file), \
         "create_git_repo should create a git repo with refs subdir"
Exemple #16
0
 def __init__(self, project, id, path):
     self.project = project
     self.doc_id = id
     self.doc_path = os.path.join(get_repo_root(),
                                  "%s%s" % (project.name, DOC_EXT),
                                  self.doc_id,
                                  DEFAULT_SPHINX_DIR,
                                  self.doc_id)
     self._content = self.get_file(path)
     self.path = path
Exemple #17
0
 def __init__(self, builder, project_id):
     self.builder = builder
     self.project_id = project_id
     prj = CodeDoubanProject.get(project_id)
     self.docs_dir = os.path.join(get_repo_root(), prj.name + DOC_EXT,
                                  builder)
     self.config = _builder_conf(project_id, builder)
     self.dir = self.config['dir']
     self.temp_dir = None
     self.temp_dir_root = None
Exemple #18
0
    def test_create_project(self):
        project_name = "project"
        project = CodeDoubanProject.add(project_name,
                                        owner_id="test1",
                                        summary="test",
                                        product="fire")

        git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
        ok_(os.path.exists(git_path))
        project.delete()
Exemple #19
0
 def test_create(self):
     git_path = os.path.join(get_repo_root(), 'test_create.git')
     assert not os.path.exists(
         git_path), "git_path should not exist prior repo creation"
     CodeDoubanProject.create_git_repo(git_path)
     assert os.path.exists(
         git_path), "create_git_repo should create git_path"
     refs_file = os.path.join(git_path, 'refs')
     assert os.path.exists(refs_file), \
         "create_git_repo should create a git repo with refs subdir"
Exemple #20
0
 def test_rename_bad_project(self):
     pname1 = 'project10'
     pname2 = '/dad13/'
     proj_owner = 'admin_user'
     p = CodeDoubanProject.add(pname1,
                               owner_id=proj_owner,
                               summary="test",
                               product="fire")
     assert p.rename(pname2) is False
     git_path = os.path.join(get_repo_root(), '%s.git' % pname1)
     ok_(os.path.exists(git_path))
Exemple #21
0
 def test_rename_project(self):
     pname1 = 'project8'
     pname2 = 'project9'
     proj_owner = 'admin_user'
     p = CodeDoubanProject.add(pname1,
                               owner_id=proj_owner,
                               summary="test",
                               product="fire")
     p.rename(pname2)
     assert p.name == pname2
     git_path = os.path.join(get_repo_root(), '%s.git' % pname2)
     ok_(os.path.exists(git_path))
Exemple #22
0
def get_doc_builder_option(project, builder_name):
    option = ArminOption()

    repo_path = project.repo_path
    config = get_builder_conf(project.conf, builder_name)
    builder = config.get('builder')
    builder_dir = config.get('dir')

    temp_path = tempfile.mkdtemp(prefix='sphinx_docs_', dir=get_tmpdir())
    doc_path = os.path.join(get_repo_root(), project.name + DOC_EXT, builder)

    builder_doc_path = os.path.join(doc_path, '.build', builder)
    if config.get('checkout_root'):
        autodoc = True
        builder_temp_path = os.path.join(temp_path, builder_dir)
    else:
        autodoc = False
        builder_temp_path = temp_path
    builder_temp_doc_path = os.path.join(builder_temp_path, '.build', builder)

    option.builder = builder
    option.settings['master_doc'] = 'index'
    option.settings['source_suffix'] = '.rst'
    option.settings['html_short_title'] = project.name
    option.settings.update(config)
    option.settings['project'] = project.name  # noqa -- override a setting in configuration
    option.doctree_path = os.path.join(temp_path, SPHINX_BUILD_DOCTREES)
    option.temp_path = temp_path
    option.sourcedir = builder_temp_path
    option.outdir = builder_temp_doc_path
    option.doc_path = doc_path
    option.builder_doc_path = builder_doc_path
    option.builder_dir = builder_dir
    option.autodoc = autodoc
    option.repo_path = repo_path
    return option
Exemple #23
0
def init_gist_folder():
    GISTS_PATH = os.path.join(get_repo_root(), 'gist')
    if not os.path.exists(GISTS_PATH):
        os.makedirs(GISTS_PATH)
Exemple #24
0
    select.poll = get_original("select", "poll")
    import subprocess

    subprocess.Popen = get_original("subprocess", "Popen")
except ImportError:
    print "You need install gevent manually! System shutdown."

from binascii import hexlify
from maria import Maria
from maria.config import config
from vilya.libs.permdir import get_repo_root
from vilya.models.sshkey import SSHKey
from vilya.models.project import CodeDoubanProject as Project
from vilya.models.gist import Gist

config.project_root = get_repo_root()
config.log_file = None
config.host_key_path = "./host.key"

app = Maria(config=config)


@app.get_environ
def get_environ_handler(user, path):
    return {"CODE_REMOTE_USER": user}


@app.has_permission
def has_permission_handler(username, path, perm):
    if not username or not path:
        return False
Exemple #25
0
def doc_exists(project):
    doc_path = os.path.join(get_repo_root(),
                            "%s%s" % (project.name, DOC_EXT))
    if os.path.exists(doc_path):
        return True
Exemple #26
0
import shutil
from os.path import join

from vilya.libs.permdir import get_repo_root
from vilya.libs.store import store
from vilya.models.project import CodeDoubanProject as Project
from vilya.models.pull import PullRequest
from vilya.models.ticket import Ticket

from tests.utils import clone

from local_config import DOMAIN

p1_name = "project1"
p1_id = None
p1_path = os.path.join(get_repo_root(), "%s.git" % p1_name)
shutil.rmtree(p1_path, ignore_errors=True)
p1 = Project.get_by_name(p1_name)
if p1:
    p1_id = p1.id
    p1.delete()

p2_name = "project2"
p2_id = None
p2_path = os.path.join(get_repo_root(), "%s.git" % p2_name)
shutil.rmtree(p2_path, ignore_errors=True)
p2 = Project.get_by_name(p2_name)
if p2:
    p2_id = p2.id
    p2.delete()
Exemple #27
0
 def repo_path(self):
     return os.path.join(get_repo_root(), '%s.git' % self.name)
Exemple #28
0
 def _path(self, name):
     return os.path.join(get_repo_root(), '%s.git' % name)
 def _path_for_clone(self, name):
     return os.path.join(get_repo_root(), '%s.clone' % name)
Exemple #30
0
        environ['GIT_PATH_INFO'] = get_git_path_info(path_info)
        if environ.get('REMOTE_USER') is None:
            result = self.authenticate(environ)
            if not isinstance(result, str):
                # Request credentials if authentication fails
                return result(environ, start_response)
            environ['REMOTE_USER'] = result
            environ['AUTH_TYPE'] = self.scheme
        return self.application(environ, start_response)


class WebRedirect(object):
    def __init__(self, application, **kw):
        self.application = application

    def __call__(self, environ, start_response):
        http_accept = environ.get('HTTP_ACCEPT')
        path_info = environ.get('PATH_INFO')
        proj_name = get_proj(path_info)
        if http_accept and 'text/html' in http_accept:
            start_response('301 Redirect', [
                ('Location', '/%s/' % proj_name),
            ])
            return []
        return self.application(environ, start_response)


app = assemble_WSGI_git_app(content_path=get_repo_root())
app = WebRedirect(app)
app = HTTPAuth(app, DOUBAN_REALM, authfunc, BasicAuth)
 def _path(self, name):
     return os.path.join(get_repo_root(), "%s.git" % name)
 def _path_work_tree(self, name):
     return os.path.join(get_repo_root(), "%s.work_tree" % name)
Exemple #33
0
    select.poll = get_original('select', 'poll')
except AttributeError:
    select.poll = get_original('select', 'kqueue')
subprocess.Popen = get_original('subprocess', 'Popen')

from sina import Sina
from sina.config import DEFAULT_CONFIG

from vilya.config import DEVELOP_MODE
from vilya.libs.permdir import get_repo_root
from vilya.models.project import CodeDoubanProject
from vilya.models.gist import Gist
from vilya.models.user import User

DOUBAN_REALM = "douban wsgi basic auth"
DEFAULT_CONFIG['project_root'] = get_repo_root()
app = Sina(DEFAULT_CONFIG)


# @app.get_repo_path
def get_repo_path_handler(environ, path):
    return ''


# @app.before_request
def before_request_handler(environ):
    return


@app.has_permission
def has_permission_handler(environ, path, perm):
Exemple #34
0
import os
import select
import subprocess
from wsgiauth.basic import BasicAuth

from sina import Sina
from sina.config import DEFAULT_CONFIG

from vilya.config import DEVELOP_MODE
from vilya.libs.permdir import get_repo_root
from vilya.models.project import CodeDoubanProject
from vilya.models.gist import Gist
from vilya.models.user import User

DOUBAN_REALM = "douban wsgi basic auth"
DEFAULT_CONFIG['project_root'] = get_repo_root()
app = Sina(DEFAULT_CONFIG)


# @app.get_repo_path
def get_repo_path_handler(environ, path):
    return ''


# @app.before_request
def before_request_handler(environ):
    return


@app.has_permission
def has_permission_handler(environ, path, perm):
Exemple #35
0
 def create_git_repo(cls, git_path):
     git_path = os.path.join(get_repo_root(), git_path)
     #check_call(['git', 'init', '--bare', git_path])
     gyt.repo(git_path, init=True)
Exemple #36
0
 def repo_root_path(self):
     return get_repo_root()
Exemple #37
0
    import select
    select.poll = get_original('select', 'poll')
    import subprocess
    subprocess.Popen = get_original('subprocess', 'Popen')
except ImportError:
    print 'You need install gevent manually! System shutdown.'

from binascii import hexlify
from maria import Maria
from maria.config import config
from vilya.libs.permdir import get_repo_root
from vilya.models.sshkey import SSHKey
from vilya.models.project import CodeDoubanProject as Project
from vilya.models.gist import Gist

config.project_root = get_repo_root()
config.log_file = None
config.host_key_path = './host.key'

app = Maria(config=config)


@app.get_environ
def get_environ_handler(user, path):
    return {'CODE_REMOTE_USER': user}


@app.has_permission
def has_permission_handler(username, path, perm):
    if not username or not path:
        return False
Exemple #38
0
import shutil
from os.path import join

from vilya.libs.permdir import get_repo_root
from vilya.libs.store import store
from vilya.models.project import CodeDoubanProject as Project
from vilya.models.pull import PullRequest
from vilya.models.ticket import Ticket

from tests.utils import clone

from local_config import DOMAIN

p1_name = "project1"
p1_id = None
p1_path = os.path.join(get_repo_root(), "%s.git" % p1_name)
shutil.rmtree(p1_path, ignore_errors=True)
p1 = Project.get_by_name(p1_name)
if p1:
    p1_id = p1.id
    p1.delete()

p2_name = "project2"
p2_id = None
p2_path = os.path.join(get_repo_root(), "%s.git" % p2_name)
shutil.rmtree(p2_path, ignore_errors=True)
p2 = Project.get_by_name(p2_name)
if p2:
    p2_id = p2.id
    p2.delete()
Exemple #39
0
 def create_git_repo(cls, git_path):
     git_path = os.path.join(get_repo_root(), git_path)
     #check_call(['git', 'init', '--bare', git_path])
     gyt.repo(git_path, init=True)
 def _path_for_clone(self, name):
     return os.path.join(get_repo_root(), '%s.clone' % name)
Exemple #41
0
 def repo_path(self):
     return os.path.join(get_repo_root(), '%s.git' % self.name)
Exemple #42
0
 def _path_work_tree(self, name):
     path = os.path.join(get_repo_root(), '%s.work_tree' % name)
     shutil.rmtree(path, ignore_errors=True)
     return path
Exemple #43
0
 def _path_work_tree(self, name):
     return os.path.join(get_repo_root(), '%s.work_tree' % name)
Exemple #44
0
def init_gist_folder():
    GISTS_PATH = os.path.join(get_repo_root(), 'gist')
    if not os.path.exists(GISTS_PATH):
        os.makedirs(GISTS_PATH)
Exemple #45
0
        path_info = environ['PATH_INFO']
        environ['GIT_PATH_INFO'] = get_git_path_info(path_info)
        if environ.get('REMOTE_USER') is None:
            result = self.authenticate(environ)
            if not isinstance(result, str):
                # Request credentials if authentication fails
                return result(environ, start_response)
            environ['REMOTE_USER'] = result
            environ['AUTH_TYPE'] = self.scheme
        return self.application(environ, start_response)


class WebRedirect(object):
    def __init__(self, application, **kw):
        self.application = application

    def __call__(self, environ, start_response):
        http_accept = environ.get('HTTP_ACCEPT')
        path_info = environ.get('PATH_INFO')
        proj_name = get_proj(path_info)
        if http_accept and 'text/html' in http_accept:
            start_response('301 Redirect',
                           [('Location', '/%s/' % proj_name), ])
            return []
        return self.application(environ, start_response)


app = assemble_WSGI_git_app(content_path=get_repo_root())
app = WebRedirect(app)
app = HTTPAuth(app, DOUBAN_REALM, authfunc, BasicAuth)
Exemple #46
0
 def repo_root_path(self):
     return get_repo_root()
Exemple #47
0
 def _path_work_tree(self, name):
     path = os.path.join(get_repo_root(), '%s.work_tree' % name)
     shutil.rmtree(path, ignore_errors=True)
     return path