[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#852210: Normalize VCS-Browser and VCS-Git URLs



Package: tracker.debian.org
Severity: normal
Tags: patch

Looking at the discussion on d-d@l.d.o
  https://lists.debian.org/debian-devel/2017/01/thrd2.html#00573
  https://lists.debian.org/debian-devel/2017/01/msg00573.html

I realize this kind of new URL is best spread by using lintian and
popular web service ;-)

Since I like python more, I wrote a proof-of-concept patch to convert
URLs to preferred ones for tracker.

Maybe we need to do the same for https://packages.qa.debian.org and
lintian.  (But they are Perl  ... )

Code is simple but as of now, untested ... but intent should be clear.

Osamu
>From 25b5789b72669ca34d8adccac23b683659ad5a3b Mon Sep 17 00:00:00 2001
From: Osamu Aoki <osamu@debian.org>
Date: Sun, 22 Jan 2017 22:22:34 +0900
Subject: [PATCH] normalize URLs for alioth git

---
 distro_tracker/core/utils/packages.py | 38 +++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/distro_tracker/core/utils/packages.py b/distro_tracker/core/utils/packages.py
index abceb59..f92a555 100644
--- a/distro_tracker/core/utils/packages.py
+++ b/distro_tracker/core/utils/packages.py
@@ -67,6 +67,44 @@ def extract_vcs_information(stanza):
         elif key.startswith('vcs-'):
             vcs['type'] = key[4:]
             vcs['url'] = value
+    # Normalize old alioth git browser URLs for git (https:// -> https://)
+    #   OLD: https://anonscm.debian.org/gitweb/?p=<repository>.git
+    #   OLD: https://anonscm.debian.org/cgit/<repository>.git
+    #   NEW: https://anonscm.debian.org/git/<repository>.git
+    if   vcs['browser'][:36] == 'http://anonscm.debian.org/gitweb/?p=':
+        vcs['browser'] = 'https://anonscm.debian.org/git/' + vcs['browser'][36:]
+    elif vcs['browser'][:37] == 'https://anonscm.debian.org/gitweb/?p=':
+        vcs['browser'] = 'https://anonscm.debian.org/git/' + vcs['browser'][37:]
+    elif vcs['browser'][:31] == 'http://anonscm.debian.org/cgit/':
+        vcs['browser'] = 'https://anonscm.debian.org/git/' + vcs['browser'][31:]
+    elif vcs['browser'][:32] == 'https://anonscm.debian.org/cgit/':
+        vcs['browser'] = 'https://anonscm.debian.org/git/' + vcs['browser'][32:]
+    elif vcs['browser'][:30] == 'http://anonscm.debian.org/git/':
+        vcs['browser'] = 'https://anonscm.debian.org/git/' + vcs['browser'][30:]
+    # Normalize old git clone URLs to new URL accessible by anyone
+    #   OLD: http://anonscm.debian.org/git/<repository>.git
+    #   OLD: git://anonscm.debian.org/git/<repository>.git
+    #   OLD: ssh+git://anonscm.debian.org/git/<repository>.git
+    #   OLD: git+ssh://anonscm.debian.org/git/<repository>.git
+    #   OLD: ssh://git.debian.org/<repository>.git
+    #   OLD: ssh+git://git.debian.org/<repository>.git
+    #   OLD: git+ssh://git.debian.org/<repository>.git
+    #   NEW: https://anonscm.debian.org/git/<repository>.git
+    if vcs['type'] == 'git':
+        if   vcs['url'][:30] == 'http://anonscm.debian.org/git/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][30:]
+        elif vcs['url'][:29] == 'git://anonscm.debian.org/git/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][29:]
+        elif vcs['url'][:33] == 'git+ssh://anonscm.debian.org/git/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][33:]
+        elif vcs['url'][:33] == 'ssh+git://anonscm.debian.org/git/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][33:]
+        elif vcs['url'][:21] == 'ssh://git.debian.org/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][21:]
+        elif vcs['url'][:25] == 'git+ssh://git.debian.org/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][25:]
+        elif vcs['url'][:25] == 'ssh+git://git.debian.org/':
+            vcs['url'] = 'https://anonscm.debian.org/git/' + vcs['url'][25:]
     return vcs
 
 
-- 
2.11.0


Reply to: