qisrc.git – Git related tools

A Pythonic git API

qisrc.git.Git

class qisrc.git.Git(repo)

The Git represent a git tree

call(*args, **kwargs)

Call a git command

Parameters:
  • args – The arguments of the command. For instance [“frobnicate”, “–spam=eggs”]
  • kwargs
    Will be passed to subprocess.check_call()
    command, with the following changes:
    • if cwd is not given it will be self.repo instead
    • if env is not given it will be read from the config file
    • if raises is False, no exception will be raise if command fails, and a (retcode, output) tuple will be returned.
clone(*args, **kwargs)

Wrapper for git clone

fetch(*args, **kwargs)

Wrapper for git fetch

get_config(name)

Get a git config value. Return None if not found

get_current_branch()

return the current branch

get_current_ref(ref='HEAD')

return the current ref git symbolic-ref HEAD else: git name-rev –name-only –always HEAD

is_clean(untracked=True)

Returns true if working dir is clean. (ie no untracked files, no unstaged changes)

param untracked:
 will return True even if there are untracked files.
is_valid()

Check if the worktree is a valid git tree

pull(*args, **kwargs)

Wrapper for git pull

push(*args, **kwargs)

Wrapper for git push

remote(*args, **kwargs)

Wrapper for git remote

reset(*args, **kwargs)

Wrapper for git reset