roundabout,
created on Tuesday, 5 December 2023, 15:14:10 (1701789250),
received on Wednesday, 31 July 2024, 06:54:39 (1722408879)
Author identity: vlad <vlad.muntoiu@gmail.com>
780a99968794c4f6593c5183c46c9d69de152d5b
app.py
@@ -390,8 +390,28 @@ def repositoryRaw(username, repository, branch, subpath):
return flask.render_template("not-found.html"), 404 repo = git.Repo(serverRepoLocation) repoData = Repo.query.filter_by(route=f"/{username}/{repository}").first() if not repoData.defaultBranch: if repo.heads: repoData.defaultBranch = repo.heads[0].name else: return flask.render_template("empty.html", remote=f"http://{config.BASE_DOMAIN}/git/{username}/{repository}"), 200 if not branch: branch = repoData.defaultBranch return flask.redirect(f"./{branch}", code=302) if branch.startswith("tag:"): ref = f"tags/{branch[4:]}" elif branch.startswith("~"): ref = branch[1:] else: ref = f"heads/{branch}" ref = ref.replace("~", "/") # encode slashes for URL supporttry: repo.git.checkout(branch)repo.git.checkout("-f", ref)except git.exc.GitCommandError: return flask.render_template("not-found.html"), 404