You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
712 B
Python
25 lines
712 B
Python
import subprocess
|
|
from pathlib import Path
|
|
from . import log
|
|
|
|
class Repo:
|
|
resource_name = 'git'
|
|
|
|
def __init__(self, label, section):
|
|
self.label = label or None
|
|
self.repo = section['repo']
|
|
self.target = Path(section['target']).expanduser()
|
|
|
|
def run(self):
|
|
if self.target.exists():
|
|
log.debug("target exists")
|
|
if self.target.is_dir():
|
|
log.debug("target is dir")
|
|
git_dir = self.target / ".git"
|
|
if git_dir.exists() and git_dir.is_dir():
|
|
log.debug("target is git repo")
|
|
return
|
|
|
|
cmd = ["git", "clone", self.repo, self.target]
|
|
subprocess.call(cmd)
|