Commit 0187de7b authored by Jakob Marten's avatar Jakob Marten
Browse files

Git force pull and remove settings again

parent b0670aff
......@@ -118,13 +118,15 @@ class GitHelper:
cmd = f'git clone {self.repository}'
os.system(cmd)
def pull(self):
cmd = f'git -C {self.repository_name} pull origin master'
def forcePull(self):
cmd = f'git -C {self.repository_name} fetch origin master'
os.system(cmd)
cmd = f'git -C {self.repository_name} reset --hard origin/master'
os.system(cmd)
def update(self):
if os.path.exists(self.repository_name+"/.git"):
self.pull()
self.forcePull()
else:
self.clone()
......@@ -166,7 +168,7 @@ class Semester:
def uploadToGrav(self):
if os.path.exists(self.gravPath):
raise FileExistsError(f"{self.gravPath} already exists!")
return
os.makedirs(str(Path(self.gravPath).parent), exist_ok=True)
with open(self.gravPath, "w") as f:
f.write(f"---\ntitle: {self.displayName}\n---")
......@@ -178,13 +180,13 @@ class Semester:
def getSemesterTuple(date: datetime.datetime):
if date.month > 3 and date.month < 10:
# summer
return (str(date.year)[2:], "SS")
return (date.year, "SS")
elif date.month >= 10:
# winter
return (str(date.year)[2:], "WS")
return (date.year, "WS")
else:
# winter
return (str(date.year-1)[2:], "WS")
return (date.year-1, "WS")
# === Source Types ===
......@@ -290,7 +292,7 @@ class ProtocolPad(BasePad):
return f"Protokoll {self.gremium.name} {self.date.strftime('%Y-%m-%d')}" + " - Fachgruppenvollversammlung"*self.isFachgruppenvollversammlung
def DEFAULT_GRAV_PATH(self):
return os.path.join(GIT_REPO_NAME, "pages", "fachrat", "02.protokolle", str(self.year)[2:] + self.part, self.date.strftime("%Y-%m-%d")+"-fgvv"*self.isFachgruppenvollversammlung, "default.de.md")
return os.path.join(GIT_REPO_NAME, "pages", "fachrat", "02.protokolle", str(self.semester.year)[2:] + self.semester.part, self.date.strftime("%Y-%m-%d")+"-fgvv"*self.isFachgruppenvollversammlung, "default.de.md")
def sendMailAsUnapproved(self) -> bool:
sender = MailParticipant(LDAP_MAIL, LDAP_NAME)
......@@ -477,7 +479,7 @@ class PadCollection(BasePad):
def initGit():
global GIT_HELPER
if GIT_REPO == None or GIT_REPO_NAME == None or GIT_EMAIL == None or GIT_NAME != None:
if GIT_REPO == None or GIT_REPO_NAME == None or GIT_EMAIL == None or GIT_NAME == None:
raise RuntimeError("Git is not configured correctly")
GIT_HELPER = GitHelper(GIT_REPO, GIT_REPO_NAME)
GIT_HELPER.config(GIT_EMAIL, GIT_NAME)
......
import linkToPDF2 as pter
pter.DEFAULT_GREMIUM = None
pter.LDAP_USER = None
pter.LDAP_PASSWORD = None
pter.LDAP_MAIL = None
pter.LDAP_NAME = None
pter.GIT_REPO = None
pter.GIT_REPO_NAME = None
pter.GIT_NAME = None
pter.GIT_EMAIL = None
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