def __init__(self, cwd=None): """Reads git repository settings and sets several methods so that they refer to the git module. This object encapsulates cola's interaction with git.""" super(MainModel, self).__init__() # Initialize the git command object self.git = git.instance() self.head = 'HEAD' self.diff_text = '' self.mode = self.mode_none self.filename = None self.currentbranch = '' self.directory = '' self.project = '' self.remotes = [] self.commitmsg = '' self.modified = [] self.staged = [] self.untracked = [] self.unmerged = [] self.upstream_changed = [] self.submodules = set() self.local_branches = [] self.remote_branches = [] self.tags = [] if cwd: self.set_worktree(cwd)
def __init__(self): observable.Observable.__init__(self) self.git = git.instance() self._system = {} self._user = {} self._repo = {} self._all = {} self._cache_key = None self._configs = [] self._config_files = {} self._find_config_files()
def _cache_key(): # Try /etc/gitconfig as a fallback for the system config userconfig = os.path.expanduser(os.path.join('~', '.gitconfig')) paths = ('/etc/gitconfig', userconfig, git.instance().git_path('config')) mtimes = [] for path in paths: try: mtimes.append(os.stat(path).st_mtime) except OSError: continue return mtimes
def _stat_info(): # Try /etc/gitconfig as a fallback for the system config userconfig = os.path.expanduser(os.path.join('~', '.gitconfig')) paths = (('system', '/etc/gitconfig'), ('user', core.decode(userconfig)), ('repo', core.decode(git.instance().git_path('config')))) statinfo = [] for category, path in paths: try: statinfo.append((category, path, os.stat(path).st_mtime)) except OSError: continue return statinfo