Git#

class mobu.storage.git.Git(*, repo=None, config_location=None, logger=None)#

Bases: object

A very basic async Git client based on asyncio.subprocess.

Parameters:
  • repo (Path | None, default: None) – Filesystem path for the git repository.

  • config_location (Path | None, default: None) – Filesystem path for the file to use as the user-global Git config.

  • logger (BoundLogger | None, default: None) – Logger to use.

Methods Summary

add(*args)

Run git add with arbitrary arguments.

branch(*args)

Run git branch with arbitrary arguments.

checkout(*args)

Run git checkout with arbitrary arguments.

clone(*args)

Run git clone with arbitrary arguments.

commit(*args)

Run git commit with arbitrary arguments.

config(*args)

Run git config with arbitrary arguments.

fetch(*args)

Run git fetch with arbitrary arguments.

git(*args)

Run an arbitrary git command with arbitrary string arguments.

init(*args)

Run git init with arbitrary arguments.

lfs(*args)

Run git lfs with arbitrary arguments.

pull(*args)

Run git pull with arbitrary arguments.

push(*args)

Run git commit with arbitrary arguments.

repo_hash()

Get the commit hash of the currently cloned repo.

reset(*args)

Run git reset with arbitrary arguments.

Methods Documentation

async add(*args)#

Run git add with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async branch(*args)#

Run git branch with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async checkout(*args)#

Run git checkout with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async clone(*args)#

Run git clone with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async commit(*args)#

Run git commit with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async config(*args)#

Run git config with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async fetch(*args)#

Run git fetch with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async git(*args)#

Run an arbitrary git command with arbitrary string arguments.

Constrain the environment of the subprocess: only pass HOME, LANG, PATH, and any GIT variables.

If self.repo is set, use that as the working directory. If self._config_location is set, use that as the value of GIT_CONFIG_GLOBAL, and set GIT_CONFIG_SYSTEM to the empty string.

This is intended to constrain where git looks for its definitions, making it both function in mobu business and not break developers’ git setups.

Parameters:

args (str)

Return type:

Output

async init(*args)#

Run git init with arbitrary arguments.

If self.repo is None, and this is run, it will set self.repo from the last argument as a side effect. If there are no arguments, self.repo becomes the current working directory.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async lfs(*args)#

Run git lfs with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async pull(*args)#

Run git pull with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async push(*args)#

Run git commit with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None

async repo_hash()#

Get the commit hash of the currently cloned repo.

Return type:

str

async reset(*args)#

Run git reset with arbitrary arguments.

Parameters:

*args (str) – Arguments to command.

Return type:

None