From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 81A0D138BF3 for ; Sat, 8 Feb 2014 04:03:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5FCEBE0C00; Sat, 8 Feb 2014 04:03:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DA3BBE0B3F for ; Sat, 8 Feb 2014 04:03:13 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 12CC033F9D3 for ; Sat, 8 Feb 2014 04:03:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id D165318278 for ; Sat, 8 Feb 2014 04:03:11 +0000 (UTC) From: "Chris Reffett" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Chris Reffett" Message-ID: <1391829708.54c30b589b6807abc9985ab0baf9ab63c3e30bcd.creffett@gentoo> Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/modules/git/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/sync/modules/git/git.py X-VCS-Directories: pym/portage/sync/modules/git/ X-VCS-Committer: creffett X-VCS-Committer-Name: Chris Reffett X-VCS-Revision: 54c30b589b6807abc9985ab0baf9ab63c3e30bcd X-VCS-Branch: plugin-sync Date: Sat, 8 Feb 2014 04:03:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b76783b8-3b18-497d-9743-95491c2955bc X-Archives-Hash: acace7d9f1052be158d5a7cc0d864747 commit: 54c30b589b6807abc9985ab0baf9ab63c3e30bcd Author: Chris Reffett gentoo org> AuthorDate: Fri Feb 7 22:46:22 2014 +0000 Commit: Chris Reffett gentoo org> CommitDate: Sat Feb 8 03:21:48 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=54c30b58 Add auto-clone support for git sync Make the git sync module clone the upstream repository if the directory specified in repos.conf isn't a git directory. Fixes bug 485402. --- pym/portage/sync/modules/git/git.py | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/pym/portage/sync/modules/git/git.py b/pym/portage/sync/modules/git/git.py index 2f855bd..bce992e 100644 --- a/pym/portage/sync/modules/git/git.py +++ b/pym/portage/sync/modules/git/git.py @@ -57,17 +57,36 @@ class GitSync(object): if not self.has_git: return repo.location, 1, False - msg = ">>> Starting git pull in %s..." % repo.location - logger(xterm_titles, msg ) - writemsg_level(msg + "\n") - exitcode = portage.process.spawn_bash("cd %s ; git pull" % \ + # Test if the directory is a valid git repo, and run + # git clone if not + exitcode = portage.process.spawn_bash("cd %s ; git rev-parse" %\ (portage._shell_quote(repo.location),), **portage._native_kwargs(spawn_kwargs)) - if exitcode != os.EX_OK: - msg = "!!! git pull error in %s." % repo.location + if exitcode == 128: + msg = "!!! Git repo does not already exist, cloning from upstream..." logger(xterm_titles, msg) - writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) - return exitcode + writemsg_level(msg + "\n") + exitcode = portage.process.spawn_bash("cd %s ; git clone %s ." % \ + (portage._shell_quote(repo.location), + portage._shell_quote(repo.sync_uri)), + **portage._native_kwargs(spawn_kwargs)) + if exitcode != os.EX_OK: + msg = "!!! git clone error in %s." % repo.location + logger(xterm_titles, msg) + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) + return (exitcode, False) + else: + msg = ">>> Starting git pull in %s..." % repo.location + logger(xterm_titles, msg ) + writemsg_level(msg + "\n") + exitcode = portage.process.spawn_bash("cd %s ; git pull" % \ + (portage._shell_quote(repo.location),), + **portage._native_kwargs(spawn_kwargs)) + if exitcode != os.EX_OK: + msg = "!!! git pull error in %s." % repo.location + logger(xterm_titles, msg) + writemsg_level(msg + "\n", level=logging.ERROR, noiselevel=-1) + return (exitcode, False) msg = ">>> Git pull in %s successful" % repo.location logger(xterm_titles, msg) writemsg_level(msg + "\n")