Package API
All of the command-line interface functionality is available from the Python package:
import gitman
Init
To generate a sample config for a new project, call:
gitman.init()
Install
To clone/checkout the specified dependencies, call:
gitman.install(*names, root=None, depth=None,
force=False, fetch=False, clean=True skip_changes=False)
with optional arguments:
*names
: optional list of dependency source or group names to filter onroot
: specifies the path to the root working treedepth
: number of levels of dependencies to traverseforce
: indicates uncommitted changes can be overwritten and script errors can be ignoredfetch
: indicates the latest branches should always be fetchedclean
: indicates untracked files should be deleted from dependenciesskip_changes
: indicates dependencies with uncommitted changes should be skipped
Update
If any of the dependencies track a branch (rather than a specific commit), the current upstream version of that branch can be checked out by calling:
gitman.update(*names, root=None, depth=None, recurse=False,
force=False, clean=True, lock=None, skip_changes=False)
with optional arguments:
*names
: optional list of dependency source or group names to filter onroot
: specifies the path to the root working treedepth
: number of levels of dependencies to traverserecurse
: indicates nested dependencies should also be updatedforce
: indicates uncommitted changes can be overwritten and script errors can be ignoredclean
: indicates untracked files should be deleted from dependencieslock
: indicates updated dependency versions should be recordedskip_changes
: indicates dependencies with uncommitted changes should be skipped
List
To display the currently checked out dependencies, call:
gitman.list(root=None, depth=None, allow_dirty=True)
with optional arguments:
root
: specifies the path to the root working treedepth
: number of levels of dependencies to traverseallow_dirty
: causes uncommitted changes to be ignored
Lock
To record the exact versions of currently checked out dependencies, call:
gitman.lock(*names, root=None)
with optional arguments:
*names
: optional list of dependency source or group names to filter onroot
: specifies the path to the root working tree
and specific versions per source:
- Each name may be followed by
@<sha>
,@<branch>
, or@<tag>
- For example:
*names = ["source1@abc123", source2@v1.0", "source3"]
source1
will be locked to theabc123
SHA if it existssource2
will be locked to thev1.0
tag if it existssource3
will be locked to the currently checked out version
Uninstall
To delete all dependencies, call:
gitman.uninstall(root=None, force=False, keep_location=False)
with optional arguments:
root
: specifies the path to the root working treeforce
: indicates uncommitted changes can be overwrittenkeep_location
: indicates that the top level folder should be kept