roundabout,
created on Monday, 4 December 2023, 19:28:26 (1701718106),
received on Wednesday, 31 July 2024, 06:54:38 (1722408878)
Author identity: vlad <vlad.muntoiu@gmail.com>
c0bf2abded0fa17b0a4a5413e2e0a6691c194066
app.py
@@ -438,18 +438,26 @@ def repositoryTree(username, repository, branch, subpath):
if branch.startswith("tag:"):
ref = f"tags/{branch[4:]}"
if branch.startswith("~"):
elif branch.startswith("~"):
ref = branch[1:]
else:
ref = f"refs/{branch}"
ref = f"heads/{branch}"
ref = ref.replace("~", "/") # encode slashes for URL support
try:
repo.git.checkout("-f", branch)
repo.git.checkout("-f", ref)
except git.exc.GitCommandError:
return flask.render_template("not-found.html"), 404
branches = repo.heads
allRefs = []
for ref in repo.heads:
allRefs.append((ref, "head"))
for ref in repo.tags:
allRefs.append((ref, "tag"))
if os.path.isdir(os.path.join(serverRepoLocation, subpath)):
files = []
blobs = []
@@ -502,7 +510,7 @@ def repositoryTree(username, repository, branch, subpath):
repository=repository,
files=infos,
subpath=os.path.join("/", subpath),
branches=branches,
branches=allRefs,
current=branch
)
else:
@@ -534,7 +542,7 @@ def repositoryTree(username, repository, branch, subpath):
username=username,
repository=repository,
file=os.path.join(f"/{username}/{repository}/raw/{branch}/", subpath),
branches=branches,
branches=allRefs,
current=branch,
mode=mode,
mimetype=mimetype,
templates/repo-tree.html
@@ -127,10 +127,10 @@
<x-vbox>
<x-buttonbox>
<select id="branch-selection" style="flex: 0 1 auto;">
<option value="branch-{{ current }}" selected>{{ current }}</option>
<option value="ref-{{ current }}" selected>{% if "tag:" in current %}tag:{% endif %}{{ current | replace("~", "/") | replace("tag:", " ") }}</option>
{% for branch in branches %}
{% if branch.name != current %}
<option value="branch-{{ branch.name }}">{{ branch.name }}</option>
{% if branch[0] != current | replace("~", "/") | replace("tag:", " ") %}
<option value="ref-{% if branch[1] == 'tag' %}tag:{% endif %}{{ branch[0] | replace('/', '~') }}">{% if branch[1] == "tag" %}tag: {% endif %}{{ branch[0] }}</option>
{% endif %}
{% endfor %}
<!--<option value="new">[CREATE NEW BRANCH]</option>-->
@@ -143,7 +143,7 @@
if(branchSelect.value == "new") {
document.getElementById("new-branch").showModal();
} else {
const PREFIX = "branch-";
const PREFIX = "ref-";
if(branchSelect.value.startsWith(PREFIX)) {
branch = branchSelect.value.slice(PREFIX.length);
}