Package gbp :: Module git :: Class GitRepository
[hide private]
[frames] | no frames]

Class GitRepository

object --+
         |
        GitRepository

Represents a git repository at path

Instance Methods [hide private]
 
__init__(self, path)
x.__init__(...) initializes x; see help(type(x)) for signature
 
__check_path(self)
 
__build_env(self, extra_env)
Prepare environment for subprocess calls
 
__git_getoutput(self, command, args=[], extra_env=None, cwd=None)
exec a git command and return the output
 
__git_inout(self, command, args, input, extra_env=None)
Send input and return output (stdout)
 
base_dir(self)
Base of the repository
 
has_branch(self, branch, remote=False)
check if the repository has branch 'branch'
 
has_treeish(self, treeish)
check if the repository has the treeish object treeish
 
has_tag(self, tag)
check if the repository has the given tag
 
_build_legacy_tag(self, format, version)
legacy version numbering
 
find_version(self, format, version)
Check if a certain version is stored in this repo.
 
remove_tag(self, tag)
remove a tag 'tag'
 
move_tag(self, old, new)
 
get_branch(self)
on what branch is the current working copy
 
get_merge_branch(self, branch)
get the branch we'd merge from
tuple
is_fast_forward(self, from_branch, to_branch)
check if an update from from_branch to to_branch would be a fast forward or if the branch is uptodate already
 
set_branch(self, branch)
switch to branch 'branch'
 
create_branch(self, branch, rev=None)
create a new branch
 
delete_branch(self, branch)
 
force_head(self, commit, hard=False)
force head to a specific commit
 
is_clean(self)
does the repository contain any uncommitted modifications
 
is_empty(self)
returns True if repo is empty (doesn't have any commits)
 
index_files(self)
List files in the index
 
commits(self, since=None, until=None, paths=None, options=None, first_parent=False)
get commits from since to until touching paths
 
show(self, id)
git-show id
 
grep_log(self, regex, where=None)
 
get_subject(self, commit)
Gets the subject of a commit
 
get_commit_info(self, commit)
Given a commit name, return a dictionary of its components, including id, author, email, subject, and body.
 
find_tag(self, commit, pattern=None)
find the closest tag to a branch's head
 
rev_parse(self, name)
find the SHA1
 
write_tree(self, index=None)
write out the current index, return the SHA1
 
update_ref(self, ref, new, old=None, msg=None)
Update ref 'ref' to commit 'new'
 
commit_tree(self, tree, msg, parents, author={}, committer={})
Commit a tree with commit msg 'msg' and parents 'parents'
 
commit_dir(self, unpack_dir, msg, branch, other_parents=None, author={}, committer={})
Replace the current tip of branch 'branch' with the contents from 'unpack_dir'
 
get_config(self, name)
Gets the config value associated with name
 
get_author_info(self)
 
get_remote_branches(self)
Get all remote branches
 
get_remote_repos(self)
Get all remote repositories
 
has_remote_repo(self, name)
Do we know about a remote named 'name'
 
format_patches(self, start, end, output_dir)
Output the commits between start and end as patches in output_dir
 
apply_patch(self, patch, index=True, context=None, strip=None)
Apply a patch using git apply
 
archive(self, format, prefix, output, treeish, **kwargs)
 
has_submodules(self)
Does the repo have submodules?
 
add_submodule(self, repo_path)
Add a submodule
 
update_submodules(self, init=True, recursive=True, fetch=False)
Update all submodules
 
get_submodules(self, treeish, path=None, recursive=True)
list the submodules of treeish

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, path)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

has_branch(self, branch, remote=False)

 

check if the repository has branch 'branch'

Parameters:
  • remote - only liste remote branches

find_version(self, format, version)

 

Check if a certain version is stored in this repo. Return it's SHA1 in this case. For legacy tags Don't check only the tag but also the message, since the former wasn't injective until recently. You only need to use this funciton if you also need to check for legacy tags.

Parameters:
  • format - tag pattern
  • version - debian version number
Returns:
sha1 of the version tag

is_fast_forward(self, from_branch, to_branch)

 

check if an update from from_branch to to_branch would be a fast forward or if the branch is uptodate already

Returns: tuple
can_fast_forward, up_to_date

create_branch(self, branch, rev=None)

 

create a new branch

Parameters:
  • rev - where to start the branch from

    if param is None the branch starts form the current HEAD

commits(self, since=None, until=None, paths=None, options=None, first_parent=False)

 

get commits from since to until touching paths

Parameters:
  • options (list of strings) - list of options past to git log

commit_dir(self, unpack_dir, msg, branch, other_parents=None, author={}, committer={})

 

Replace the current tip of branch 'branch' with the contents from 'unpack_dir'

Parameters:
  • unpack_dir (string) - content to add
  • msg (string) - commit message to use
  • branch (string) - branch to add the contents of unpack_dir to
  • other_parents (list string) - additional parents of this commit
  • author (dict with keys 'name', 'email', 'date') - author information to use for commit
  • committer (dict with keys 'name', 'email', 'date') - committer information to use for commit

get_submodules(self, treeish, path=None, recursive=True)

 

list the submodules of treeish

returns a list of submodule/commit-id tuples