class documentation

A git repository that holds the source of a Debian package

Class Method tag_to_version Extract the version from a tag
Class Method version_to_tag Generate a tag from a given format and a version
Method __init__ Undocumented
Method create_pristine_tar_commits Create pristine-tar commits for a package with main tarball and (optional) component tarballs based on upstream_tree
Method create_upstream_tarball_via_git_archive Create a compressed orig tarball in output_dir using git archive
Method create_upstream_tarball_via_pristine_tar Undocumented
Method debian_version_from_upstream Build the Debian version that a package based on upstream commit commit would carry taking into account a possible epoch.
Method find_version 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_pristine_tar_commit Get the pristine-tar commit for the given source package's latest version.
Method has_pristine_tar_branch Whether the repo has a pristine-tar branch.
Method tree_drop_dirs Drop the given top level dirs from the given git tree returning a new tree object.
Method tree_get_dir Get the SHA1 of directory in a given tree
Method vcs_tag_parent If linking to the upstream VCS get the commit id
Instance Variable pristine_tar Undocumented
Property pristine_tar_branch The name of the pristine-tar branch, whether it already exists or not.
Class Method _mangle_version Basic version mangling to replace single characters
Class Method _unmangle_format Reverse of _mangle_version for format
Class Method _unmangle_version Reverse of _mangle_version for version
Static Method _build_legacy_tag Legacy tags (prior to 0.5.5) dropped epochs and didn't honor the '~'
Static Method _sanitize_version sanitize a version so git accepts it as a tag
Static Method _unsanitize_version Reverse _sanitize_version

Inherited from PkgGitRepository:

Static Method sanitize_prefix Make sure git-archive prefix ends with a slash
Method archive_comp Create a compressed source tree archive with the given options
Method _archive_comp_single Create a compressed source tree archive without submodules
Method _archive_comp_submodules Create a compressed source tree archive with submodules.
@classmethod
def tag_to_version(cls, tag, format):

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")
@classmethod
def version_to_tag(cls, format, version):

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'
def __init__(self, *args, **kwargs):
def create_pristine_tar_commits(self, upstream_tree, sources):

Create pristine-tar commits for a package with main tarball and (optional) component tarballs based on upstream_tree

Parameters
upstream_treethe treeish in the git repo to create the commits against
sourcesUndocumented
soureslist of tarball as UpstreamSource. First one being the main tarball the other ones additional tarballs.
def create_upstream_tarball_via_git_archive(self, source, output_dir, treeish, comp, with_submodules, component=None):

Create a compressed orig tarball in output_dir using git archive

Parameters
source:DebianSourcedebian source package
output_diroutput directory
treeish:strgit treeish
comp:Compressorcompressor
with_submodules:boolwether to add submodules
component:

str

Raises GitRepositoryError in case of an error

component to add to tarball name
typestr
def create_upstream_tarball_via_pristine_tar(self, source, output_dir, comp, upstream_signatures, component=None):

Undocumented

def debian_version_from_upstream(self, upstream_tag_format, upstream_branch, commit='HEAD', epoch=None, debian_release=True):

Build the Debian version that a package based on upstream commit commit would carry taking into account a possible epoch.

Parameters
upstream_tag_format:strthe tag format on the upstream branch
upstream_branch:strthe upstream branch
committhe commit to search for the latest upstream version
epochan epoch to use
debian_releaseIf set to False don't append a Debian release number to the version number
Returns
a new debian version
Raises
GitRepositoryErrorif no upstream tag was found
def find_version(self, format, version):

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:strtag pattern
version:strdebian version number
Returns
strsha1 of the commit the tag references to
def get_pristine_tar_commit(self, source, component=None):

Get the pristine-tar commit for the given source package's latest version.

def has_pristine_tar_branch(self):

Whether the repo has a pristine-tar branch.

Returns
BoolTrue if the repo has pristine-tar commits already, False otherwise
def tree_drop_dirs(self, tree, dirs):

Drop the given top level dirs from the given git tree returning a new tree object.

def tree_get_dir(self, tree, dir):

Get the SHA1 of directory in a given tree

def vcs_tag_parent(self, vcs_tag_format, version):

If linking to the upstream VCS get the commit id

pristine_tar =
@property
pristine_tar_branch =

The name of the pristine-tar branch, whether it already exists or not.

@classmethod
def _mangle_version(cls, format, version):

Basic version mangling to replace single characters

>>> DebianGitRepository._mangle_version(r'%(version%-%\%)s', "0-1.2.3")
('%(version)s', '0%1.2.3')
@classmethod
def _unmangle_format(cls, format):

Reverse of _mangle_version for format

@classmethod
def _unmangle_version(cls, format, tag):

Reverse of _mangle_version for version

@staticmethod
def _build_legacy_tag(format, version):

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'
@staticmethod
def _sanitize_version(version):

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'
@staticmethod
def _unsanitize_version(tag):

Reverse _sanitize_version

as described in DEP14

>>> DebianGitRepository._unsanitize_version("1%0_bpo3")
'1:0~bpo3'
>>> DebianGitRepository._unsanitize_version("1%0_bpo3.#.")
'1:0~bpo3..'