All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@kernel.crashing.org>
To: yocto@yoctoproject.org
Subject: [layerindex-web] [PATCH 3/3] RFC: editlayer: Be more specific on the searches
Date: Sat, 12 Oct 2019 20:56:33 -0500	[thread overview]
Message-ID: <20191013015633.118339-4-mark.hatle@kernel.crashing.org> (raw)
In-Reply-To: <20191013015633.118339-1-mark.hatle@kernel.crashing.org>

Just because git.yoctoproject.org is in the URL, doesn't mean we can or
should force the vcs_web_url to be a specific value.  If it starts with
git://git.yoctoproject.org then we can do this.  git.openembedded.org
already did this.

This also changes github, gitlab and bitbucket references.

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 layerindex/tools/import_layer.py       |  8 ++++----
 layerindex/tools/import_wiki_layers.py | 13 ++++++++++---
 templates/layerindex/editlayer.html    |  8 ++++----
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/layerindex/tools/import_layer.py b/layerindex/tools/import_layer.py
index 8fcbc15..ace58e5 100755
--- a/layerindex/tools/import_layer.py
+++ b/layerindex/tools/import_layer.py
@@ -36,27 +36,27 @@ def set_vcs_fields(layer, repoval):
         layer.vcs_web_tree_base_url = 'http://cgit.openembedded.org/' + reponame + '/tree/%path%?h=%branch%'
         layer.vcs_web_file_base_url = 'http://cgit.openembedded.org/' + reponame + '/tree/%path%?h=%branch%'
         layer.vcs_web_commit_url = 'http://cgit.openembedded.org/' + reponame + '/commit/?id=%hash%'
-    elif 'git.yoctoproject.org/' in repoval:
+    elif repoval.startswith('git://git.yoctoproject.org/'):
         reponame = re.sub('^.*/', '', repoval)
         layer.vcs_web_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame
         layer.vcs_web_tree_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
         layer.vcs_web_file_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
         layer.vcs_web_commit_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/commit/?id=%hash%'
-    elif 'github.com/' in repoval:
+    elif repoval.startswith('git://github.com/') or repoval.startswith('http://github.com/') or repoval.startswith('https://github.com/'):
         reponame = re.sub('^.*github.com/', '', repoval)
         reponame = re.sub('.git$', '', reponame)
         layer.vcs_web_url = 'http://github.com/' + reponame
         layer.vcs_web_tree_base_url = 'http://github.com/' + reponame + '/tree/%branch%/'
         layer.vcs_web_file_base_url = 'http://github.com/' + reponame + '/blob/%branch%/'
         layer.vcs_web_commit_url = 'http://github.com/' + reponame + '/commit/%hash%'
-    elif 'gitlab.com/' in repoval:
+    elif repoval.startswith('git://gitlab.com/') or repoval.startswith('http://gitlab.com/') or repoval.startswith('https://gitlab.com/'):
         reponame = re.sub('^.*gitlab.com/', '', repoval)
         reponame = re.sub('.git$', '', reponame)
         layer.vcs_web_url = 'http://gitlab.com/' + reponame
         layer.vcs_web_tree_base_url = 'http://gitlab.com/' + reponame + '/tree/%branch%/'
         layer.vcs_web_file_base_url = 'http://gitlab.com/' + reponame + '/blob/%branch%/'
         layer.vcs_web_commit_url = 'http://gitlab.com/' + reponame + '/commit/%hash%'
-    elif 'bitbucket.org/' in repoval:
+    elif repoval.startswith('git://bitbucket.org/') or repoval.startswith('http://bitbucket.org/') or repoval.startswith('https://bitbucket.org/'):
         reponame = re.sub('^.*bitbucket.org/', '', repoval)
         reponame = re.sub('.git$', '', reponame)
         layer.vcs_web_url = 'http://bitbucket.org/' + reponame
diff --git a/layerindex/tools/import_wiki_layers.py b/layerindex/tools/import_wiki_layers.py
index baf0c71..71f26ea 100755
--- a/layerindex/tools/import_wiki_layers.py
+++ b/layerindex/tools/import_wiki_layers.py
@@ -100,20 +100,27 @@ def main():
                             layer.vcs_web_tree_base_url = 'http://cgit.openembedded.org/' + reponame + '/tree/%path%?h=%branch%'
                             layer.vcs_web_file_base_url = 'http://cgit.openembedded.org/' + reponame + '/tree/%path%?h=%branch%'
                             layer.vcs_web_commit_url = 'http://cgit.openembedded.org/' + reponame + '/commit/?id=%hash%'
-                        elif 'git.yoctoproject.org/' in repoval:
+                        elif repoval.startswith('git://git.yoctoproject.org/'):
                             reponame = re.sub('^.*/', '', repoval)
                             layer.vcs_web_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame
                             layer.vcs_web_tree_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
                             layer.vcs_web_file_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
                             layer.vcs_web_commit_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/commit/?id=%hash%'
