From 416564d40a13c7f1372adcdf4ed564cc2f72035d Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Thu, 8 Aug 2024 17:50:28 +0200 Subject: [PATCH] giteapc: allow GiteaPC files to be in .giteapc instead of root (#8) The only change is that giteapc.make must explicitly include .giteapc/giteapc-config.make and not giteapc-config.make, as the makefile still runs in the root folder. --- giteapc/repos.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/giteapc/repos.py b/giteapc/repos.py index 5665d09..b896f41 100644 --- a/giteapc/repos.py +++ b/giteapc/repos.py @@ -57,7 +57,11 @@ class LocalRepo: self.owner, self.name = fullname.split("/") self.folder = REPO_FOLDER + "/" + fullname self.remote = False - self.makefile = self.folder + "/giteapc.make" + + if os.path.exists(self.folder + "/.giteapc/giteapc.make"): + self.makefile = self.folder + "/.giteapc/giteapc.make" + else: + self.makefile = self.folder + "/giteapc.make" @staticmethod def path(fullname): @@ -159,16 +163,17 @@ class LocalRepo: command = "make" with ChangeDirectory(self.folder): - return run([command, "-f", "giteapc.make", target], env=env) + return run([command, "-f", self.makefile, target], env=env) def configs(self): RE_NAME = re.compile(r'giteapc-config-(.*)\.make') files = glob.glob(self.folder + "/giteapc-config-*.make") + files += glob.glob(self.folder + "/.giteapc/giteapc-config-*.make") return sorted(RE_NAME.match(os.path.basename(x))[1] for x in files) def set_config(self, config): - source = self.folder + f"/giteapc-config.make" - target = self.folder + f"/giteapc-config-{config}.make" + source = os.path.dirname(self.makefile) + f"/giteapc-config.make" + target = os.path.dirname(self.makefile) + f"/giteapc-config-{config}.make" if config == "": if os.path.islink(source): @@ -191,7 +196,7 @@ class LocalRepo: RE_METADATA = re.compile(r'^\s*#\s*giteapc\s*:\s*(.*)$') metadata = dict() - with open(self.folder + "/giteapc.make", "r") as fp: + with open(self.makefile, "r") as fp: makefile = fp.read() for line in makefile.split("\n"):