class DebianGitRepository(PkgGitRepository):
Known subclasses: gbp.deb.rollbackgit.RollbackDebianGitRepository
A git repository that holds the source of a Debian package
Class Method | tag |
Extract the version from a tag |
Class Method | version |
Generate a tag from a given format and a version |
Method | __init__ |
Undocumented |
Method | create |
Create pristine-tar commits for a package with main tarball and (optional) component tarballs based on upstream_tree |
Method | create |
Create a compressed orig tarball in output_dir using git archive |
Method | create |
Undocumented |
Method | debian |
Build the Debian version that a package based on upstream commit commit would carry taking into account a possible epoch. |
Method | find |
Check if a certain version is stored in this repo and return the SHA1 of the related commit. That is, an annotated tag is dereferenced to the commit object it points to. |
Method | get |
Get the pristine-tar commit for the given source package's latest version. |
Method | has |
Whether the repo has a pristine-tar branch. |
Method | tree |
Drop the given top level dirs from the given git tree returning a new tree object. |
Method | tree |
Get the SHA1 of directory in a given tree |
Method | vcs |
If linking to the upstream VCS get the commit id |
Instance Variable | pristine |
Undocumented |
Property | pristine |
The name of the pristine-tar branch, whether it already exists or not. |
Class Method | _mangle |
Basic version mangling to replace single characters |
Class Method | _unmangle |
Reverse of _mangle_version for format |
Class Method | _unmangle |
Reverse of _mangle_version for version |
Static Method | _build |
Legacy tags (prior to 0.5.5) dropped epochs and didn't honor the '~' |
Static Method | _sanitize |
sanitize a version so git accepts it as a tag |
Static Method | _unsanitize |
Reverse _sanitize_version |
Inherited from PkgGitRepository
:
Static Method | sanitize |
Make sure git-archive prefix ends with a slash |
Method | archive |
Create a compressed source tree archive with the given options |
Method | _archive |
Create a compressed source tree archive without submodules |
Method | _archive |
Create a compressed source tree archive with submodules. |
Extract the version from a tag
>>> DebianGitRepository.tag_to_version("upstream/1%2_3-4", "upstream/%(version)s") '1:2~3-4' >>> DebianGitRepository.tag_to_version("foo/2.3.4", "foo/%(version)s") '2.3.4' >>> DebianGitRepository.tag_to_version("v1-2-3", "v%(version%.%-)s") '1.2.3' >>> DebianGitRepository.tag_to_version("v1.#.2", "v%(version%.%-)s") '1..2' >>> DebianGitRepository.tag_to_version("foo/2.3.4", "upstream/%(version)s")
Generate a tag from a given format and a version
%(version)s provides a clean version that works as a git tag.
%(hversion)s provides the same thing, but with '.' replaced with '-'. hversion is useful for upstreams with tagging policies that prohibit . characters.
%(version%A%B)s provides %(version)s with string 'A' replaced by 'B'. This way, simple version mangling is possible via substitution. Inside the substition string, '%' needs to be escaped. See the examples below.
>>> DebianGitRepository.version_to_tag("debian/%(version)s", "0:0~0") 'debian/0%0_0' >>> DebianGitRepository.version_to_tag("libfoo-%(hversion)s", "1.8.1") 'libfoo-1-8-1' >>> DebianGitRepository.version_to_tag("v%(version%.%_)s", "1.2.3") 'v1_2_3' >>> DebianGitRepository.version_to_tag(r'%(version%-%\%)s', "0-1.2.3") '0%1.2.3'
gbp.pkg.git.PkgGitRepository.__init__
gbp.deb.rollbackgit.RollbackDebianGitRepository
Undocumented
Create pristine-tar commits for a package with main tarball and (optional) component tarballs based on upstream_tree
Parameters | |
upstream | the treeish in the git repo to create the commits against |
sources | Undocumented |
soures | list of tarball as UpstreamSource. First one being the main tarball the other ones additional tarballs. |
Create a compressed orig tarball in output_dir using git archive
Parameters | |
source:DebianSource | debian source package |
output | output directory |
treeish:str | git treeish |
comp:Compressor | compressor |
with | wether to add submodules |
component: str Raises GitRepositoryError in case of an error | component to add to tarball name |
type | str |
Undocumented
Build the Debian version that a package based on upstream commit commit would carry taking into account a possible epoch.
Parameters | |
upstream | the tag format on the upstream branch |
upstream | the upstream branch |
commit | the commit to search for the latest upstream version |
epoch | an epoch to use |
debian | If set to False don't append a Debian release number to the version number |
Returns | |
a new debian version | |
Raises | |
GitRepositoryError | if no upstream tag was found |
Check if a certain version is stored in this repo and return the SHA1 of the related commit. That is, an annotated tag is dereferenced to the commit object it points to.
For legacy tags don't only check the tag itself but also the commit message, since the former wasn't injective until release 0.5.5. You only need to use this function if you also need to check for legacy tags.
Parameters | |
format:str | tag pattern |
version:str | debian version number |
Returns | |
str | sha1 of the commit the tag references to |
Whether the repo has a pristine-tar branch.
Returns | |
Bool | True if the repo has pristine-tar commits already, False otherwise |
Basic version mangling to replace single characters
>>> DebianGitRepository._mangle_version(r'%(version%-%\%)s', "0-1.2.3") ('%(version)s', '0%1.2.3')
Legacy tags (prior to 0.5.5) dropped epochs and didn't honor the '~'
>>> DebianGitRepository._build_legacy_tag('upstream/%(version)s', '1:2.0~3') 'upstream/2.0.3'
sanitize a version so git accepts it as a tag
as described in DEP14
>>> DebianGitRepository._sanitize_version("0.0.0") '0.0.0' >>> DebianGitRepository._sanitize_version("0.0~0") '0.0_0' >>> DebianGitRepository._sanitize_version("0:0.0") '0%0.0' >>> DebianGitRepository._sanitize_version("0%0~0") '0%0_0' >>> DebianGitRepository._sanitize_version("0....0") '0.#.#.#.0' >>> DebianGitRepository._sanitize_version("0.lock") '0.#lock'