pcvs.helpers.git module
- class pcvs.helpers.git.Blob(repo, id, prefix='', data='')[source]
Bases:
Tree
Maps a Git ‘blob’ object, dedicated to hold data (“leaves” in Git trees)
- class pcvs.helpers.git.Branch(repo, name='master')[source]
Bases:
Reference
Maps to a regular Git branch.
- class pcvs.helpers.git.Commit(repo, obj, metadata={})[source]
Bases:
Reference
Maps to a regular Git commit
- class pcvs.helpers.git.GitByAPI(prefix=None)[source]
Bases:
GitByGeneric
Manage repository through a third-party Python module.
Currently, this work is based on pygit2.
- property branches
Returns the list of available local branche names from this repo.
This is an abstract function as its behavior depends on derived classes.
- commit(tree, msg='No data', timestamp=None, parent=None, orphan=False)[source]
Create a commit from changes.
- get_parents(ref)[source]
Retrieve parents for a given ref.
This method is not a part of a Reference object as the approach changes depending on the Git method used (lazy resolution).
- Parameters
ref (Reference) – the revision
- get_tree(rev=None, prefix='')[source]
Retrieve data associated with a given prefix. A tree can used to set which ref should be used.
- Param[in] tree
the ref from where get the data
- Param[in] prefix
the unique prefix associated with data
- insert_tree(prefix, data, root=None)[source]
Create a new tree mapping a prefix filled with ‘data’.
- Param[in] prefix
the prefix under Git tree.
- Param[in] data
the data to store.
- iterate_over(rev=None)[source]
starting from the ref, iterate references backwards (from newest to oldest).
- Parameters
ref (Reference) – the starting point
- list_commits(rev=None, since=None, until=None)[source]
List past commits finishing with ‘rev’.
The list can be shrunk with a start & end
- Parameters
rev – the revision to extract commit from
since (date) – the oldest commit should be newer than this date
until (date) – the newest commit should be older than this date
- Typ rev
any
- list_files(rev=None, prefix='')[source]
For a given revision, list files (not only changed ones).
- Parameters
rev (Reference) – the revision
- class pcvs.helpers.git.GitByCLI(prefix='')[source]
Bases:
GitByGeneric
Git endpoint ot manipulate a repository through basic CLI.
Currently relying on the sh module.
- property branches
Returns the list of available local branche names from this repo.
This is an abstract function as its behavior depends on derived classes.
- commit(tree, msg='VOID', timestamp=None, parent=None, orphan=False)[source]
Create a commit from changes.
- get_parents(ref)[source]
Retrieve parents for a given ref.
This method is not a part of a Reference object as the approach changes depending on the Git method used (lazy resolution).
- Parameters
ref (Reference) – the revision
- get_tree(rev=None, prefix='')[source]
Retrieve data associated with a given prefix. A tree can used to set which ref should be used.
- Param[in] tree
the ref from where get the data
- Param[in] prefix
the unique prefix associated with data
- insert_tree(prefix, data, root=None)[source]
Create a new tree mapping a prefix filled with ‘data’.
- Param[in] prefix
the prefix under Git tree.
- Param[in] data
the data to store.
- iterate_over(ref)[source]
starting from the ref, iterate references backwards (from newest to oldest).
- Parameters
ref (Reference) – the starting point
- list_commits(rev=None, since='', until='')[source]
List past commits finishing with ‘rev’.
The list can be shrunk with a start & end
- Parameters
rev – the revision to extract commit from
since (date) – the oldest commit should be newer than this date
until (date) – the newest commit should be older than this date
- Typ rev
any
- list_files(prefix)[source]
For a given revision, list files (not only changed ones).
- Parameters
rev (Reference) – the revision
- class pcvs.helpers.git.GitByGeneric(prefix=None, head='unknown/00000000')[source]
Bases:
ABC
Create a Git endpoint able to discuss efficiently with repositories.
This base classe serves abstract methods to be implemented to create a new derived class. Currently are provided: - GitByAPI: relies on python module pygit2 (requires libgit2) - GitByCLI: based on regular Git program invocations (require git program)
- abstract property branches
Returns the list of available local branche names from this repo.
This is an abstract function as its behavior depends on derived classes.
- abstract commit(tree, msg='No data', timestamp=None, parent=None, orphan=False)[source]
Create a commit from changes.
- get_head()[source]
Get the current repo’s HEAD (used when no default)
- Returns
a ref to the HEAD as a branch
- Return type
- abstract get_parents(ref)[source]
Retrieve parents for a given ref.
This method is not a part of a Reference object as the approach changes depending on the Git method used (lazy resolution).
- Parameters
ref (Reference) – the revision
- abstract get_tree(tree, prefix)[source]
Retrieve data associated with a given prefix. A tree can used to set which ref should be used.
- Param[in] tree
the ref from where get the data
- Param[in] prefix
the unique prefix associated with data
- abstract insert_tree(prefix, data)[source]
Create a new tree mapping a prefix filled with ‘data’.
- Param[in] prefix
the prefix under Git tree.
- Param[in] data
the data to store.
- abstract iterate_over(ref)[source]
starting from the ref, iterate references backwards (from newest to oldest).
- Parameters
ref (Reference) – the starting point
- abstract list_commits(rev, since, until)[source]
List past commits finishing with ‘rev’.
The list can be shrunk with a start & end
- Parameters
rev – the revision to extract commit from
since (date) – the oldest commit should be newer than this date
until (date) – the newest commit should be older than this date
- Typ rev
any
- abstract list_files(rev)[source]
For a given revision, list files (not only changed ones).
- Parameters
rev (Reference) – the revision
- abstract revparse(rev)[source]
Convert a revision (tag, branch, commit) to a regular reference.
- Parameters
rev (Reference) – Reference
- class pcvs.helpers.git.Reference(repo)[source]
Bases:
object
Maps an object which can be “pointed” (as a Git semantic). It can usually be used to refer a commit, a simple hash or a branch.
- property repo
Getter to the repo this reference comes from.
- class pcvs.helpers.git.Tree(repo, id, prefix='', children=[])[source]
Bases:
Reference
Maps to a git-lowlevel Tree object
- classmethod as_root(repo, hdl, children=[])[source]
Create a Tree and attach it with the git-specific handler (if any)
- Parameters
repo (any) – the repo handle
hdl (any) – the git-specific root handle
children (any) – any prebuild children for this root node
- Returns
the created Tree object
- Return type
- pcvs.helpers.git.elect_handler(prefix=None)[source]
Select the proper repository handler based on python support
Python 3.7+-based PCVS installations come with pygit2, thanks to provided wheels. Older versions are relying on regular Git commands (as wheels are not provided for Python3.6 and older & building pygit2 requires specific libgit2 version to be installed, hardening the installation process)
- pcvs.helpers.git.get_current_usermail()[source]
Get the git user mail.
- Returns
git user mail
- Return type