def __init__(self, name, user):
self.name = name
self.owner_id = user.id
# create the master branch
new_branch = application.branches.Branch('master', self, None, user)
db.session.add(new_branch)
db.session.commit()
# updating branch's self reference
new_branch.origin_id = new_branch.id
db.session.commit()
# create folder for resources
os.makedirs(join('repos', name, '_resources'))
os.makedirs(join('repos', name, '_resources/original'))
os.makedirs(join('repos', name, '_resources/low_resolution'))
os.makedirs(join('repos', name, '_resources/thumbnail'))
# create the repository in the filesystem
repo_path = join('repos', name, 'master/source')
os.makedirs(repo_path)
os.symlink(os.path.abspath(join('repos', name, '_resources',
'low_resolution')),
os.path.abspath(join('repos', name,
'master/source/_resources/')))
git.Repo.init(repo_path)
repo = git.Repo(repo_path)
application.branches.config_repo(repo, user.username, user.email)
copyfile('empty_repo/source/index.rst', join(repo_path, 'index.rst'))
copyfile('empty_repo/.gitignore', join(repo_path, '.gitignore'))
repo.index.add(['index.rst', '.gitignore'])
author = git.Actor(user.username, user.email)
repo.index.commit(_('Initial commit'), author=author)
new_branch.build(timeout=30)
评论列表
文章目录