Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] enhance action_pull
@ 2015-08-04 16:23 Patrick Ohly
  2015-08-04 16:23 ` [PATCH 1/2] combo-layer: enhance output in action_pull Patrick Ohly
  2015-08-04 16:24 ` [PATCH 2/2] combo-layer: fix action_pull for unknown branch Patrick Ohly
  0 siblings, 2 replies; 3+ messages in thread
From: Patrick Ohly @ 2015-08-04 16:23 UTC (permalink / raw)
  To: openembedded-core

action_pull can fail when the branch is not yet in the existing
component repo. Both error reporting and handling need to be enhanced.

The following changes since commit 288c76a41aebaf54c7fca3782160830df462b9e4:

  builder: Fix multilib compile failure (2015-08-03 07:15:47 +0100)

are available in the git repository at:

  git://github.com/pohly/openembedded-core action-pull
  https://github.com/pohly/openembedded-core/tree/action-pull

Patrick Ohly (2):
  combo-layer: enhance output in action_pull
  combo-layer: fix action_pull for unknown branch

 scripts/combo-layer | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

-- 
2.1.4



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

* [PATCH 1/2] combo-layer: enhance output in action_pull
  2015-08-04 16:23 [PATCH 0/2] enhance action_pull Patrick Ohly
@ 2015-08-04 16:23 ` Patrick Ohly
  2015-08-04 16:24 ` [PATCH 2/2] combo-layer: fix action_pull for unknown branch Patrick Ohly
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Ohly @ 2015-08-04 16:23 UTC (permalink / raw)
  To: openembedded-core

The git operations can fail, for example when the branch is unknown
or misconfigured.

Better move the info message and extend it such that it is printed
first and provides the necessary context, because otherwise the
CalledProcessError exception gets dumped without mentioning for which
component it occurred.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
 scripts/combo-layer | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/combo-layer b/scripts/combo-layer
index 70dad83..7380f5b 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -585,8 +585,8 @@ def action_pull(conf, args):
         repo = conf.repos[name]
         ldir = repo['local_repo_dir']
         branch = repo.get('branch', "master")
+        logger.info("update branch %s of component repo %s in %s ..." % (branch, name, ldir))
         runcmd("git checkout %s" % branch, ldir)
-        logger.info("update component repo %s in %s ..." % (name, ldir))
         if not conf.hard_reset:
             output=runcmd("git pull --ff-only", ldir)
             logger.info(output)
-- 
2.1.4



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

* [PATCH 2/2] combo-layer: fix action_pull for unknown branch
  2015-08-04 16:23 [PATCH 0/2] enhance action_pull Patrick Ohly
  2015-08-04 16:23 ` [PATCH 1/2] combo-layer: enhance output in action_pull Patrick Ohly
@ 2015-08-04 16:24 ` Patrick Ohly
  1 sibling, 0 replies; 3+ messages in thread
From: Patrick Ohly @ 2015-08-04 16:24 UTC (permalink / raw)
  To: openembedded-core

When reconfiguring the branch to something not already fetched,
action_pull fails with
   error: pathspec '<new branch name>' did not match any file(s) known to git.

It is the "git checkout" which fails like that. To solve this,
try the faster "git checkout + git pull" first and only if that fails,
fall back to the slow "git fetch + git checkout".

In the conf.hard_reset case, do the checkout always after the git fetch.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
 scripts/combo-layer | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/scripts/combo-layer b/scripts/combo-layer
index 7380f5b..7435a17 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -586,13 +586,25 @@ def action_pull(conf, args):
         ldir = repo['local_repo_dir']
         branch = repo.get('branch', "master")
         logger.info("update branch %s of component repo %s in %s ..." % (branch, name, ldir))
-        runcmd("git checkout %s" % branch, ldir)
         if not conf.hard_reset:
-            output=runcmd("git pull --ff-only", ldir)
-            logger.info(output)
+            # Try to pull only the configured branch. Beware that this may fail
+            # when the branch is currently unknown (for example, after reconfiguring
+            # combo-layer). In that case we need to fetch everything and try the check out
+            # and pull again.
+            try:
+                runcmd("git checkout %s" % branch, ldir, printerr=False)
+            except subprocess.CalledProcessError:
+                output=runcmd("git fetch", ldir)
+                logger.info(output)
+                runcmd("git checkout %s" % branch, ldir)
+                runcmd("git pull --ff-only", ldir)
+            else:
+                output=runcmd("git pull --ff-only", ldir)
+                logger.info(output)
         else:
             output=runcmd("git fetch", ldir)
             logger.info(output)
+            runcmd("git checkout %s" % branch, ldir)
             runcmd("git reset --hard FETCH_HEAD", ldir)
 
 def action_update(conf, args):
-- 
2.1.4



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

end of thread, other threads:[~2015-08-04 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-04 16:23 [PATCH 0/2] enhance action_pull Patrick Ohly
2015-08-04 16:23 ` [PATCH 1/2] combo-layer: enhance output in action_pull Patrick Ohly
2015-08-04 16:24 ` [PATCH 2/2] combo-layer: fix action_pull for unknown branch Patrick Ohly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox