~edwargix/git.sr.ht

1a045af24ecea64cc6276753bc7c16411e25ebd5 — Thorben Günther 6 years ago 406e590
Parse git user from dispatch string
3 files changed, 11 insertions(+), 4 deletions(-)

M gitsrht-update-hook/submitter.go
M gitsrht/blueprints/repo.py
M gitsrht/urls.py
M gitsrht-update-hook/submitter.go => gitsrht-update-hook/submitter.go +6 -1
@@ 171,7 171,12 @@ func (submitter GitBuildSubmitter) GetCloneUrl() string {
		origin := strings.ReplaceAll(submitter.GitOrigin, "http://", "")
		origin = strings.ReplaceAll(origin, "https://", "")
		// Use SSH URL
		return fmt.Sprintf("git+ssh://git@%s/~%s/%s", origin,
		git_user, ok := config.Get("git.sr.ht::dispatch", "/usr/bin/gitsrht-keys")
		if !ok {
			git_user = "git:git"
		}
		git_user = strings.Split(git_user, ":")[0]
		return fmt.Sprintf("git+ssh://%s@%s/~%s/%s", git_user, origin,
			submitter.OwnerName, submitter.RepoName)
	} else {
		// Use HTTP(s) URL

M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +2 -1
@@ 64,7 64,8 @@ def _highlight_file(repo, ref, name, data, blob_id):

def render_empty_repo(owner, repo):
    origin = cfg("git.sr.ht", "origin")
    urls = get_clone_urls(origin, owner, repo, 'git@{origin}:{user}/{repo}')
    git_user = cfg("git.sr.ht::dispatch", "/usr/bin/gitsrht-keys", "git:git").split(":")[0]
    urls = get_clone_urls(origin, owner, repo, '{git_user}@{origin}:{user}/{repo}')
    return render_template("empty-repo.html", owner=owner, repo=repo,
            clone_urls=urls)


M gitsrht/urls.py => gitsrht/urls.py +3 -2
@@ 1,14 1,15 @@
from flask import url_for
from srht.config import get_origin
from srht.config import cfg, get_origin

def clone_urls(repo):
    """Returns the readonly and read/write URL for a given repo."""
    git_user = cfg("git.sr.ht::dispatch", "/usr/bin/gitsrht-keys", "git:git").split(":")[0]
    base = (get_origin("git.sr.ht", external=True)
        .replace("http://", "")
        .replace("https://", ""))
    return [
        url.format(base, repo.owner.canonical_name, repo.name)
        for url in ["https://{}/{}/{}", "git@{}:{}/{}"]
        for url in ["https://{}/{}/{}", git_user+"@{}:{}/{}"]
    ]

def log_rss_url(repo, ref=None):