AsyncGit¶
(Fully qualified class: privex.helpers.extras.git._AsyncGit
)
-
class
privex.helpers.extras.git.
_AsyncGit
(repo: str = None, default_version: str = 'HEAD', **kwargs)[source]¶ Git CLI wrapper class - methods can be used both synchronously and async via
AsyncGit
/Git
(aliases, both are the same)This class uses the
awaitable_class()
decorator to make the class work both synchronously and asynchronously, without needing to duplicate code.The
awaitable_class()
decorator detects whether the methods are being called from a synchronous, or an asynchronous function/method.If they’re being called from an async function, then a coroutine will be returned, and must be
await
’ed.If they’re being called from a synchronous function, then it will spin up an event loop, run the method in the event loop, then return the result transparently.
Synchronous usage:
>>> from privex.helpers import Git >>> g = Git() # Git is an alias for AsyncGit, there is no difference between them >>> >>> def some_func(): ... current_commit = g.get_current_commit() ... print(current_commit) 'ac52b28f551825160785f9ea7e96f86ccc869cc1'
Asynchronous usage:
>>> from privex.helpers import Git >>> g = Git() # Git is an alias for AsyncGit, there is no difference between them >>> >>> async def some_func(): ... current_commit = await g.get_current_commit() ... print(current_commit) 'ac52b28f551825160785f9ea7e96f86ccc869cc1'
Methods
|
Initialize self. |
|
If an attribute doesn’t exist, this method will return a |
|
|
|
Use like |
|
|
|
|
|
Calls |
|
Get current active branch/tag. |
|
Get current commit hash. |
|
Get the latest tag on this branch - useful for detecting current version of your python application. |
|
Wrapper async method for calling |
|
Use like |
|
|
|
|
|