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 995BB13877A for ; Mon, 16 Jun 2014 03:40:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B4A00E0B2E; Mon, 16 Jun 2014 03:40:20 +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 E25C8E0B2D for ; Mon, 16 Jun 2014 03:40:19 +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 E003833F926 for ; Mon, 16 Jun 2014 03:40:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id A887F187ED for ; Mon, 16 Jun 2014 03:40:17 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1402607509.a4ce4f5a312c08eb90ccb741f673780b8559d0c4.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/ X-VCS-Repository: proj/layman X-VCS-Files: layman/overlays/git.py X-VCS-Directories: layman/overlays/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: a4ce4f5a312c08eb90ccb741f673780b8559d0c4 X-VCS-Branch: master Date: Mon, 16 Jun 2014 03:40:17 +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: b7a774c5-8d07-4faa-a568-cc5d6637ef67 X-Archives-Hash: 6225958e976c1c01301f0a1630b34a94 Message-ID: <20140616034017.VYVPzZ5T1igrfPA_NL3nEkojlDivw8ELDvbi9cK-9ds@z> commit: a4ce4f5a312c08eb90ccb741f673780b8559d0c4 Author: Devan Franchini gentoo org> AuthorDate: Fri May 23 21:33:47 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Thu Jun 12 21:11:49 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a4ce4f5a git.py: adds update() function Moves the fix_git_source() function to allow both add() and update() to make use of it. While the update() function calls git remote set-url, replacing the old url with the new url provided by overlay.update(). --- layman/overlays/git.py | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/layman/overlays/git.py b/layman/overlays/git.py index f3790ca..ee8c53b 100644 --- a/layman/overlays/git.py +++ b/layman/overlays/git.py @@ -46,21 +46,24 @@ class GitOverlay(OverlaySource): _location, ignore) self.subpath = None + def _fix_git_source(self, source): + ''' + Adds trailing slash to http sources + + @param source: source URL, string. + ''' + # http:// should get trailing slash, other protocols shouldn't + if source.split(':')[:1] == 'http': + if not source.endswith('/'): + return source + '/' + return source + def add(self, base): '''Add overlay.''' if not self.supported(): return 1 - def fix_git_source(source): - # http:// should get trailing slash, other protocols shouldn't - if source.split(':')[0] == 'http': - if source.endswith('/'): - return source - else: - return source + '/' - return source - cfg_opts = self.config["git_addopts"] target = path([base, self.parent.name]) @@ -70,7 +73,7 @@ class GitOverlay(OverlaySource): args.append('-q') if len(cfg_opts): args.append(cfg_opts) - args.append(fix_git_source(self.src)) + args.append(self._fix_git_source(self.src)) args.append(target) success = False # adding cwd=base due to a new git bug in selinux due to @@ -95,6 +98,21 @@ class GitOverlay(OverlaySource): self.output.debug("set git user info...args=%s" % ' '.join(args), 8) return self.run_command(self.command(), args, cmd=self.type, cwd=target) + def update(self, base, src): + ''' + Update overlay src-url + + @params base: base location where all overlays are installed. + @params src: source URL. + ''' + self.output.debug("git.update(); starting...%s" % self.parent.name, 6) + target = path([base, self.parent.name]) + + # git remote set-url + args = ['remote', 'set-url', 'origin', self._fix_git_source(src), self._fix_git_source(self.src)] + + return self.run_command(self.command(), args, cmd=self.type, cwd=target) + def sync(self, base): '''Sync overlay.'''