ctl.plugins.git
Plugin that allows you to manage a git repository
Functions
temporary_plugin
def temporary_plugin(ctl, name, path, **config)
Instantiate a temporary git plugin pointing at an existing checkout path.
Arguments
- ctl: ctl instance
- name: plugin name
- path: file path to a cloned git repository
Keyword Arguments
Any keyword arguments will be passed on to plugin config
Returns
GitPlugin
instance
Classes
GitPlugin
GitPlugin(ctl.plugins.repository.RepositoryPlugin)
manage a git repository
For information on the configuration schema please check
the RepositoryPlugin
documenation
Instanced Attributes
These attributes / properties will be available on instances of the class
- branch (
@property
): Return current branch name - is_clean (
@property
): Return whether the current repo checkout is clean - is_cloned (
@property
): returns whether or not the checkout_path location is a valid git repo or not - uuid (
@property
): return recent commit hash of the repo
Methods
branch_exists
def branch_exists(self, name)
Return if a branch exists in the local repo or not
Arguments
- name (
str
): branch name
Returns
True
if branch exists, False
if not
checkout
def checkout(self, branch, **kwargs)
Checkout a branch or tag
Arguments
- branch (
str
): branch name
Exposed to CLI
namespace: ctl.{plugin_name}.checkout
clone
def clone(self, **kwargs)
Clone the repo specified in repo_url
to checkout_path
Will only clone if there is no valid git repo at ceckout_path already
Exposed to CLI
namespace: ctl.{plugin_name}.clone
command
def command(self, *command)
Prepare git command to use with run_git_command
Will automaticdally prepare --git-dir
and --work-tree
options
Arguments
Any arguments passed will be joined together as a command
Returns
prepared command (list
)
commit
def commit(self, **kwargs)
Commit changes
Keyword Arguments
- files (
list
): list of files to commit, should be filenames relative to the repo root - message (
str
): commit message - push (
bool
=True
): push immediately
execute
def execute(self, **kwargs)
Execute plugin operation
Keyword Arguments
- op (
str
): operation to execute - needs to be exposed - checkout_path (
str
): override repo_url config param - repo_url (
str
): override repo_url config param
overrides and calls RepositoryPlugin.execute
merge
def merge(self, branch_a, branch_b, **kwargs)
Merge branch A into branch B
Arguments
- branch_a (
str
): name of branch to merge - branch_b (
str
): name of branch to merge into
Keyword Arguments
- push (
bool
): if true will push branch B after merge
pull
def pull(self, **kwargs)
Pull the repo
Exposed to CLI
namespace: ctl.{plugin_name}.pull
push
def push(self, **kwargs)
Push commits
run_git_command
def run_git_command(self, command)
Execute git command
Use command
to prepare command
Arguments
- command (
list
): command list that will be passed to subprocess
Returns
- captured output (
list
)
tag
def tag(self, version, message, **kwargs)
Tag the currently active branch
Arguments
- vrsion (
str
): tag version string / tag name - message (
str
): commit message