Compare commits

...

2 commits

Author SHA1 Message Date
Lephenixnoir
416564d40a
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.
2024-08-08 17:50:28 +02:00
Lephenixnoir
c3b6148d34
show: also show list of configs 2024-08-08 17:49:40 +02:00
2 changed files with 14 additions and 5 deletions

View file

@ -79,6 +79,10 @@ def print_repo(r, branches=None, tags=None, has_giteapc=True):
print(" ->", os.readlink(r.folder)) print(" ->", os.readlink(r.folder))
else: else:
print("") print("")
print(" {W}Configs:{_}".format(**colors()), end="")
for c in r.configs():
print(" " + c, end="")
print("")
branches = r.branches() branches = r.branches()
tags = r.tags() tags = r.tags()

View file

@ -57,7 +57,11 @@ class LocalRepo:
self.owner, self.name = fullname.split("/") self.owner, self.name = fullname.split("/")
self.folder = REPO_FOLDER + "/" + fullname self.folder = REPO_FOLDER + "/" + fullname
self.remote = False 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 @staticmethod
def path(fullname): def path(fullname):
@ -159,16 +163,17 @@ class LocalRepo:
command = "make" command = "make"
with ChangeDirectory(self.folder): 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): def configs(self):
RE_NAME = re.compile(r'giteapc-config-(.*)\.make') RE_NAME = re.compile(r'giteapc-config-(.*)\.make')
files = glob.glob(self.folder + "/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) return sorted(RE_NAME.match(os.path.basename(x))[1] for x in files)
def set_config(self, config): def set_config(self, config):
source = self.folder + f"/giteapc-config.make" source = os.path.dirname(self.makefile) + f"/giteapc-config.make"
target = self.folder + f"/giteapc-config-{config}.make" target = os.path.dirname(self.makefile) + f"/giteapc-config-{config}.make"
if config == "": if config == "":
if os.path.islink(source): if os.path.islink(source):
@ -191,7 +196,7 @@ class LocalRepo:
RE_METADATA = re.compile(r'^\s*#\s*giteapc\s*:\s*(.*)$') RE_METADATA = re.compile(r'^\s*#\s*giteapc\s*:\s*(.*)$')
metadata = dict() metadata = dict()
with open(self.folder + "/giteapc.make", "r") as fp: with open(self.makefile, "r") as fp:
makefile = fp.read() makefile = fp.read()
for line in makefile.split("\n"): for line in makefile.split("\n"):