commit:     a2f107d19503a8ffca9de85c9e74ff59d21cadf6
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 14 23:32:05 2015 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> 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)

Reply via email to