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 1519C138D19 for ; Tue, 14 Jul 2015 23:30:01 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3C845E0880; Tue, 14 Jul 2015 23:30:00 +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 D8E7AE0880 for ; Tue, 14 Jul 2015 23:29:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D6A96340784 for ; Tue, 14 Jul 2015 23:29:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6D0B974B for ; Tue, 14 Jul 2015 23:29:55 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <1436916725.a2f107d19503a8ffca9de85c9e74ff59d21cadf6.blueness@gentoo> Subject: [gentoo-commits] proj/grss:master commit in: grs/ X-VCS-Repository: proj/grss X-VCS-Files: grs/Synchronize.py X-VCS-Directories: grs/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: a2f107d19503a8ffca9de85c9e74ff59d21cadf6 X-VCS-Branch: master Date: Tue, 14 Jul 2015 23:29:55 +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: c649369f-7d39-4899-b36f-67482eed76f3 X-Archives-Hash: 9344e5516dfca1f01f4ed8fe3a6e6c9d commit: a2f107d19503a8ffca9de85c9e74ff59d21cadf6 Author: Anthony G. Basile gentoo org> AuthorDate: Tue Jul 14 23:32:05 2015 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Tue Jul 14 23:32:05 2015 +0000 URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=a2f107d1 grs/Synchronize.py: add documentation. grs/Synchronize.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grs/Synchronize.py b/grs/Synchronize.py index 1df8ce2..ed8209c 100644 --- a/grs/Synchronize.py +++ b/grs/Synchronize.py @@ -5,9 +5,7 @@ from grs.Constants import CONST from grs.Execute import Execute class Synchronize(): - """ doc here - more doc - """ + """ Either clone or pull a remote git repository for a GRS system. """ def __init__(self, remote_repo, branch, libdir = CONST.LIBDIR, logfile = CONST.LOGFILE): self.remote_repo = remote_repo @@ -17,21 +15,23 @@ class Synchronize(): def sync(self): if self.isgitdir(): + # If the local repo exists, then make it pristine an pull cmd = 'git -C %s reset HEAD --hard' % self.local_repo Execute(cmd, timeout=60, logfile=self.logfile) cmd = 'git -C %s clean -f -x -d' % self.local_repo Execute(cmd, timeout=60, logfile=self.logfile) cmd = 'git -C %s pull' % self.local_repo Execute(cmd, timeout=60, logfile=self.logfile) - cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch) - Execute(cmd, timeout=60, logfile=self.logfile) else: + # else clone afresh. cmd = 'git clone %s %s' % (self.remote_repo, self.local_repo) Execute(cmd, timeout=60, logfile=self.logfile) - cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch) - Execute(cmd, timeout=60, logfile=self.logfile) + # Make sure we're on the correct branch for the desired GRS system. + cmd = 'git -C %s checkout %s' % (self.local_repo, self.branch) + Execute(cmd, timeout=60, logfile=self.logfile) def isgitdir(self): + """ If there is a .git/config file, assume its a local git repository. """ git_configdir = os.path.join(self.local_repo, '.git') git_configfile = os.path.join(git_configdir, 'config') return os.path.isdir(git_configdir) and os.path.isfile(git_configfile)