Package PyFoam :: Package Basics :: Module GitInterface
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Basics.GitInterface

 1  #  ICE Revision: $Id$ 
 2  """A VCS-interface to Mercurial""" 
 3   
 4  from PyFoam.Error import warning,error,notImplemented 
 5   
 6  from .GeneralVCSInterface import GeneralVCSInterface 
 7   
 8  from os import path as opath 
 9  import subprocess 
10  import os 
11   
12 -class GitInterface(GeneralVCSInterface):
13 """\ 14 The interface class to git 15 16 Only a partial implementation (As much as the BuildHelper needs)""" 17
18 - def __init__(self, 19 path, 20 init=False):
21 22 GeneralVCSInterface.__init__(self,path,init) 23 if init: 24 notImplemented(self,"__init__ (creation of a repository)")
25 26
27 - def getRoot(self,path):
28 oldDir=os.getcwd() 29 os.chdir(path) 30 result=self.executeWithOuput("git rev-parse --show-toplevel") 31 os.chdir(oldDir) 32 return result
33
34 - def branchName(self):
35 return self.doInPath(self.executeWithOuput,"git rev-parse --abbrev-ref HEAD")
36
37 - def getRevision(self):
38 return self.doInPath(self.executeWithOuput,"git rev-parse --short HEAD")
39
40 - def update(self, 41 timeout=None):
42 ok=self.doInPath(subprocess.call,["git","pull"]) 43 return ok==0
44 45 46 # Should work with Python3 and Python2 47