mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
support git@gitlab.com: style URLs in servergitmirrors
This converts the git@gitlab.com SSH URLs to the proper HTTPS URLs that fdroidclient can directly use.
This commit is contained in:
parent
183ce9541b
commit
5cc15d0fa9
2 changed files with 23 additions and 15 deletions
|
|
@ -519,30 +519,38 @@ def extract_pubkey():
|
|||
return hexlify(pubkey), repo_pubkey_fingerprint
|
||||
|
||||
|
||||
# Get raw URL from git service for mirroring
|
||||
def get_raw_mirror(url):
|
||||
# Divide urls in parts
|
||||
url = url.split("/")
|
||||
'''Get direct URL from git service for use by fdroidclient
|
||||
|
||||
# Get the hostname
|
||||
hostname = url[2]
|
||||
Via 'servergitmirrors', fdroidserver can create and push a mirror
|
||||
to certain well known git services like gitlab or github. This
|
||||
will always use the 'master' branch since that is the default
|
||||
branch in git.
|
||||
|
||||
# fdroidserver will use always 'master' branch for git-mirroring
|
||||
'''
|
||||
|
||||
if url.startswith('git@'):
|
||||
url = re.sub(r'^git@(.*):(.*)', r'https://\1/\2', url)
|
||||
|
||||
segments = url.split("/")
|
||||
hostname = segments[2]
|
||||
branch = "master"
|
||||
folder = "fdroid"
|
||||
|
||||
if hostname == "github.com":
|
||||
# Github like RAW url "https://raw.githubusercontent.com/user/repo/master/fdroid"
|
||||
url[2] = "raw.githubusercontent.com"
|
||||
url.extend([branch, folder])
|
||||
# Github like RAW segments "https://raw.githubusercontent.com/user/repo/master/fdroid"
|
||||
segments[2] = "raw.githubusercontent.com"
|
||||
segments.extend([branch, folder])
|
||||
elif hostname == "gitlab.com":
|
||||
# Gitlab like RAW url "https://gitlab.com/user/repo/raw/master/fdroid"
|
||||
url.extend(["raw", branch, folder])
|
||||
# Gitlab like RAW segments "https://gitlab.com/user/repo/raw/master/fdroid"
|
||||
segments.extend(["raw", branch, folder])
|
||||
else:
|
||||
return None
|
||||
|
||||
url = "/".join(url)
|
||||
return url
|
||||
if segments[4].endswith('.git'):
|
||||
segments[4] = segments[4][:-4]
|
||||
|
||||
return '/'.join(segments)
|
||||
|
||||
|
||||
class VerificationException(Exception):
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import hashlib
|
|||
import os
|
||||
import paramiko
|
||||
import pwd
|
||||
import re
|
||||
import subprocess
|
||||
from argparse import ArgumentParser
|
||||
import logging
|
||||
|
|
@ -235,9 +236,8 @@ def update_servergitmirrors(servergitmirrors, repo_section):
|
|||
|
||||
repo = git.Repo.init(repo_dir)
|
||||
|
||||
# take care of each mirror
|
||||
for mirror in servergitmirrors:
|
||||
hostname = mirror.split("/")[2]
|
||||
hostname = re.sub(r'\W*\w+\W+(\w+).*', r'\1', mirror)
|
||||
repo.create_remote(hostname, mirror)
|
||||
logging.info('Mirroring to: ' + mirror)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue