diff mbox

[core] lib/oelite/baker.py: fix MANIFEST_ORIGIN_SRCURI if ssh protocol is implicit

Message ID 1384799896-28321-2-git-send-email-jabk@prevas.dk
State Changes Requested
Delegated to: Esben Haabendal
Headers show

Commit Message

Jacob Kjaergaard Nov. 18, 2013, 6:38 p.m. UTC
From: Jacob Kjaergaard <jacob.kjaergaard@prevas.dk>

git clone will interpret git@git.mygitserver.org:mygit.git as ssh if it
exist. This commits fixes implicitly given ssh protocol.
This is not error prone. If a @ is not given git may prompt for username, but it
fixes more cases.
---
 lib/oelite/baker.py |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Esben Haabendal Nov. 18, 2013, 9:05 p.m. UTC | #1
jabk@prevas.dk writes:

> From: Jacob Kjaergaard <jacob.kjaergaard@prevas.dk>
>
> git clone will interpret git@git.mygitserver.org:mygit.git as ssh if it
> exist. This commits fixes implicitly given ssh protocol.
> This is not error prone. If a @ is not given git may prompt for username, but it
> fixes more cases.
> ---
>  lib/oelite/baker.py |    7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/lib/oelite/baker.py b/lib/oelite/baker.py
> index dfb99d2..8243902 100644
> --- a/lib/oelite/baker.py
> +++ b/lib/oelite/baker.py
> @@ -201,6 +201,13 @@ class OEliteBaker:
>                  if url.startswith('%s://'%(protocol)):
>                      srcuri = 'git://%s'%(url[len(protocol)+3:])
>                      break
> +                if protocol == 'ssh':
> +                    index = url.find('@');
> +                    if index > 0:
> +                        srcuri = 'git://%s'%(
> +                            url.replace(':/','/').replace(':','/')
> +                            )
> +                        break

This check should be done after the for loop, not in it.

The actual url syntax we should support is:

   [user@]host.xz:path/to/repo.git/

So checking for a '@' in the url does not cover the use case where
'user@' is not included.

So perhaps just let the current for loop run to an end, and if nothing
matched, do some kind of sanity checking and if it looks okay, convert
the colon thingy.

>          self.config.set('MANIFEST_ORIGIN_URL', url)
>          self.config.set_flag('MANIFEST_ORIGIN_URL', 'nohash', True)
>          if srcuri is None:

/Esben
christian.braunersorensen@prevas.dk March 4, 2014, 11:20 a.m. UTC | #2
Hi Jakob

Any updates on the below patch?

/Christian
diff mbox

Patch

diff --git a/lib/oelite/baker.py b/lib/oelite/baker.py
index dfb99d2..8243902 100644
--- a/lib/oelite/baker.py
+++ b/lib/oelite/baker.py
@@ -201,6 +201,13 @@  class OEliteBaker:
                 if url.startswith('%s://'%(protocol)):
                     srcuri = 'git://%s'%(url[len(protocol)+3:])
                     break
+                if protocol == 'ssh':
+                    index = url.find('@');
+                    if index > 0:
+                        srcuri = 'git://%s'%(
+                            url.replace(':/','/').replace(':','/')
+                            )
+                        break
         self.config.set('MANIFEST_ORIGIN_URL', url)
         self.config.set_flag('MANIFEST_ORIGIN_URL', 'nohash', True)
         if srcuri is None: