|
def | __init__ (self, repo, binsha, mode=None, path=None, name=None, parent_commit=None, url=None, branch_path=None) |
|
def | __eq__ (self, other) |
|
def | __ne__ (self, other) |
|
def | __hash__ (self) |
|
def | __str__ (self) |
|
def | __repr__ (self) |
|
def | add (cls, repo, name, path, url=None, branch=None, no_checkout=False, depth=None, env=None) |
|
def | update (self, recursive=False, init=True, to_latest_revision=False, progress=None, dry_run=False, force=False, keep_going=False, env=None) |
|
def | move (self, module_path, configuration=True, module=True) |
|
def | remove (self, module=True, force=False, configuration=True, dry_run=False) |
|
def | set_parent_commit (self, commit, check=True) |
|
def | config_writer (self, index=None, write=True) |
|
def | rename (self, new_name) |
|
def | module (self) |
|
def | module_exists (self) |
|
def | exists (self) |
|
def | branch (self) |
|
def | branch_path (self) |
|
def | branch_name (self) |
|
def | url (self) |
|
def | parent_commit (self) |
|
def | name (self) |
|
def | config_reader (self) |
|
def | children (self) |
|
def | iter_items (cls, repo, parent_commit='HEAD') |
|
def | __init__ (self, repo, binsha, mode=None, path=None) |
|
def | abspath (self) |
|
def | __init__ (self, repo, binsha) |
|
def | new (cls, repo, id) |
|
def | new_from_sha (cls, repo, sha1) |
|
def | hexsha (self) |
|
def | data_stream (self) |
|
def | stream_data (self, ostream) |
|
def | list_items (cls, repo, *args, **kwargs) |
|
def | iter_items (cls, repo, *args, **kwargs) |
|
def | list_traverse (self, *args, **kwargs) |
|
def | traverse (self, predicate=lambda i, True d, prune=lambda i, False d, depth=-1, branch_first=True, visit_once=True, ignore_self=1, as_edge=False) |
|
Implements access to a git submodule. They are special in that their sha
represents a commit in the submodule's repository which is to be checked out
at the path of this instance.
The submodule type does not have a string type associated with it, as it exists
solely as a marker in the tree and index.
All methods work in bare and non-bare repositories.
def add |
( |
|
cls, |
|
|
|
repo, |
|
|
|
name, |
|
|
|
path, |
|
|
|
url = None , |
|
|
|
branch = None , |
|
|
|
no_checkout = False , |
|
|
|
depth = None , |
|
|
|
env = None |
|
) |
| |
Add a new submodule to the given repository. This will alter the index
as well as the .gitmodules file, but will not create a new commit.
If the submodule already exists, no matter if the configuration differs
from the one provided, the existing submodule will be returned.
:param repo: Repository instance which should receive the submodule
:param name: The name/identifier for the submodule
:param path: repository-relative or absolute path at which the submodule
should be located
It will be created as required during the repository initialization.
:param url: git-clone compatible URL, see git-clone reference for more information
If None, the repository is assumed to exist, and the url of the first
remote is taken instead. This is useful if you want to make an existing
repository a submodule of anotherone.
:param branch: name of branch at which the submodule should (later) be checked out.
The given branch must exist in the remote repository, and will be checked
out locally as a tracking branch.
It will only be written into the configuration if it not None, which is
when the checked out branch will be the one the remote HEAD pointed to.
The result you get in these situation is somewhat fuzzy, and it is recommended
to specify at least 'master' here.
Examples are 'master' or 'feature/new'
:param no_checkout: if True, and if the repository has to be cloned manually,
no checkout will be performed
:param depth: Create a shallow clone with a history truncated to the
specified number of commits.
:param env: Optional dictionary containing the desired environment variables.
Note: Provided variables will be used to update the execution
environment for `git`. If some variable is not specified in `env`
and is defined in `os.environ`, value from `os.environ` will be used.
If you want to unset some variable, consider providing empty string
as its value.
:return: The newly created submodule instance
:note: works atomically, such that no change will be done if the repository
update fails for instance
def config_writer |
( |
|
self, |
|
|
|
index = None , |
|
|
|
write = True |
|
) |
| |
:return: a config writer instance allowing you to read and write the data
belonging to this submodule into the .gitmodules file.
:param index: if not None, an IndexFile instance which should be written.
defaults to the index of the Submodule's parent repository.
:param write: if True, the index will be written each time a configuration
value changes.
:note: the parameters allow for a more efficient writing of the index,
as you can pass in a modified index on your own, prevent automatic writing,
and write yourself once the whole operation is complete
:raise ValueError: if trying to get a writer on a parent_commit which does not
match the current head commit
:raise IOError: If the .gitmodules file/blob could not be read
def move |
( |
|
self, |
|
|
|
module_path, |
|
|
|
configuration = True , |
|
|
|
module = True |
|
) |
| |
Move the submodule to a another module path. This involves physically moving
the repository at our current path, changing the configuration, as well as
adjusting our index entry accordingly.
:param module_path: the path to which to move our module in the parent repostory's working tree,
given as repository-relative or absolute path. Intermediate directories will be created
accordingly. If the path already exists, it must be empty.
Trailing (back)slashes are removed automatically
:param configuration: if True, the configuration will be adjusted to let
the submodule point to the given path.
:param module: if True, the repository managed by this submodule
will be moved as well. If False, we don't move the submodule's checkout, which may leave
the parent repository in an inconsistent state.
:return: self
:raise ValueError: if the module path existed and was not empty, or was a file
:note: Currently the method is not atomic, and it could leave the repository
in an inconsistent state if a sub-step fails for some reason
def remove |
( |
|
self, |
|
|
|
module = True , |
|
|
|
force = False , |
|
|
|
configuration = True , |
|
|
|
dry_run = False |
|
) |
| |
Remove this submodule from the repository. This will remove our entry
from the .gitmodules file and the entry in the .git/config file.
:param module: If True, the module checkout we point to will be deleted
as well. If the module is currently on a commit which is not part
of any branch in the remote, if the currently checked out branch
working tree, or untracked files,
is ahead of its tracking branch, if you have modifications in the
In case the removal of the repository fails for these reasons, the
submodule status will not have been altered.
If this submodule has child-modules on its own, these will be deleted
prior to touching the own module.
:param force: Enforces the deletion of the module even though it contains
modifications. This basically enforces a brute-force file system based
deletion.
:param configuration: if True, the submodule is deleted from the configuration,
otherwise it isn't. Although this should be enabled most of the times,
this flag enables you to safely delete the repository of your submodule.
:param dry_run: if True, we will not actually do anything, but throw the errors
we would usually throw
:return: self
:note: doesn't work in bare repositories
:note: doesn't work atomically, as failure to remove any part of the submodule will leave
an inconsistent state
:raise InvalidGitRepositoryError: thrown if the repository cannot be deleted
:raise OSError: if directories or files could not be removed
def update |
( |
|
self, |
|
|
|
recursive = False , |
|
|
|
init = True , |
|
|
|
to_latest_revision = False , |
|
|
|
progress = None , |
|
|
|
dry_run = False , |
|
|
|
force = False , |
|
|
|
keep_going = False , |
|
|
|
env = None |
|
) |
| |
Update the repository of this submodule to point to the checkout
we point at with the binsha of this instance.
:param recursive: if True, we will operate recursively and update child-
modules as well.
:param init: if True, the module repository will be cloned into place if necessary
:param to_latest_revision: if True, the submodule's sha will be ignored during checkout.
Instead, the remote will be fetched, and the local tracking branch updated.
This only works if we have a local tracking branch, which is the case
if the remote repository had a master branch, or of the 'branch' option
was specified for this submodule and the branch existed remotely
:param progress: UpdateProgress instance or None if no progress should be shown
:param dry_run: if True, the operation will only be simulated, but not performed.
All performed operations are read-only
:param force:
If True, we may reset heads even if the repository in question is dirty. Additinoally we will be allowed
to set a tracking branch which is ahead of its remote branch back into the past or the location of the
remote branch. This will essentially 'forget' commits.
If False, local tracking branches that are in the future of their respective remote branches will simply
not be moved.
:param keep_going: if True, we will ignore but log all errors, and keep going recursively.
Unless dry_run is set as well, keep_going could cause subsequent/inherited errors you wouldn't see
otherwise.
In conjunction with dry_run, it can be useful to anticipate all errors when updating submodules
:param env: Optional dictionary containing the desired environment variables.
Note: Provided variables will be used to update the execution
environment for `git`. If some variable is not specified in `env`
and is defined in `os.environ`, value from `os.environ` will be used.
If you want to unset some variable, consider providing empty string
as its value.
:note: does nothing in bare repositories
:note: method is definitely not atomic if recurisve is True
:return: self