Parent: [b67bc4] (diff)

Child: [61625d] (diff)

Download this file

repo_tasks.py    46 lines (39 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import shutil
from pylons import c
from allura.lib.decorators import task
from allura.lib.repository import RepositoryApp
@task
def init(**kwargs):
from allura import model as M
c.app.repo.init()
M.Notification.post_user(
c.user, c.app.repo, 'created',
text='Repository %s/%s created' % (
c.project.shortname, c.app.config.options.mount_point))
@task
def clone(
cloned_from_path,
cloned_from_name,
cloned_from_url):
from allura import model as M
c.app.repo.init_as_clone(
cloned_from_path,
cloned_from_name,
cloned_from_url)
M.Notification.post_user(
c.user, c.app.repo, 'created',
text='Repository %s/%s created' % (
c.project.shortname, c.app.config.options.mount_point))
@task
def refresh(**kwargs):
c.app.repo.refresh()
@task
def uninstall(**kwargs):
from allura import model as M
repo = c.app.repo
if repo is not None:
shutil.rmtree(repo.full_fs_path, ignore_errors=True)
repo.delete()
M.MergeRequest.query.remove(dict(
app_config_id=c.app.config._id))
super(RepositoryApp, c.app).uninstall(c.project)