diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2021-09-20 20:19:37 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2021-09-20 20:19:37 -0300 |
commit | 95e4381784a10ba5f144df6ab5396cb868a8bcb1 (patch) | |
tree | ff3f186202215a889640929d2cdf5f609507a817 | |
parent | 2b96f8d9b2cba1fdb0daff8c145199c88d2806b7 (diff) |
Do not put symlinks in site-dir
This requires manual intervention: the htmlgdump cache needs to be cleared!
-rwxr-xr-x | git-hooks/post-receive | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/git-hooks/post-receive b/git-hooks/post-receive index e3db9dd..93970e8 100755 --- a/git-hooks/post-receive +++ b/git-hooks/post-receive @@ -152,6 +152,9 @@ changes = [GitChange(*l.rstrip("\n").split(" ", 2)) for l in sys.stdin] gen_dir = pathlib.Path(CACHE_HOME) / name / "gen" gen_dir.mkdir(parents=True,exist_ok=True) +build_dir = pathlib.Path(CACHE_HOME) / name / "build" +build_dir.mkdir(parents=True,exist_ok=True) + todocommits = set() print("updating refs") @@ -159,15 +162,18 @@ print("updating refs") # build changed refs for c in changes: path = gen_dir / c.ref_name + linkpath = build_dir / c.ref_name if c.deleting: try: shutil.rmtree(path) + shutil.rmtree(linkpath) except FileNotFoundError: pass else: path.mkdir(parents=True,exist_ok=True) + linkpath.mkdir(parents=True,exist_ok=True) index = path / "index.html" - link = path / "tree" + link = linkpath / "tree" tree = gen_dir / "trees" / str(repo[c.new_value].tree_id) with index.open("w") as f: # TODO @@ -183,9 +189,11 @@ print("generating refs") for ref in repo.references: ref = repo.references.get(ref) path = gen_dir / ref.name + linkpath = build_dir / ref.name path.mkdir(parents=True,exist_ok=True) + linkpath.mkdir(parents=True,exist_ok=True) index = path / "index.html" - link = path / "tree" + link = linkpath / "tree" tree = gen_dir / "trees" / str(ref.peel(pygit2.Commit).tree_id) try: f = index.open("x") @@ -207,9 +215,11 @@ print("generating commits") while todocommits: c = todocommits.pop() path = gen_dir / "commits" / str(c.id) + linkpath = build_dir / "commits" / str(c.id) path.mkdir(parents=True,exist_ok=True) + linkpath.mkdir(parents=True,exist_ok=True) index = path / "index.html" - link = path / "tree" + link = linkpath / "tree" tree = gen_dir / "trees" / str(c.tree_id) try: f = index.open("x") @@ -236,7 +246,9 @@ print("generating trees") while todotrees: t = todotrees.pop() path = gen_dir / "trees" / str(t.id) + linkpath = build_dir / "trees" / str(t.id) path.mkdir(parents=True,exist_ok=True) + linkpath.mkdir(parents=True,exist_ok=True) index = path / "index.html" try: f = index.open("x") @@ -257,7 +269,7 @@ while todotrees: if linkname == "index.html": linkname = str(t.id) + "_index.html" quoted = quote(linkname, safe='') - link = path / linkname + link = linkpath / linkname if isinstance(obj, pygit2.Blob): blobmeta = todoblobs.setdefault(obj, []) blobmeta += [(obj.filemode, obj.name)] @@ -326,19 +338,10 @@ with path.open("w") as f: f.write("<li><a href=\"./{}\">{}</a></li>".format(quoted, quoted)) f.write("</ul></body></html>") -print("preparing build") - -# CANNOT use shutil.copytree - it is broken. -# also need to be aware of copying into a directory, so we just always make it -# a directory. -build_dir = pathlib.Path(CACHE_HOME) / name / "build" -build_dir.mkdir(parents=True,exist_ok=True) -subprocess.run(["cp", "-R", "-P", *gen_dir.glob("*"), build_dir], check=True) - print("running soupault") -# run soupault on it. note that soupault currently follows symlinks. -# FIXME: don't put symlinks in the site dir +# run soupault on it. note that soupault currently follows symlinks, but we +# workaround it. subprocess.run( [ soupault, |