mirror of
https://github.com/Kozea/Radicale.git
synced 2025-06-26 16:45:52 +00:00
Redirect to documentation of default branch
This commit is contained in:
parent
bbfae8c131
commit
1546fb5b8b
1 changed files with 18 additions and 2 deletions
|
@ -98,8 +98,19 @@ def run_git_fetch_and_restart_if_changed(remote_commits, target_branch):
|
||||||
os.execv(__file__, sys.argv)
|
os.execv(__file__, sys.argv)
|
||||||
|
|
||||||
|
|
||||||
|
def make_index_html(branch):
|
||||||
|
return """\
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<meta http-equiv="Refresh" content="0; url=%s.html">
|
||||||
|
<title>Redirect</title>
|
||||||
|
<p>Please follow <a href="%s.html">this link</a>.</p>
|
||||||
|
""" % (branch, branch)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
install_dependencies()
|
if os.environ.get("GITHUB_ACTIONS", "") == "true":
|
||||||
|
install_dependencies()
|
||||||
target_branch, = run_git("rev-parse", "--abbrev-ref", "HEAD")
|
target_branch, = run_git("rev-parse", "--abbrev-ref", "HEAD")
|
||||||
remote_commits = run_git("rev-parse", "--remotes=%s" % REMOTE)
|
remote_commits = run_git("rev-parse", "--remotes=%s" % REMOTE)
|
||||||
run_git_fetch_and_restart_if_changed(remote_commits, target_branch)
|
run_git_fetch_and_restart_if_changed(remote_commits, target_branch)
|
||||||
|
@ -111,16 +122,21 @@ def main():
|
||||||
run_git("rm", "--", path)
|
run_git("rm", "--", path)
|
||||||
with TemporaryDirectory() as temp:
|
with TemporaryDirectory() as temp:
|
||||||
branch_docs = {}
|
branch_docs = {}
|
||||||
for branch in branches:
|
for branch in branches[:]:
|
||||||
checkout(branch)
|
checkout(branch)
|
||||||
if os.path.exists(DOCUMENTATION_SRC):
|
if os.path.exists(DOCUMENTATION_SRC):
|
||||||
branch_docs[branch] = os.path.join(temp, "%s.md" % branch)
|
branch_docs[branch] = os.path.join(temp, "%s.md" % branch)
|
||||||
shutil.copy(DOCUMENTATION_SRC, branch_docs[branch])
|
shutil.copy(DOCUMENTATION_SRC, branch_docs[branch])
|
||||||
|
else:
|
||||||
|
branches.remove(branch)
|
||||||
checkout(target_branch)
|
checkout(target_branch)
|
||||||
for branch, src_path in branch_docs.items():
|
for branch, src_path in branch_docs.items():
|
||||||
to_path = os.path.join(TARGET_DIR, "%s.html" % branch)
|
to_path = os.path.join(TARGET_DIR, "%s.html" % branch)
|
||||||
convert_doc(src_path, to_path, branch, branches)
|
convert_doc(src_path, to_path, branch, branches)
|
||||||
run_git("add", "--", to_path)
|
run_git("add", "--", to_path)
|
||||||
|
if branches:
|
||||||
|
with open(os.path.join(TARGET_DIR, "index.html"), "w") as f:
|
||||||
|
f.write(make_index_html(branches[0]))
|
||||||
with contextlib.suppress(subprocess.CalledProcessError):
|
with contextlib.suppress(subprocess.CalledProcessError):
|
||||||
run_git("diff", "--cached", "--quiet")
|
run_git("diff", "--cached", "--quiet")
|
||||||
print("No changes", file=sys.stderr)
|
print("No changes", file=sys.stderr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue