All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Git fetcher remote fix
@ 2015-05-14 13:33 Paul Eggleton
  2015-05-14 13:33 ` [PATCH 1/2] fetch2/git: ensure the unpacked origin remote points upstream Paul Eggleton
  2015-05-14 13:33 ` [PATCH 2/2] tests/fetch: ensure fetch tests preserve current dir Paul Eggleton
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Eggleton @ 2015-05-14 13:33 UTC (permalink / raw)
  To: bitbake-devel

A minor fix for the git fetcher in aid of OE's devtool, as well as a fix
for a bitbake-selftest issue I noticed at the same time.


The following changes since commit c7263096ba31ba45daeeb9de90c1cb9ebef24a28:

  fetch2: Add BB_ALLOWED_NETWORKS support (2015-05-12 12:17:08 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib paule/fetchfix
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=paule/fetchfix

Paul Eggleton (2):
  fetch2/git: ensure the unpacked origin remote points upstream
  tests/fetch: ensure fetch tests preserve current dir

 lib/bb/fetch2/git.py  | 31 +++++++++++++++++--------------
 lib/bb/tests/fetch.py |  2 ++
 2 files changed, 19 insertions(+), 14 deletions(-)

-- 
2.1.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] fetch2/git: ensure the unpacked origin remote points upstream
  2015-05-14 13:33 [PATCH 0/2] Git fetcher remote fix Paul Eggleton
@ 2015-05-14 13:33 ` Paul Eggleton
  2015-05-14 13:33 ` [PATCH 2/2] tests/fetch: ensure fetch tests preserve current dir Paul Eggleton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2015-05-14 13:33 UTC (permalink / raw)
  To: bitbake-devel

If you're interested in using the checked out repository for development
(e.g. in OE with devtool) then you ideally want the origin remote to
point to the repository it was fetched from, so just set that after
cloning.

(As part of this I did a minor refactor so we have one function to
generate the repository URL, which was already in two places.)

Fixes [YOCTO #7756].

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 lib/bb/fetch2/git.py | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 0fd9bee..4cc5811 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -178,11 +178,6 @@ class Git(FetchMethod):
     def download(self, ud, d):
         """Fetch url"""
 
-        if ud.user:
-            username = ud.user + '@'
-        else:
-            username = ""
-
         ud.repochanged = not os.path.exists(ud.fullmirror)
 
         # If the checkout doesn't exist and the mirror tarball does, extract it
@@ -191,7 +186,7 @@ class Git(FetchMethod):
             os.chdir(ud.clonedir)
             runfetchcmd("tar -xzf %s" % (ud.fullmirror), d)
 
-        repourl = "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
+        repourl = self._get_repo_url(ud)
 
         # If the repo still doesn't exist, fallback to cloning it
         if not os.path.exists(ud.clonedir):
@@ -277,8 +272,10 @@ class Git(FetchMethod):
             clonedir = indirectiondir
 
         runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, cloneflags, clonedir, destdir), d)
+        os.chdir(destdir)
+        repourl = self._get_repo_url(ud)
+        runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, repourl), d)
         if not ud.nocheckout:
-            os.chdir(destdir)
             if subdir != "":
                 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
                 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
@@ -312,6 +309,16 @@ class Git(FetchMethod):
             raise bb.fetch2.FetchError("The command '%s' gave output with more then 1 line unexpectedly, output: '%s'" % (cmd, output))
         return output.split()[0] != "0"
 
+    def _get_repo_url(self, ud):
+        """
+        Return the repository URL
+        """
+        if ud.user:
+            username = ud.user + '@'
+        else:
+            username = ""
+        return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
+
     def _revision_key(self, ud, d, name):
         """
         Return a unique key for the url
@@ -322,13 +329,9 @@ class Git(FetchMethod):
         """
         Run git ls-remote with the specified search string
         """
-        if ud.user:
-            username = ud.user + '@'
-        else:
-            username = ""
-
-        cmd = "%s ls-remote %s://%s%s%s %s" % \
-              (ud.basecmd, ud.proto, username, ud.host, ud.path, search)
+        repourl = self._get_repo_url(ud)
+        cmd = "%s ls-remote %s %s" % \
+              (ud.basecmd, repourl, search)
         if ud.proto.lower() != 'file':
             bb.fetch2.check_network_access(d, cmd)
         output = runfetchcmd(cmd, d, True)
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tests/fetch: ensure fetch tests preserve current dir
  2015-05-14 13:33 [PATCH 0/2] Git fetcher remote fix Paul Eggleton
  2015-05-14 13:33 ` [PATCH 1/2] fetch2/git: ensure the unpacked origin remote points upstream Paul Eggleton
@ 2015-05-14 13:33 ` Paul Eggleton
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggleton @ 2015-05-14 13:33 UTC (permalink / raw)
  To: bitbake-devel

The fetcher calls os.chdir() in a number of places, which can affect
other tests (since the directory it changes into gets deleted) - let's
just put the current directory back to where it was when we're done.

(This fixes bb.tests.Path.test_unsafe_delete_path failing if it was run
as part of a full bitbake-selftest run, where the fetcher tests get to
run before it.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
 lib/bb/tests/fetch.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index d3f7b6a..3575468 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -315,6 +315,7 @@ class URITest(unittest.TestCase):
 class FetcherTest(unittest.TestCase):
 
     def setUp(self):
+        self.origdir = os.getcwd()
         self.d = bb.data.init()
         self.tempdir = tempfile.mkdtemp()
         self.dldir = os.path.join(self.tempdir, "download")
@@ -326,6 +327,7 @@ class FetcherTest(unittest.TestCase):
         self.d.setVar("PERSISTENT_DIR", persistdir)
 
     def tearDown(self):
+        os.chdir(self.origdir)
         bb.utils.prunedir(self.tempdir)
 
 class MirrorUriTest(FetcherTest):
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-14 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 13:33 [PATCH 0/2] Git fetcher remote fix Paul Eggleton
2015-05-14 13:33 ` [PATCH 1/2] fetch2/git: ensure the unpacked origin remote points upstream Paul Eggleton
2015-05-14 13:33 ` [PATCH 2/2] tests/fetch: ensure fetch tests preserve current dir Paul Eggleton

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.