Esempio n. 1
0
 def _path_at_level(self, level ):
     # we do not support an absolute path of the gitconfig on windows , 
     # use the global config instead
     if sys.platform == "win32" and level == "system":
         level = "global"
     #END handle windows
         
     if level == "system":
         return "/etc/%s" % self.system_config_file_name
     elif level == "global":
         return normpath(expanduser("~/.%s" % self.system_config_file_name))
     elif level == "repository":
         return join(self.git_dir, self.repo_config_file_name)
     #END handle level
     
     raise ValueError("Invalid configuration level: %r" % level)
Esempio n. 2
0
    def _path_at_level(self, level):
        # we do not support an absolute path of the gitconfig on windows ,
        # use the global config instead
        if sys.platform == "win32" and level == "system":
            level = "global"
        # END handle windows

        if level == "system":
            return "/etc/%s" % self.system_config_file_name
        elif level == "global":
            return normpath(expanduser("~/.%s" % self.system_config_file_name))
        elif level == "repository":
            return join(self.git_dir, self.repo_config_file_name)
        # END handle level

        raise ValueError("Invalid configuration level: %r" % level)
Esempio n. 3
0
    def _initialize(self, path):
        epath = abspath(expandvars(expanduser(path or os.getcwd())))

        if not exists(epath):
            raise NoSuchPathError(epath)
        #END check file

        self._working_tree_dir = None
        self._git_path = None
        curpath = epath

        # walk up the path to find the .git dir
        while curpath:
            if is_git_dir(curpath):
                self._git_path = curpath
                self._working_tree_dir = os.path.dirname(curpath)
                break
            gitpath = join(curpath, self.repo_dir)
            if is_git_dir(gitpath):
                self._git_path = gitpath
                self._working_tree_dir = curpath
                break
            curpath, dummy = os.path.split(curpath)
            if not dummy:
                break
        # END while curpath

        if self._git_path is None:
            raise InvalidGitRepositoryError(epath)
        # END path not found

        self._bare = self._working_tree_dir is None
        if hasattr(self, 'config_reader'):
            try:
                self._bare = self.config_reader("repository").getboolean(
                    'core', 'bare')
            except Exception:
                # lets not assume the option exists, although it should
                pass
            #END handle exception
        #END check bare flag
        self._working_tree_dir = self._bare and None or self._working_tree_dir
Esempio n. 4
0
    def _initialize(self, path):
        epath = abspath(expandvars(expanduser(path or os.getcwd())))

        if not exists(epath):
            raise NoSuchPathError(epath)
        #END check file 

        self._working_tree_dir = None
        self._git_path = None
        curpath = epath
        
        # walk up the path to find the .git dir
        while curpath:
            if is_git_dir(curpath):
                self._git_path = curpath
                self._working_tree_dir = os.path.dirname(curpath)
                break
            gitpath = join(curpath, self.repo_dir)
            if is_git_dir(gitpath):
                self._git_path = gitpath
                self._working_tree_dir = curpath
                break
            curpath, dummy = os.path.split(curpath)
            if not dummy:
                break
        # END while curpath
        
        if self._git_path is None:
            raise InvalidGitRepositoryError(epath)
        # END path not found

        self._bare = self._working_tree_dir is None
        if hasattr(self, 'config_reader'):
            try:
                self._bare = self.config_reader("repository").getboolean('core','bare') 
            except Exception:
                # lets not assume the option exists, although it should
                pass
            #END handle exception
        #END check bare flag
        self._working_tree_dir = self._bare and None or self._working_tree_dir