rendered paste bodyclass GIT(GenericVersionControlSystem): """Class to manage items under revision control of Subversion.""" # Assuming that the the PO directory is under the toplevel $projectdir # XXX: Hardcoded for GNU Style layouts # MARKER_DIR = "../.git" def __init__(self, location): GenericVersionControlSystem.__init__(self, location) self.gitdir = os.path.join(os.path.dirname(os.path.abspath(location)), self.MARKER_DIR) self.location = os.path.abspath(location) os.chdir (os.path.dirname(self.location)) def update(self, revision=None): """update the working copy - remove local modifications if necessary""" location_rel = os.path.basename(self.location) # Git checkout command = "git checkout %s" % (location_rel) if error: raise IOError("git error running '%s': %s" % (command, error)) # pull changes command = "git pull" output_pull, error = pipe(command) if error: raise IOError("git error running '%s': %s" % (command, error)) return output_checkout + output_pull def commit(self, message=None): """commit the file and return the given message if present""" location_rel = os.path.basename(self.location) command = "git add %s" % (location_rel) output_add, error, ret = pipe(command) #if ret: # raise IOError("git error running '%s': %s, %s" % (command, error, os.getcwd())) # commit file command = "git commit" if message: command = command + " -m " + '"PootleCommit"' output_commit, error, ret = pipe(command) #if ret: # raise IOError("git error running '%s': %s" % (command, error)) # push changes command = "git push" output_push, error, ret = pipe(command) #if ret: # raise IOError("git error running '%s': %s" % (command, error)) return output_add + output_commit + output_push def getcleanfile(self, revision=None): """return the content of the 'head' revision of the file""" location_rel = os.path.basename(self.location) command = "git show HEAD:%s" % (location_rel) output, error = pipe(command) if error: raise IOError("git error running '%s': %s" % (command, error)) return output