mirror of https://git.sr.ht/~sircmpwn/hub.sr.ht
Return an error when trying to clone a project
-- >8 -- nabijaczleweli@tarta:~/uwu/git$ strace -f -o ss git clone http://127.0.0.1:5014/~nabijaczleweli/projeq Cloning into 'projeq'... fatal: remote error: This is a sourcehat project, which amalgamates multiple source repositories, issue trackers, and mailing lists. You can visit http://127.0.0.1:5014/~nabijaczleweli/projeq/sources to pick a specific source. nabijaczleweli@tarta:~/uwu/git$ -- >8 -- Returning a non-ERR here and going down to a pack is possible (confer https://twitter.com/nabijaczleweli/status/1296062752516079617) but errors later down the line are either more verbose and hint at implementation errors, or leave repositories in a sticky state. Ref: ~sircmpwn/hub.sr.ht#49
This commit is contained in:
parent
4d009f9c9a
commit
b2f59c803b
|
@ -1,6 +1,6 @@
|
|||
import re
|
||||
from sqlalchemy import or_
|
||||
from flask import Blueprint, render_template, request, redirect, url_for
|
||||
from flask import Blueprint, Response, render_template, request, redirect, url_for, abort
|
||||
from flask import session
|
||||
from hubsrht.decorators import adminrequired
|
||||
from hubsrht.projects import ProjectAccess, get_project
|
||||
|
@ -8,13 +8,31 @@ from hubsrht.services import git, hg
|
|||
from hubsrht.types import Feature, Event, EventType
|
||||
from hubsrht.types import Project, RepoType, Visibility
|
||||
from hubsrht.types import SourceRepo, MailingList, Tracker
|
||||
from srht.config import cfg, get_origin
|
||||
from srht.database import db
|
||||
from srht.flask import paginate_query
|
||||
from srht.flask import csrf_bypass, paginate_query
|
||||
from srht.oauth import current_user, loginrequired
|
||||
from srht.validation import Validation, valid_url
|
||||
|
||||
projects = Blueprint("projects", __name__)
|
||||
|
||||
site_name = cfg("sr.ht", "site-name")
|
||||
ext_origin = get_origin("hub.sr.ht", external=True)
|
||||
clone_message = lambda owner, project: f"""
|
||||
|
||||
You have tried to clone a project from {site_name}, but you probably meant to
|
||||
clone a specific git repository for this project instead. A single project on
|
||||
{site_name} often has more than one git repository.
|
||||
|
||||
You can visit the following URL:
|
||||
|
||||
{ext_origin}{url_for("sources.sources_GET",
|
||||
owner=owner.canonical_name, project_name=project.name)}
|
||||
|
||||
To the browse source repositories for this project.
|
||||
|
||||
"""
|
||||
|
||||
@projects.route("/<owner>/<project_name>/")
|
||||
def summary_GET(owner, project_name):
|
||||
owner, project = get_project(owner, project_name, ProjectAccess.read)
|
||||
|
@ -52,6 +70,19 @@ def summary_GET(owner, project_name):
|
|||
summary=summary, summary_error=summary_error,
|
||||
events=events, EventType=EventType)
|
||||
|
||||
@projects.route("/<owner>/<project_name>/info/refs")
|
||||
def summary_refs(owner, project_name):
|
||||
if request.args.get("service") == "git-upload-pack":
|
||||
owner, project = get_project(owner, project_name, ProjectAccess.read)
|
||||
msg = clone_message(owner, project)
|
||||
|
||||
return Response(f"""001e# service=git-upload-pack
|
||||
000000400000000000000000000000000000000000000000 HEAD\0agent=hubsrht
|
||||
{'{:04x}'.format(4 + 3 + 1 + len(msg))}ERR {msg}0000""",
|
||||
mimetype="application/x-git-upload-pack-advertisement")
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
@projects.route("/<owner>/<project_name>/feed")
|
||||
def feed_GET(owner, project_name):
|
||||
owner, project = get_project(owner, project_name, ProjectAccess.read)
|
||||
|
|
Loading…
Reference in New Issue