Changeset 3267

Show
Ignore:
Timestamp:
02/24/08 03:20:36 (9 months ago)
Author:
hvr
Message:

GitPlugin: added simple GIT sanity check to constructor, in order to
catch bad git_dirs early

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gitplugin/0.11/tracext/git/PyGIT.py

    r3266 r3267  
    138138    def __init__(self, git_dir, log): 
    139139        self.logger = log 
     140 
     141        # simple sanity checking 
     142        __git_file_path = partial(os.path.join, git_dir) 
     143        if not all(map(os.path.exists, 
     144                       map(__git_file_path, 
     145                           ['HEAD','objects','refs']))): 
     146            self.logger.error("GIT control files missing in '%s'" % git_dir) 
     147            if os.path.exists(__git_file_path('.git')): 
     148                self.logger.error("entry '.git' found in '%s'" 
     149                                  " -- maybe use that folder instead..." % git_dir) 
     150            raise GitError("GIT control files not found, maybe wrong directory?") 
     151 
    140152        self.logger.debug("PyGIT.Storage instance %d constructed" % id(self)) 
    141153