Ggit.Repository¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
Clone options |
||
r |
Head |
||
r/w/co |
Whether to initialize a repository |
||
r/w/co |
Is a bare repository |
||
r/w/co |
The location of the repository |
||
r/w/co |
The URL for cloning a repository |
||
r/w/c |
The path to the repository working directory |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Ggit.Repository(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Represents an existing git repository including all of it’s object contents.
- classmethod clone(url, location, options)¶
- Parameters:
url (
str
) – url to fetch the repository from.location (
Gio.File
) – the location of the repository.options (
Ggit.CloneOptions
orNone
) – aGgit.CloneOptions
.
- Raises:
- Returns:
a newly created
Ggit.Repository
.- Return type:
Clones a new git repository in the given folder.
- classmethod discover(location)¶
- Parameters:
location (
Gio.File
) – the base location where the lookup starts.- Raises:
- Returns:
the repository location.
- Return type:
Looks for a git repository.
The lookup starts from path and walks up the parent directories and stops when a repository is found.
- classmethod discover_full(location, across_fs, ceiling_dirs)¶
- Parameters:
- Raises:
- Returns:
the repository location.
- Return type:
Looks for a git repository.
The lookup starts from path and walks up the parent directories and stops when a repository is found.
- classmethod init_repository(location, is_bare)¶
- Parameters:
- Raises:
- Returns:
a newly created
Ggit.Repository
.- Return type:
Creates a new git repository in the given folder.
- classmethod open(location)¶
- Parameters:
location (
Gio.File
) – the location of the repository.- Raises:
- Returns:
a newly created
Ggit.Repository
.- Return type:
Open a git repository.
The path must point to an existing git repository folder, e.g.
/path/to/my_repo/.git/ (normal repository) objects/ index HEAD
/path/to/bare_repo/ (bare repository) objects/ index HEAD
The method will automatically detect if path is a normal or bare repository or fail if it is neither.
- add_remote_fetch(remote, refspec)¶
- Parameters:
remote (
Ggit.Remote
) – aGgit.Remote
.refspec (
str
) – the fetch refspec.
- Raises:
Adds a fetch refspec to the remote's configuration. Adds refspec to the fetch list in the configuration. No loaded remote instances will be affected.
- add_remote_push(remote, refspec)¶
- Parameters:
remote (
Ggit.Remote
) – aGgit.Remote
.refspec (
str
) – the push refspec.
- Raises:
Adds a push refspec to remote's configuration. Adds the given refspec to the push list in the configuration. No loaded remote instances will be affected.
- blame_file(file, blame_options)¶
- Parameters:
file (
Gio.File
) – the file to blame.blame_options (
Ggit.BlameOptions
orNone
) – blame options.
- Raises:
- Returns:
a
Ggit.Blame
.- Return type:
Ggit.Blame
orNone
Get a blame for a single file.
- checkout_head(options)¶
- Parameters:
options (
Ggit.CheckoutOptions
orNone
) – aGgit.CheckoutOptions
orNone
.- Raises:
- Returns:
- Return type:
Update files in the working tree to reflect the contents of current HEAD. If options is
None
, then the default checkout options will be used.If the checkout was not successfull, then error will be set.
- checkout_index(index, options)¶
- Parameters:
index (
Ggit.Index
orNone
) – aGgit.Index
orNone
.options (
Ggit.CheckoutOptions
orNone
) – aGgit.CheckoutOptions
orNone
.
- Raises:
- Returns:
- Return type:
Update files in the working tree to reflect the contents of the index. If index is
None
, then the current index of the repository will be used. If options isNone
, then the default checkout options will be used.If the checkout was not successfull, then error will be set.
- checkout_tree(tree, options)¶
- Parameters:
tree (
Ggit.Object
orNone
) – aGgit.Object
orNone
.options (
Ggit.CheckoutOptions
orNone
) – aGgit.CheckoutOptions
orNone
.
- Raises:
- Returns:
- Return type:
Update files in the working tree to reflect the contents of the specified commit, tag or tree object. If tree is
None
, then the current HEAD of the repository will be used. If options isNone
, then the default checkout options will be used.If the checkout was not successfull, then error will be set.
- cherry_pick(commit, options)¶
- Parameters:
commit (
Ggit.Commit
) – aGgit.Commit
.options (
Ggit.CherryPickOptions
) – aGgit.CherryPickOptions
.
- Raises:
- Returns:
True
if the commit was cherry-picked successfully,False
otherwise.- Return type:
Cherry pick the specified commit, making changes in the index and the working directory.
- cherry_pick_commit(commit, our_commit, mainline, merge_options)¶
- Parameters:
commit (
Ggit.Commit
) – aGgit.Commit
to cherry-pick.our_commit (
Ggit.Commit
) – aGgit.Commit
to cherry-pick on.mainline (
int
) – the parent of the commit, in case of a merge commit.merge_options (
Ggit.MergeOptions
orNone
) – aGgit.MergeOptions
.
- Raises:
- Returns:
a
Ggit.Index
.- Return type:
Ggit.Index
orNone
Cherry-picks the given commit against the provided our_commit, producing and index that reflects the result of the cherry-pick.
- create_blob()¶
- Returns:
- Return type:
Create a new blob and return a
Gio.OutputStream
to write contents to the blob. This is an efficient way to create new blobs without copying data. The blob id can be obtained from the blob output stream usingGgit.BlobOutputStream.get_id
, after you close the stream.
- create_blob_from_buffer(buffer)¶
- Parameters:
buffer (
bytes
) – the data.- Raises:
- Returns:
the new #GgitOid of the written blob, or
None
if writing the blob failed.- Return type:
Write an in-memory buffer to the object database as a blob.
- create_blob_from_file(file)¶
- Parameters:
- Raises:
- Return type:
Write a file to the object database as a blob.
Returns (transfer full) (nullable): the new #GgitOid of the written blob, or
None
if writing the blob failed.
- create_blob_from_path(path)¶
- Parameters:
path (
str
) – the file path.- Raises:
- Returns:
the new #GgitOid of the written blob, or
None
if writing the blob failed.- Return type:
Write a path relative to the repository working directory to the object database as a blob.
- create_branch(branch_name, target, flags)¶
- Parameters:
branch_name (
str
) – the name of the branch.target (
Ggit.Object
) – aGgit.Object
.flags (
Ggit.CreateFlags
) – aGgit.CreateFlags
.
- Raises:
- Returns:
the reference to which the branch points, or
None
in case of an error.- Return type:
Ggit.Branch
orNone
Creates a new branch pointing at a target commit.
- create_commit(update_ref, author, committer, message_encoding, message, tree, parents)¶
- Parameters:
author (
Ggit.Signature
) – author signature.committer (
Ggit.Signature
) – committer signature (and time of commit).message (
str
) – commit message.tree (
Ggit.Tree
) – the tree of objects to commit.parents ([
Ggit.Commit
]) – parent commits.
- Raises:
- Returns:
the
Ggit.OId
of the created commit object, orNone
in case of an error.- Return type:
Create a new commit. If update_ref is not
None
, the given reference will be updated to point to the newly created commit. Use “HEAD” to update the HEAD of the current branch and make it point to this commit.If message_encoding is set to
None
, “UTF-8” encoding is assumed for the provided message. Note that message will not be cleaned up automatically. You can useGgit.message_prettify
to do this yourself if needed.
- create_commit_buffer(author, committer, message_encoding, message, tree, parents)¶
- Parameters:
author (
Ggit.Signature
) – author signature.committer (
Ggit.Signature
) – committer signature (and time of commit).message (
str
) – commit message.tree (
Ggit.Tree
) – the tree of objects to commit.parents ([
Ggit.Commit
]) – parent commits.
- Raises:
- Returns:
the commit object content or
None
in case of an error.- Return type:
Create a commit as with git_commit_create() but instead of writing it to the objectdb, write the contents of the object into a buffer.
- create_commit_from_ids(update_ref, author, committer, message_encoding, message, tree, parents)¶
- Parameters:
author (
Ggit.Signature
) – author signature.committer (
Ggit.Signature
) – committer signature (and time of commit).message (
str
) – commit message.tree (
Ggit.OId
) – the tree of objects to commit.parents ([
Ggit.OId
]) – parent commits.
- Raises:
- Returns:
the
Ggit.OId
of the created commit object, orNone
in case of an error.- Return type:
Create a new commit. If update_ref is not
None
, the given reference will be updated to point to the newly created commit. Use “HEAD” to update the HEAD of the current branch and make it point to this commit.If message_encoding is set to
None
, “UTF-8” encoding is assumed for the provided message. Note that message will not be cleaned up automatically. You can useGgit.message_prettify
to do this yourself if needed.
- create_commit_with_signature(commit_content, signature, signature_field)¶
- Parameters:
- Raises:
- Returns:
the
Ggit.OId
of the created commit object, orNone
in case of an error.- Return type:
Given the unsigned commit object’s contents, its signature and the header field in which to store the signature, attach the signature to the commit and write it into the given repositoryCreate a new commit using the (if not
None
) signature key and type of key provided.
- create_index_entry_for_file(file, id)¶
- Parameters:
- Raises:
- Returns:
a
Ggit.IndexEntry
orNone
when an error occurred.- Return type:
Create a new index entry. When file is not
None
, the path of the returned entry (Ggit.IndexEntry.get_path
) is set to the path of file relative to the working directory of self. The file must reside in the working directory of self. The file related fields of the returned entry are also queried from this file (if the file exists).If id is not
None
, then the id of the returned entry is set to id (seeGgit.IndexEntry.get_id
) which could point to a blob (for a file) or a tree (for a directory).
- create_index_entry_for_path(path, id)¶
- Parameters:
- Raises:
- Returns:
a
Ggit.IndexEntry
orNone
when an error occurred.- Return type:
Create a new index entry. When path is not
None
, the path of the returned entry (Ggit.IndexEntry.get_path
) is set to path. The specified path can be either absolute or relative. In the case of an absolute path, the path must reside within the working directory of self. The file related fields of the returned entry are also queried from this path (if the file exists).If id is not
None
, then the id of the returned entry is set to id (seeGgit.IndexEntry.get_id
) which could point to a blob (for a file) or a tree (for a directory).
- create_note(notes_ref, author, committer, id, note, force)¶
- Parameters:
notes_ref (
str
orNone
) – canonical name of the reference to use, orNone
to use the default ref.author (
Ggit.Signature
) – author signature.committer (
Ggit.Signature
) – committer signature.id (
Ggit.OId
) – OID of the git object to decorate.note (
str
) – content of the note to add for object oid.force (
bool
) – whether to overwrite existing note.
- Raises:
- Returns:
the OID for the note or
None
in case of error.- Return type:
Adds a note for an object.
- create_reference(name, oid, log_message)¶
- Parameters:
- Raises:
- Returns:
the newly created reference.
- Return type:
Creates a new object id reference.
The reference will be created in the repository and written to the disk. The returned value must be freed with
GObject.Object.unref
().
- create_remote(name, url)¶
- Parameters:
- Raises:
- Returns:
a new
Ggit.Remote
orNone
if there is an error.- Return type:
Ggit.Remote
orNone
Adds a remote with the default fetch refspec to the repository’s configuration.
- create_symbolic_reference(name, target, log_message)¶
- Parameters:
- Raises:
- Returns:
the newly created reference.
- Return type:
Creates a new symbolic reference.
The reference will be created in the repository and written to the disk. The returned value must be freed with
GObject.Object.unref
().
- create_tag(tag_name, target, tagger, message, flags)¶
- Parameters:
tag_name (
str
) – the tag name.target (
Ggit.Object
) – aGgit.Object
.tagger (
Ggit.Signature
) – aGgit.Signature
.message (
str
) – the tag message.flags (
Ggit.CreateFlags
) – aGgit.CreateFlags
.
- Raises:
- Returns:
the id to which the tag points, or
None
in case of an error.- Return type:
Create a new tag object.
- create_tag_annotation(tag_name, target, signature, message)¶
- Parameters:
tag_name (
str
) – the name of the tag.target (
Ggit.Object
) – aGgit.Object
.signature (
Ggit.Signature
) – aGgit.Object
.message (
str
) – the tag message.
- Raises:
- Returns:
the id to which the tag points, or
None
in case of an error.- Return type:
Creates a new annotated tag.
- create_tag_from_buffer(tag, flags)¶
- Parameters:
tag (
str
) – the tag buffer.flags (
Ggit.CreateFlags
) – aGgit.CreateFlags
.
- Raises:
- Returns:
the id to which the tag points, or
None
in case of an error.- Return type:
Create a new tag from a buffer describing the tag object. The buffer must be correctly formatted.
- create_tag_lightweight(tag_name, target, flags)¶
- Parameters:
tag_name (
str
) – the name of the tag.target (
Ggit.Object
) – aGgit.Object
.flags (
Ggit.CreateFlags
) – aGgit.CreateFlags
.
- Raises:
- Returns:
the id to which the tag points, or
None
in case of an error.- Return type:
Creates a new lightweight tag.
- create_tree_builder()¶
- Raises:
- Returns:
a new
Ggit.TreeBuilder
, orNone
if there was an error.- Return type:
Create a new tree builder.
- create_tree_builder_from_tree(tree)¶
- Parameters:
- Raises:
- Returns:
a new
Ggit.TreeBuilder
object, orNone
if there was an error.- Return type:
Create a tree builder for initialized with tree. To create an empty tree builder, use
Ggit.Repository.create_tree_builder
instead.
- delete_tag(name)¶
- Parameters:
name (
str
) – the name of the tag.- Raises:
- Returns:
- Return type:
Delete an existing tag reference by name.
- drop_stash(index)¶
- Parameters:
index (
int
) – the position within the stash list. 0 points to the. most recent stashed state.- Raises:
Removes a single stashed state from the stash list.
- enumerate_branches(list_type)¶
- Parameters:
list_type (
Ggit.BranchType
) – aGgit.BranchType
.- Raises:
- Returns:
a branch enumerator.
- Return type:
Get a branch enumerator to enumerate over all branches of the specified list_type in self.
- file_status(location)¶
- Parameters:
location (
Gio.File
) – the file to retrieve status for, rooted at the repository working dir.- Raises:
- Returns:
the status for a single file.
- Return type:
Gets the file status for a single file.
- file_status_foreach(options, callback, *user_data)¶
- Parameters:
options (
Ggit.StatusOptions
orNone
) – status options, orNone
.callback (
Ggit.StatusCallback
) – aGgit.StatusCallback
.
- Raises:
- Returns:
- Return type:
Gathers file statuses and run a callback for each one.
To the callback is passed the path of the file, the status and the data pointer passed to this function. If the callback returns something other than 0, the iteration will stop and error will be set.
Set options to
None
to get the default status options.
- get_ahead_behind(local, upstream)¶
- Parameters:
- Raises:
- Returns:
- ahead:
number of unique from commits in upstream.
- behind:
number of unique from commits in local.
- Return type:
Count the number of unique commits between two commit objects.
There is no need for branches containing the commits to have any upstream relationship, but it helps to think of one as a branch and the other as its upstream, the ahead and behind values will be what git would report for the branches.
- get_attribute(path, name, flags)¶
- Parameters:
path (
str
) – the relative path to the file.name (
str
) – the name of the attribute.flags (
Ggit.AttributeCheckFlags
) – aGgit.AttributeCheckFlags
.
- Raises:
- Returns:
the attribute value, or
None
.- Return type:
Get the attribute value of the specified attribute for the given file.
- get_config()¶
- Raises:
- Returns:
a
Ggit.Config
.- Return type:
Ggit.Config
orNone
Get the config for a specific repository.
- get_default_notes_ref()¶
- Raises:
- Returns:
the default notes reference for self.
- Return type:
Gets the default notes reference for self. It defaults to “refs/notes/commits”.
- get_descendant_of(commit, ancestor)¶
- Parameters:
- Raises:
- Returns:
True
if commit is a descendant of ancestor, orFalse
otherwise.- Return type:
Check whether com mit is a descendant of ancestor. Note that if this function returns
False
, an error might have occurred. If so, error will be set appropriately.
- get_head()¶
- Raises:
- Returns:
a
Ggit.Ref
- Return type:
Get and resolves the current HEAD reference of the repository. Note that the returned ref is already resolved (if HEAD is symbolic). If you want to retrieve the symbolic ref called HEAD, then use
Ggit.Repository.lookup_reference
instead.
- get_index()¶
- Raises:
- Returns:
a
Ggit.Index
.- Return type:
Ggit.Index
orNone
Get the index for a specific repository.
- get_location()¶
-
Get the gitdir location of the repository.
- get_submodule_status(name, ignore)¶
- Parameters:
name (
str
) – the name of the submodule.ignore (
Ggit.SubmoduleIgnore
) – the ignore rules to follow.
- Raises:
- Returns:
the
Ggit.SubmoduleStatus
for submodule.- Return type:
Gets the status for a submodule. This looks at a submodule and tries to determine the status. It will return a combination of the %GGIT_SUBMODULE_STATUS values. How deeply it examines the working directory to do this will depend on ignore.
- get_workdir()¶
-
Gets the working directory of the repository.
- is_empty()¶
- Raises:
- Returns:
True
if the repository is empty.- Return type:
Checks if self is empty.
An empty repository has just been initialized and contains no commits.
- is_head_detached()¶
- Raises:
- Returns:
True
if HEAD is detached.- Return type:
Checks if self's HEAD is detached.
A repository’s HEAD is detached when it points directly to a commit instead of a branch.
- is_head_unborn()¶
- Raises:
- Returns:
True
if the current branch is an orphan.- Return type:
Checks if self's HEAD is an orphan.
An orphan branch is one named from HEAD but doesn’t exist in the refs namespace, because it doesn’t have any commit to point to.
- list_remotes()¶
- Raises:
- Returns:
a list with the remotes.
- Return type:
Fill a list with all the remotes in self.
- list_tags()¶
- Raises:
- Returns:
a list with the tags in self.
- Return type:
Fill a list with all the tags in the self.
- list_tags_match(pattern)¶
- Parameters:
- Raises:
- Returns:
a list with matching tags in self.
- Return type:
Fill a list with all the tags in the self matching the provided pattern. The pattern can use standard fnmatch syntax.
- lookup(oid, gtype)¶
- Parameters:
gtype (
GObject.GType
) – aGObject.GType
.
- Raises:
- Returns:
the found
Ggit.Object
, orNone
on error.- Return type:
Ggit.Object
orNone
Lookups a reference to one of the objects in the self.
The generated reference must be freed with
GObject.Object.unref
().The gtype must match the type of the object in the odb; the method will fail otherwise. The special value
GObject.TYPE_NONE
may be passed to let the method guess the object’s type.
- lookup_blob(oid)¶
- Parameters:
- Raises:
- Returns:
a #GgitBlog pointer.
- Return type:
Lookups a branch by its name in a repository.
- lookup_branch(branch_name, branch_type)¶
- Parameters:
branch_name (
str
) – the name of the branch.branch_type (
Ggit.BranchType
) – aGgit.BranchType
.
- Raises:
- Returns:
a branch by its name in a repository.
- Return type:
Ggit.Branch
orNone
Lookups a branch by its name in a repository.
- lookup_commit(oid)¶
- Parameters:
- Raises:
- Returns:
a
Ggit.Commit
pointer.- Return type:
Ggit.Commit
orNone
Lookups a branch by its name in a repository.
- lookup_reference(name)¶
- Parameters:
name (
str
) – the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, …).- Raises:
- Returns:
the searched reference.
- Return type:
Lookups a reference by its name in self. The returned
Ggit.Ref
must be freed withGObject.Object.unref
().
- lookup_reference_dwim(short_name)¶
- Parameters:
short_name (
str
) – the short name for the reference (e.g. master, v0.1.0, …).- Raises:
- Returns:
the searched reference.
- Return type:
Lookups a reference by its short name in self applying the git precendence rules to the given shorthand to determine which reference the user is referring to. The returned
Ggit.Ref
must be freed withGObject.Object.unref
().
- lookup_remote(name)¶
- Parameters:
name (
str
) – the remote’s name.- Raises:
- Returns:
a new
Ggit.Remote
orNone
if there is an error.- Return type:
Ggit.Remote
orNone
Gets the remote called name.
- lookup_submodule(name)¶
- Parameters:
name (
str
) – the name of the submodule.- Raises:
- Returns:
a newly-allocated
Ggit.Submodule
.- Return type:
Lookups a submodule information by name or path. If the submodule does not exist,
None
is returned and aGgit.Error.NOTFOUND
error set.
- lookup_tag(oid)¶
- Parameters:
- Raises:
- Returns:
a
Ggit.Tag
pointer.- Return type:
Lookups a branch by its name in a repository.
- lookup_tree(oid)¶
- Parameters:
- Raises:
- Returns:
a
Ggit.Tree
pointer.- Return type:
Lookups a branch by its name in a repository.
- merge(their_heads, merge_opts, checkout_opts)¶
- Parameters:
their_heads ([
Ggit.AnnotatedCommit
]) – the heads to merge intomerge_opts (
Ggit.MergeOptions
) – merge optionscheckout_opts (
Ggit.CheckoutOptions
) – checkout options
- Raises:
Merges the given commit(s) into HEAD, writing the results into the working directory. Any changes are staged for commit and any conflicts are written to the index.
Callers should inspect the repository’s index after this completes, resolve any conflicts and prepare a commit.
- merge_base(oid_one, oid_two)¶
- Parameters:
- Raises:
- Returns:
- Return type:
Find the merge base between two commits
- merge_commits(our_commit, their_commit, merge_options)¶
- Parameters:
our_commit (
Ggit.Commit
) – the commit that reflects the destination tree.their_commit (
Ggit.Commit
) – the commit that reflects the source tree.merge_options (
Ggit.MergeOptions
) – the merge options.
- Raises:
- Returns:
a new
Ggit.Index
orNone
if an error occurred.- Return type:
Ggit.Index
orNone
Merge two commits creating a
Ggit.Index
reflecting the result of the merge.
- merge_trees(ancestor_tree, our_tree, their_tree, merge_options)¶
- Parameters:
ancestor_tree (
Ggit.Tree
) – the common ancestor between the trees, orNone
.our_tree (
Ggit.Tree
) – the tree that reflects the destination tree.their_tree (
Ggit.Tree
) – the tree that reflects the source tree.merge_options (
Ggit.MergeOptions
) – the merge options.
- Raises:
- Returns:
a new
Ggit.Index
orNone
if an error occurred.- Return type:
Ggit.Index
orNone
Merge two trees creating a
Ggit.Index
reflecting the result of the merge.
- note_foreach(notes_ref, callback, *user_data)¶
- Parameters:
notes_ref (
str
orNone
) – canonical name of the reference to use, orNone
to use the default ref.callback (
Ggit.NoteCallback
) – aGgit.NoteCallback
.
- Raises:
- Returns:
- Return type:
Loop over all the notes within a specified namespace and issue a callback for each one. If callback returns a non-zero value, this will stop looping.
- path_is_ignored(path)¶
- Parameters:
path (
str
) – A path within the repository.- Raises:
- Returns:
True
if path should be ignored.- Return type:
Tests if the ignore rules apply to the path provided.
This acts similar to filtering performed when calling “git add .” on the command line.
- read_note(notes_ref, id)¶
- Parameters:
- Raises:
- Returns:
the read note or
None
in case of an error.- Return type:
Reads the note for an object.
- rebase_init(branch, upstream, onto, options)¶
- Parameters:
branch (
Ggit.AnnotatedCommit
orNone
) – the terminal commit to rebase, orNone
to rebase the current branch.upstream (
Ggit.AnnotatedCommit
orNone
) – the commit to begin rebasing from, orNone
to rebase all reachable commits.onto (
Ggit.AnnotatedCommit
orNone
) – the branch to rebase onto, orNone
to rebase onto the given upstream.options (
Ggit.RebaseOptions
) – aGgit.RebaseOptions
to specify how rebase is performed, orNone
.
- Raises:
- Returns:
a newly allocated
Ggit.Rebase
.- Return type:
Ggit.Rebase
orNone
Initializes a rebase operation to rebase the changes in branch relative to upstream onto another branch. To begin the rebase process, call git_rebase_next(). When you have finished with this object, call
GObject.Object.unref
().
- rebase_open(options)¶
- Parameters:
options (
Ggit.RebaseOptions
) – aGgit.RebaseOptions
to specify how rebase is performed, orNone
.- Raises:
- Returns:
a newly allocated
Ggit.Rebase
.- Return type:
Ggit.Rebase
orNone
Opens an existing rebase that was previously started by either an invocation of ggit_rebase_init() or by another client.
- references_foreach(callback, *user_data)¶
- Parameters:
callback (
Ggit.ReferencesCallback
) – aGgit.ReferencesCallback
.
- Raises:
- Returns:
- Return type:
Gathers references and run a callback for each one.
To the callback is passed the reference and the data pointer passed to this function. If the callback returns something other than 0, the iteration will stop and error will be set.
- references_foreach_name(callback, *user_data)¶
- Parameters:
callback (
Ggit.ReferencesNameCallback
) – aGgit.ReferencesNameCallback
.
- Raises:
- Returns:
- Return type:
Gathers reference names and run a callback for each one.
To the callback is passed the name of the reference and the data pointer passed to this function. If the callback returns something other than 0, the iteration will stop and error will be set.
- remove_note(notes_ref, author, committer, id)¶
- Parameters:
notes_ref (
str
orNone
) – canonical name of the reference to use, orNone
to use the default ref.author (
Ggit.Signature
) – author signature.committer (
Ggit.Signature
) – committer signature.id (
Ggit.OId
) – OID of the git object to decorate.
- Raises:
- Returns:
True
if the note was removed from id.- Return type:
Removes the note for an object.
- remove_remote(name)¶
- Parameters:
name (
str
) – the remote’s name.- Raises:
- Returns:
- Return type:
Removes remote from the self.
- rename_remote(name, new_name)¶
- Parameters:
- Raises:
- Returns:
non-default refspecs that cannot be renamed.
- Return type:
Rename the remote of self from name to new_name.
- reset(target, reset_type, checkout_options)¶
- Parameters:
target (
Ggit.Object
) – the targetGgit.Object
which is a commit or a tag.reset_type (
Ggit.ResetType
) – theGgit.ResetType
to perform.checkout_options (
Ggit.CheckoutOptions
) – theGgit.CheckoutOptions
to be used for a HARD reset.
- Raises:
Performs a reset of type reset_type on self to target, or error will be set.
- reset_default(target, pathspecs)¶
- Parameters:
target (
Ggit.Object
orNone
) – the targetGgit.Object
which is a commit or a tag.pathspecs ([
str
]) – a list of file paths to reset.
- Raises:
Update some entries in the index from the target commit tree. The scope of the updated entries is determined by the paths specified in pathspecs. Passing
None
in target will result in removing entries in the index matching the provided pathspecs.
- revert(commit, options)¶
- Parameters:
commit (
Ggit.Commit
) – aGgit.Commit
.options (
Ggit.RevertOptions
) – aGgit.RevertOptions
.
- Raises:
- Returns:
- Return type:
Revert the given commit on top of the current working directory.
- revparse(spec)¶
- Parameters:
spec (
str
) – the revision specification.- Raises:
- Returns:
a
Ggit.Object
orNone
if the revision could not be found.- Return type:
Ggit.Object
orNone
Find an object, as specified by a revision string. See
man gitrevisions
, or the documentation forgit rev-parse
for information on the syntax accepted.
- save_stash(stasher, message, flags)¶
- Parameters:
stasher (
Ggit.Signature
) – aGgit.Signature
.message (
str
) – description along with the stashed state orNone
to be autogenerated.flags (
Ggit.StashFlags
) – aGgit.StashFlags
to control the stashing process.
- Raises:
- Returns:
a new object id of the commit containing the stashed state.
- Return type:
Saves the local modifications to a new stash. It returns the commit containing the stashed state. This commit is also the target of the direct reference refs/stash.
- set_head(ref_name)¶
- Parameters:
ref_name (
str
) – canonical name of the reference HEAD should point to.- Raises:
- Returns:
- Return type:
- set_head_detached(oid)¶
- Parameters:
oid (
Ggit.OId
) – canonical Object id of the Commit the HEAD should point to.- Raises:
- Returns:
- Return type:
- set_remote_url(remote, url)¶
- Parameters:
- Raises:
- Returns:
- Return type:
Sets url for the remote from the self.
- set_submodule_fetch_recurse(name, fetch_recurse_submodules)¶
- Parameters:
name (
str
) – the name of the submodule.fetch_recurse_submodules (
Ggit.SubmoduleRecurse
) – aGgit.SubmoduleRecurse
.
- Raises:
Sets the submodule.’name’.fetchRecurseSubmodules value for the submodule. This setting won’t affect any existing instances..
- set_submodule_ignore(name, ignore)¶
- Parameters:
name (
str
) – the name of the submodule.ignore (
Ggit.SubmoduleIgnore
) – aGgit.SubmoduleIgnore
.
- Raises:
Sets the ignore rule for the submodule in the configuration. This does not affect any currently-loaded instances..
- set_submodule_update(name, update)¶
- Parameters:
name (
str
) – the name of the submodule.update (
Ggit.SubmoduleUpdate
) – aGgit.SubmoduleUpdate
.
- Raises:
Sets the update rule for the submodule in the configuration. This setting won’t affect any existing instances.
- set_submodule_url(name, url)¶
- Parameters:
- Raises:
Sets the URL for the submodule in the configuration.
After calling this, you may wish to call
Ggit.Submodule.sync
() to write the changes to the checked out submodule repository.
- set_workdir(workdir, update_gitlink)¶
- Parameters:
Sets the working directory of the repository. If update_gitlink is set to
True
“core.worktree” will be set in the config if workdir is not the parent of the .git directory).
- stash_foreach(callback, *user_data)¶
- Parameters:
callback (
Ggit.StashCallback
) – aGgit.StashCallback
.
- Raises:
- Returns:
- Return type:
Loops over all the stashed states and issue a callback for each one. If callback returns a non-zero value, this will stop looping.
- submodule_foreach(callback, *user_data)¶
- Parameters:
callback (
Ggit.SubmoduleCallback
) – aGgit.StatusCallback
.
- Raises:
- Returns:
- Return type:
Gathers submodules and run a callback for each one.
To the callback is passed the submodule instance and name. If the callback returns something other than 0, the iteration will stop and error will be set.
NOTE: the submodule instance passed to the callback is only valid during the call to
Ggit.Repository.submodule_foreach
and may not be used after the call has finished.
- tag_foreach(callback, *user_data)¶
- Parameters:
callback (
Ggit.TagCallback
) – aGgit.TagCallback
.
- Raises:
- Returns:
- Return type:
Get all the tags in the repository and run the provided callback on each. If the callback returns something other than 0, the iteration will stop and error will be set.
Property Details¶
- Ggit.Repository.props.clone_options¶
- Name:
clone-options
- Type:
- Default Value:
- Flags:
Clone options
- Ggit.Repository.props.init¶
- Name:
init
- Type:
- Default Value:
- Flags:
Whether to initialize a repository
- Ggit.Repository.props.is_bare¶
- Name:
is-bare
- Type:
- Default Value:
- Flags:
Is a bare repository
- Ggit.Repository.props.location¶
- Name:
location
- Type:
- Default Value:
- Flags:
The location of the repository
- Ggit.Repository.props.url¶
- Name:
url
- Type:
- Default Value:
- Flags:
The URL for cloning a repository