cola.models.main – Main application model
Provides access to git data.
This module provides the cola model class.
-
class cola.models.main.GitCola
GitPython throws exceptions by default.
We suppress exceptions in favor of return values.
-
get_git_dir()
-
get_work_tree()
-
is_valid()
-
load_worktree(path)
-
exception cola.models.main.GitInitError
-
class cola.models.main.MainModel
Provides a friendly wrapper for doing common git operations.
-
abort_merge()
-
add_or_remove(to_process)
- Invokes ‘git add’ to index the filenames in to_process that exist
and ‘git rm’ for those that do not exist.
-
add_signoff(*rest)
- Adds a standard Signed-off by: tag to the end
of the current commit message.
-
apply_diff(filename)
-
apply_diff_to_worktree(filename)
-
apply_font_size(param, default)
-
branch_list(remote=False)
Returns a list of local or remote branches
This explicitly removes HEAD from the list of remote branches.
-
cherry_pick_list(revs, **kwargs)
- Cherry-picks each revision into the current branch.
Returns a list of command output strings (1 per cherry pick)
-
commit_with_msg(msg, amend=False)
- Creates a git commit.
-
config_dict(local=True)
- parses the lines from git config –list into a dictionary
-
config_set(key=None, value=None, local=True)
-
create_branch(name, base, track=False)
Create a branch named ‘name’ from revision ‘base’
Pass track=True to create a local tracking branch.
-
current_branch()
- Parses ‘git symbolic-ref’ to find the current branch.
-
delete_branch(branch)
-
describe(revid, descr)
-
diff_helper(commit=None, branch=None, ref=None, endref=None, filename=None, cached=True, with_diff_header=False, suppress_header=True, reverse=False, patch_with_raw=True)
- Invokes git diff on a filepath.
-
diffindex()
-
diffstat()
-
export_patchset(start, end, output='patches', **kwargs)
-
format_patch_helper(to_export, revs, output='patches')
- writes patches named by to_export to the output directory.
-
gen_remote_helper(gitaction)
- Generates a closure that calls git fetch, push or pull
-
generate_remote_helpers()
- Generates helper methods for fetch, push and pull
-
get_all_branches()
-
get_changed_files(start, end)
-
get_cola_config(key)
-
get_commit_diff(sha1)
-
get_config_params()
-
get_corresponding_remote_ref()
-
get_default_remote()
-
get_diff_details(idx, ref, staged=True)
-
get_diff_filenames(arg)
- Returns a list of filenames that have been modified
-
get_editor()
-
get_filename(idx, staged=True)
-
get_global_config(key, default=None)
-
get_gui_config(key)
-
get_history_browser()
-
get_local_config(key, default=None)
-
get_merge_message()
-
get_merge_message_path()
-
get_prev_commitmsg(*rest)
- Queries git for the latest commit message and sets it in
self.commitmsg.
-
get_remote_args(remote, local_branch='', remote_branch='', ffwd=True, tags=False, rebase=False)
-
get_renamed_files(start, end)
-
get_revision_sha1(idx)
-
get_subtree_node(idx)
-
get_tmp_dir()
-
get_tmp_file_pattern()
-
get_tmp_filename(prefix='')
-
get_tree_node(idx)
-
get_workdir_state(head='HEAD', staged_only=False)
- Returns a tuple of staged, unstaged, untracked, and unmerged files
-
git_repo_path(*subpaths)
-
init_browser_data()
- This scans over self.(names, sha1s, types) to generate
directories, directory_entries, and subtree_*
-
is_commit_published()
-
load_commitmsg(path)
-
load_commitmsg_template()
-
log_helper(all=False)
- Returns a pair of parallel arrays listing the revision sha1’s
and commit summaries.
-
pad(pstr, num=22)
-
parse_ls_tree(rev)
- Returns a list of(mode, type, sha1, path) tuples.
-
parse_rev_list(raw_revs)
-
parse_stash_list(revids=False)
- Parses “git stash list” and returns a list of stashes.
-
remember_gui_settings()
-
remote_url(name)
-
reset(*items)
-
reset_helper(args)
Removes files from the index
This handles the git init case, which is why it’s not
just ‘git reset name’. For the git init case this falls
back to ‘git rm –cached’.
-
rev_list_range(start, end)
-
save_config_param(param)
-
set_remote(remote)
-
should_display_log(status)
Returns whether we should display the log window
- This implements the behavior of the cola.showoutput variable.
- never = never open the log window
always = open it always
errors = only open it on error (handled implicitly)
-
stage_all()
-
stage_modified()
-
stage_untracked()
-
unstage_all()
-
update_revision_lists(filename=None, show_versions=False)
-
update_status(head='HEAD', staged_only=False)
-
use_worktree(worktree)
-
cola.models.main.eval_path(path)
- handles quoted paths.