def setUp(self, commit=True): TmpPathTestCase.setUp(self) self.initialize_repo() if commit: self.commit_files() git.instance().set_worktree(os.getcwd()) gitcfg.instance().reset() gitcmds.clear_cache()
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.""" Observable.__init__(self) # 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): 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 paths = ("/etc/gitconfig", _USER_XDG_CONFIG, _USER_CONFIG, git.instance().git_path("config")) mtimes = [] for path in paths: try: mtimes.append(core.stat(path).st_mtime) except OSError: continue return mtimes
def _cache_key(): # Try /etc/gitconfig as a fallback for the system config paths = ('/etc/gitconfig', _USER_XDG_CONFIG, _USER_CONFIG, git.instance().git_path('config')) mtimes = [] for path in paths: try: mtimes.append(core.stat(path).st_mtime) except OSError: continue return mtimes
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 rebase(): """Rebase onto a branch.""" branch = choose_from_combo('Rebase Branch', cola.model().all_branches()) if not branch: return #TODO cmd status, output = git.instance().rebase(branch, with_stderr=True, with_status=True) qtutils.log(status, output)
def __init__(self): observable.ObservableModel.__init__(self) self.git = git.instance() self.descriptions_start = [] self.descriptions_end = [] self.revisions_start = [] self.revisions_end = [] self.revision_start = '' self.revision_end = '' self.compare_files = [] self.num_results = 100 self.show_versions=False
def _stat_info(): # Try /etc/gitconfig as a fallback for the system config paths = (('system', '/etc/gitconfig'), ('user', _USER_XDG_CONFIG), ('user', _USER_CONFIG), ('repo', git.instance().git_path('config'))) statinfo = [] for category, path in paths: try: statinfo.append((category, path, core.stat(path).st_mtime)) except OSError: continue return statinfo
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.""" ObservableModel.__init__(self) # Initialize the git command object self.git = git.instance() ##################################################### self.head = 'HEAD' self.mode = self.mode_none self.diff_text = '' self.filename = None self.currentbranch = '' self.trackedbranch = '' self.directory = '' self.git_version = self.git.version() self.remotes = [] self.remotename = '' self.local_branch = '' self.remote_branch = '' ##################################################### # Status info self.commitmsg = '' self.modified = [] self.staged = [] self.untracked = [] self.unmerged = [] self.upstream_changed = [] self.submodules = set() ##################################################### # Refs self.revision = '' self.local_branches = [] self.remote_branches = [] self.tags = [] self.revisions = [] self.summaries = [] self.fetch_helper = None self.push_helper = None self.pull_helper = None self.generate_remote_helpers() if cwd: self.use_worktree(cwd) ##################################################### # Dag self._commits = []
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
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 __init__(self): observable.Observable.__init__(self) self.git = git.instance() self._map = {} self._system = {} self._user = {} self._repo = {} self._all = {} self._cache_key = None self._configs = [] self._config_files = {} self._value_cache = {} self._attr_cache = {} self._find_config_files()
def _stat_info(): # Try /etc/gitconfig as a fallback for the system config paths = ( ("system", "/etc/gitconfig"), ("user", _USER_XDG_CONFIG), ("user", _USER_CONFIG), ("repo", git.instance().git_path("config")), ) statinfo = [] for category, path in paths: try: statinfo.append((category, path, core.stat(path).st_mtime)) except OSError: continue return statinfo
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
def diff_branch(): """Launches a diff against a branch.""" branch = choose_from_combo('Select Branch, Tag, or Commit-ish', ['HEAD^'] + cola.model().all_branches() + cola.model().tags) if not branch: return zfiles_str = git.instance().diff(branch, name_only=True, no_color=True, z=True).rstrip('\0') files = zfiles_str.split('\0') filename = choose_from_list('Select File', files) if not filename: return cola.notifier().broadcast(signals.branch_mode, branch, filename)
def __init__(self): observable.ObservableModel.__init__(self) self.git = git.instance() self.remote_branches = gitcmds.branch_list(remote=True) self.local_branches = gitcmds.branch_list(remote=False) self.left_combo = ['Local', 'Remote'] self.right_combo = ['Local', 'Remote'] self.left_combo_index = 0 self.right_combo_index = 1 self.left_list = [] self.right_list = [] self.left_list_index = -1 self.right_list_index = -1 self.left_list_selected = False self.right_list_selected = False self.diff_files = []
def git_version(): """Returns the current GIT version""" return git.instance().version().split()[-1]
import os from PyQt4 import QtGui from cola import git from cola import gitcmds from cola import utils from cola import resources from cola import qtutils from cola.models import browser from cola.views.selectcommits import SelectCommitsView from cola.qobserver import QObserver git = git.instance() def select_file_from_repo(): """Launch a dialog for selecting a filename from a branch.""" # Clone the model to allow opening multiple browsers # with different sets of data model = browser.BrowserModel(gitcmds.current_branch()) parent = QtGui.QApplication.instance().activeWindow() view = SelectCommitsView(parent, syntax=False) controller = RepoBrowserController(model, view, title='Select File', get_file=True) view.show() if view.exec_() == QtGui.QDialog.Accepted: return controller.filename