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.
This commit is contained in:
Lephenixnoir 2024-08-08 17:50:28 +02:00
parent c3b6148d34
commit 416564d40a
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -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"):