-                        elif 'github.com/' in repoval:
+                        elif repoval.startswith('git://github.com/') or repoval.startswith('http://github.com/') or repoval.startswith('https://github.com/'):
                             reponame = re.sub('^.*github.com/', '', repoval)
                             reponame = re.sub('.git$', '', reponame)
                             layer.vcs_web_url = 'http://github.com/' + reponame
                             layer.vcs_web_tree_base_url = 'http://github.com/' + reponame + '/tree/%branch%/'
                             layer.vcs_web_file_base_url = 'http://github.com/' + reponame + '/blob/%branch%/'
                             layer.vcs_web_commit_url = 'http://github.com/' + reponame + '/commit/%hash%'
-                        elif 'bitbucket.org/' in repoval:
+                        elif repoval.startswith('git://gitlab.com/') or repoval.startswith('http://gitlab.com/') or repoval.startswith('https://gitlab.com/'):
+                            reponame = re.sub('^.*gitlab.com/', '', repoval)
+                            reponame = re.sub('.git$', '', reponame)
+                            layer.vcs_web_url = 'http://gitlab.com/' + reponame
+                            layer.vcs_web_tree_base_url = 'http://gitlab.com/' + reponame + '/tree/%branch%/'
+                            layer.vcs_web_file_base_url = 'http://gitlab.com/' + reponame + '/blob/%branch%/'
+                            layer.vcs_web_commit_url = 'http://gitlab.com/' + reponame + '/commit/%hash%'
+                        elif repoval.startswith('git://bitbucket.org/') or repoval.startswith('http://bitbucket.org/') or repoval.startswith('https://bitbucket.org/'):
                             reponame = re.sub('^.*bitbucket.org/', '', repoval)
                             reponame = re.sub('.git$', '', reponame)
                             layer.vcs_web_url = 'http://bitbucket.org/' + reponame
diff --git a/templates/layerindex/editlayer.html b/templates/layerindex/editlayer.html
index a06c317..dd95ea3 100644
--- a/templates/layerindex/editlayer.html
+++ b/templates/layerindex/editlayer.html
@@ -204,7 +204,7 @@
             this.vcs_web_commit_url = 'http://cgit.openembedded.org/' + reponame + '/commit/?id=%hash%'
             this.vcs_web_type = 'cgit'
         }
-        else if( repoval.indexOf('git.yoctoproject.org/') > -1 ) {
+        else if( repoval.startsWith('git://git.yoctoproject.org/') ) {
             reponame = repoval.replace(/^.*\//, '')
             this.vcs_web_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame
             this.vcs_web_tree_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%'
@@ -212,7 +212,7 @@
             this.vcs_web_commit_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/commit/?id=%hash%'
             this.vcs_web_type = 'cgit'
         }
-        else if( repoval.indexOf('github.com/') > -1 ) {
+        else if( repoval.startsWith('git://github.com/') ) {
             reponame = repoval.replace(/^.*github.com\//, '')
             reponame = reponame.replace(/.git$/, '')
             this.vcs_web_url = 'http://github.com/' + reponame
@@ -221,7 +221,7 @@
             this.vcs_web_commit_url = 'http://github.com/' + reponame + '/commit/%hash%/'
             this.vcs_web_type = '(custom)'
         }
-        else if( repoval.indexOf('gitlab.com/') > -1 ) {
+        else if( repoval.startsWith('git://gitlab.com/') ) {
             reponame = repoval.replace(/^.*gitlab.com\//, '')
             reponame = reponame.replace(/.git$/, '')
             this.vcs_web_url = 'http://gitlab.com/' + reponame
@@ -230,7 +230,7 @@
             this.vcs_web_commit_url = 'http://gitlab.com/' + reponame + '/commit/%hash%/'
             this.vcs_web_type = '(custom)'
         }
-        else if( repoval.indexOf('bitbucket.org/') > -1 ) {
+        else if( repoval.startsWith('git://bitbucket.org/') ) {
             reponame = repoval.replace(/^.*bitbucket.org\//, '')
             reponame = reponame.replace(/.git$/, '')
             this.vcs_web_url = 'http://bitbucket.org/' + reponame
-- 
2.17.1



  parent reply	other threads:[~2019-10-13  1:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-13  1:56 [layerindex-web] [PATCH 0/3] Some misc changes/fixes Mark Hatle
2019-10-13  1:56 ` [layerindex-web] [PATCH 1/3] layerindex/urls.py: Allow branches with a '.' in the name Mark Hatle
2019-10-13  1:56 ` [layerindex-web] [PATCH 2/3] update.py: Allow bitbake to live in a subdirectory of a repository Mark Hatle
2019-10-13  1:56 ` Mark Hatle [this message]
2019-10-13 20:31 ` [layerindex-web] [PATCH 0/3] Some misc changes/fixes Paul Eggleton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191013015633.118339-4-mark.hatle@kernel.crashing.org \
    --to=mark.hatle@kernel.crashing.org \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.