From f3c7eac83764076070728a6a79fb8ddffb83b344 Mon Sep 17 00:00:00 2001 From: Karsten Hopp Date: Tue, 5 Jul 2016 14:09:51 +0200 Subject: [PATCH] add a function that takes a string with a dist-git url as parameter and returns a cgit url --- rida/scm.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/rida/scm.py b/rida/scm.py index 81f73b95..134a094c 100644 --- a/rida/scm.py +++ b/rida/scm.py @@ -191,4 +191,21 @@ def get_hash_of_git_master_head_pkgname(pkgname=None): break return ret - +def convert_giturl_to_cgiturl(giturl=None): + """ + dist-pkg giturls are of the form + git://pkgs.fedoraproject.org/rpms/ed?#abc0235d4923930745ef05d873646f361a365457 + cgit urls look like this: + http://pkgs.fedoraproject.org/cgit/rpms/ed.git/commit/?id=abc0235d4923930745ef05d873646f361a365457 + This function takes a string with a dist-git url as parameter and returns a cgit url + """ + if not isinstance(giturl, str): + return '' + try: + url = giturl[giturl.index('://')+3:] + except: + raise RuntimeError('%s is not a dist-git URL' % giturl) + url = url.replace('/rpms/','/cgit/rpms/') + url = url.replace('?#','.git/commit/?id=') + return 'http://' + url +