Commit 32d77f58 authored by Dominik Woiwode's avatar Dominik Woiwode
Browse files

Fix order of git commands an add return code to ensure .git-folder is created

parent 3ad59355
......@@ -24,8 +24,19 @@ class Config:
PRELIMINARY_MAIL_RECEIVER = [MailParticipant("fr@finf.uni-hannover.de", "Fachrat Informatik Hannover")]
# Grav
GRAV_PROTOCOL_PATH = "pages/fachrat/02.protokolle/"
IGNORED_TOPS = ["Anwesende", "Ständiges", "Termine", "Mitteilungen/Verschiedenes", "Schluss"]
GRAV_PROTOCOL_PATH = "pages/02.fachrat/04.protokolle/"
IGNORED_TOPS = [
"Anwesende",
"Ständiges",
"Termine",
"Mitteilungen/Verschiedenes",
"Schluss",
"Feststellung der Beschlussfähigkeit",
"Genehmigung der Tagesordnung",
"Genehmigung des letzten Protokolls",
"Wahl der Sitzungsleitung",
"Wahl des Protokollanten",
]
# Git
GIT_REPO = "https://git.finf.uni-hannover.de/fachrat-informatik/website.git"
......@@ -44,6 +55,7 @@ class Config:
raise RuntimeError("Git is not configured correctly")
self._git = pterClasses.GitHelper(self.GIT_REPO, self.GIT_REPO_PATH)
self._git.forcePull()
self._git.config(self.GIT_EMAIL, self.GIT_NAME)
self._git.update()
return self._git
......@@ -42,11 +42,11 @@ class Semester:
if os.path.exists(self.gravPath):
return
git = opt.git
os.makedirs(str(Path(self.gravPath).parent), exist_ok=True)
with open(self.gravPath, "w") as d:
d.write(f"---\ntitle: {self.displayName}\n---")
git = opt.git
git.add(opt.GRAV_PROTOCOL_PATH)
git.commit(f"Added {self.part.value} {self.year}")
git.push()
......@@ -233,8 +233,7 @@ class ProtocolPad(BasePad):
if ignore:
continue
linesNew.append(l)
"\n".join(linesNew)
return
return "\n".join(linesNew)
def sendMailAsPreliminary(self) -> bool:
sender = MailParticipant(opt.LDAP_MAIL, opt.MAIL_DISPLAY_NAME)
......
......@@ -90,37 +90,41 @@ class GitHelper:
def config(self, email, name):
cmd = f'git -C {self.repository_path} config user.name {name}'
os.system(cmd)
ret = os.system(cmd)
if ret != 0:
return ret
cmd = f'git -C {self.repository_path} config user.email {email}'
os.system(cmd)
return os.system(cmd)
def clone(self):
cmd = f'git clone {self.repository} {self.repository_path}'
os.system(cmd)
return os.system(cmd)
def forcePull(self):
cmd = f'git -C {self.repository_path} fetch origin master'
os.system(cmd)
ret = os.system(cmd)
if ret != 0:
return ret
cmd = f'git -C {self.repository_path} reset --hard origin/master'
os.system(cmd)
return os.system(cmd)
def update(self):
if os.path.exists(os.path.join(self.repository_path, "/.git")):
self.forcePull()
return self.forcePull()
else:
self.clone()
return self.clone()
def add(self, file: str):
cmd = f'git -C {self.repository_path} add {file}'
os.system(cmd)
return os.system(cmd)
def commit(self, msg: str):
cmd = f'git -C {self.repository_path} commit -m \"{msg}\"'
os.system(cmd)
return os.system(cmd)
def push(self):
cmd = f'git -C {self.repository_path} push origin master'
os.system(cmd)
return os.system(cmd)
class SemesterPart(Enum):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment