|
|
e5b0ac |
|
|
|
e5b0ac |
|
|
|
e5b0ac |
import os
|
|
|
e5b0ac |
import shutil
|
|
|
e5b0ac |
import subprocess
|
|
|
e5b0ac |
|
|
|
e5b0ac |
from repotypes.base import RepotypeBase
|
|
|
e5b0ac |
|
|
|
e5b0ac |
|
|
|
e5b0ac |
class RepotypeGit(RepotypeBase):
|
|
|
e5b0ac |
def __init__(self):
|
|
|
e5b0ac |
super().__init__('GIT')
|
|
|
e5b0ac |
|
|
|
e5b0ac |
def check_config(self, server, config):
|
|
|
e5b0ac |
super().check_config(server, config)
|
|
|
e5b0ac |
config['command'] = server.fixpath(config['command'], root = True)
|
|
|
e5b0ac |
config['command'] = server.fixpath(config['command'], root = True)
|
|
|
e5b0ac |
config['environment'] = server.fixenv(config['environment'])
|
|
|
e5b0ac |
|
|
|
e5b0ac |
def configure(self, server, config):
|
|
|
e5b0ac |
super().configure(server, config)
|
|
|
e5b0ac |
self.command = self.config['command']
|
|
|
e5b0ac |
self.environment = self.config['environment']
|
|
|
e5b0ac |
assert self.command[0] == '/'
|
|
|
e5b0ac |
assert not self.environment is None
|
|
|
e5b0ac |
|
|
|
e5b0ac |
def create(self, subpath):
|
|
|
e5b0ac |
path = self.gen_path(subpath)
|
|
|
e5b0ac |
print(self.name + ': Creating repository by path: ' + path)
|
|
|
e5b0ac |
parentpath = self.parentdir(path)
|
|
|
e5b0ac |
self.mkdir(parentpath)
|
|
|
e5b0ac |
subprocess.run([self.command, 'init', '--bare', path], env = self.environment, cwd = parentpath)
|
|
|
e5b0ac |
subprocess.run([self.command, 'config', 'http.receivepack', 'true'], env = self.environment, cwd = path)
|
|
|
e5b0ac |
|
|
|
e5b0ac |
def delete(self, subpath):
|
|
|
e5b0ac |
path = self.gen_path(subpath)
|
|
|
e5b0ac |
print(self.name + ': Deleting repository by path: ' + path)
|
|
|
e5b0ac |
if os.path.exists(path):
|
|
|
e5b0ac |
shutil.rmtree( self.gen_path(subpath) )
|
|
|
e5b0ac |
|