Ggit.Ref¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Ggit.Ref(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Reprensents a git reference.
- classmethod is_valid_name(name)¶
- Parameters:
name (
str
) – the name to validate.- Returns:
- Return type:
Check if the given name is a valid name for a reference. Note that name should be the full ref name (including prefixes).
Valid toplevel names can contain only capital letters and underscores and must start and end with a letter (e.g. HEAD, ORIG_HEAD).
Valid refs/ names may contain any characters, except ‘~’, ‘^’, ‘:’, ‘\’, ‘?’, ‘[’, ‘*’, “..” and “@{”, because they are interpreted by revparse.
- delete()¶
- Raises:
Deletes self.
This method works for both direct and symbolic references.
The reference will be immediately removed on disk and from memory. The given reference pointer will no longer be valid.
- delete_log()¶
- Raises:
Deletes the log for self, on error error is set.
- get_log()¶
- Raises:
- Returns:
the reflog or
None
.- Return type:
Ggit.Reflog
orNone
Gets the
Ggit.Reflog
for self. The reflog will be created if it doesn’t exist yet.
- get_name()¶
-
Gets the full name of self.
- get_owner()¶
- Returns:
the repository where a reference resides or
None
.- Return type:
Gets the repository where self resides.
- get_reference_type()¶
- Returns:
the type of a reference.
- Return type:
Gets the type of self. Either direct (
Ggit.RefType.OID
) or symbolic (Ggit.RefType.SYMBOLIC
).
- get_shorthand()¶
-
Gets the shorthand name of self.
- get_symbolic_target()¶
-
Get full name to the reference pointed to by a symbolic reference. Only available if the reference is symbolic.
- get_target()¶
-
Get the OID pointed to by a direct reference. Only available if the reference is direct (i.e. an object id reference, not a symbolic one).
- has_log()¶
-
Get whether self has an existing log.
- is_branch()¶
-
Check whether the reference is a branch.
- is_note()¶
-
Check whether the reference is a note.
- is_remote()¶
-
Check whether the reference is a remote.
- is_tag()¶
-
Check whether the reference is a tag.
- lookup()¶
- Raises:
- Returns:
a
Ggit.Object
orNone
.- Return type:
Ggit.Object
orNone
Convenient method to resolve a reference to an object.
- rename(new_name, force, log_message)¶
- Parameters:
- Raises:
- Returns:
- Return type:
Rename an existing reference.
This method works for both direct and symbolic references.
The new name will be checked for validity. See
ggit_ref_create_symbolic()
for rules about valid names.If not error, self will be deleted from disk and a new
Ggit.Ref
will be returned.The reference will be immediately renamed in-memory and on disk.
If the
force
flag is not enabled, and there’s already a reference with the given name, the renaming will fail.IMPORTANT: The user needs to write a proper reflog entry if the reflog is enabled for the repository. We only rename the reflog if it exists.
- resolve()¶
- Raises:
- Returns:
the resolved reference to the peeled one or
None
.- Return type:
Resolves a symbolic reference.
This method iteratively peels a symbolic reference until it resolves to a direct reference to an OID.
If a direct reference is passed as an argument, that reference is returned immediately.
- set_symbolic_target(target, log_message)¶
- Parameters:
- Raises:
- Returns:
- Return type:
Create a new reference with the same name as the given reference but a different symbolic target. The reference must be a symbolic reference, otherwise this will fail.
The new reference will be written to disk, overwriting the given reference.
The target name will be checked for validity. See
ggit_ref_create_symbolic()
for rules about valid names.
- set_target(oid, log_message)¶
- Parameters:
- Raises:
- Returns:
- Return type:
Create a new reference with the same name as the given reference but a different OID target. The reference must be a direct reference, otherwise this will fail.
The new reference will be written to disk, overwriting the given reference.