Package gbp :: Package deb :: Module git :: Class DebianGitRepository
[hide private]
[frames] | no frames]

Class DebianGitRepository

                  object --+    
                           |    
git.repository.GitRepository --+
                               |
                              DebianGitRepository
Known Subclasses:

A git repository that holds the source of a Debian package

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
 
create_pristinetar_commits(self, upstream_tree, tarball, component_tarballs)
Create pristine-tar commits for a package with main tarball tarball and (optional) component tarballs based on upstream_tree
 
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.
str
find_version(self, format, version)
Check if a certain version is stored in this repo and return the SHA1 of the related commit.
Bool
has_pristine_tar_branch(self)
Whether the repo has a pristine-tar branch.
 
tree_drop_dirs(self, tree, dirs)
Drop the given top level dirs from the given git tree returning a new tree object.
 
tree_get_dir(self, tree, dir)
Get the SHA1 of directory in a given tree

Inherited from git.repository.GitRepository: archive, clean, collect_garbage, force_head, get_author_info, get_config, is_clean, is_empty, rev_parse, set_config, set_user_email, set_user_name, status

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Branches and Merging

Inherited from git.repository.GitRepository: abort_merge, branch_contains, create_branch, delete_branch, get_branch, get_local_branches, get_merge_base, get_merge_branch, get_remote_branches, get_upstream_branch, has_branch, is_fast_forward, is_in_merge, merge, rename_branch, set_branch, set_upstream_branch, update_ref

Inherited from git.repository.GitRepository (private): _get_branches

    Tags

Inherited from git.repository.GitRepository: create_tag, delete_tag, describe, find_branch_tag, find_tag, get_tags, has_tag, move_tag, verify_tag

    Trees

Inherited from git.repository.GitRepository: checkout, get_obj_type, has_treeish, list_tree, make_tree, write_tree

    Remote Repositories

Inherited from git.repository.GitRepository: add_remote_repo, fetch, get_remote_repos, get_remotes, has_remote_repo, pull, push, push_tag, remove_remote_repo

    Files

Inherited from git.repository.GitRepository: add_files, list_files, remove_files, rename_file, write_file

    Comitting

Inherited from git.repository.GitRepository: commit_all, commit_dir, commit_files, commit_staged, commit_tree

Inherited from git.repository.GitRepository (private): _commit

    Commit Information

Inherited from git.repository.GitRepository: get_commit_info, get_commits, get_subject, grep_log, show

    Patches

Inherited from git.repository.GitRepository: apply_patch, diff, diff_status, format_patches

    Submodules

Inherited from git.repository.GitRepository: add_submodule, get_submodules, has_submodules, update_submodules

Class Methods [hide private]
 
_mangle_version(cls, format, version)
Basic version mangling to replce single characters
 
_unmangle_format(cls, format)
Reverse of _mangle_version for format
 
_unmangle_version(cls, format, tag)
Reverse of _mangle_version for version
 
tag_to_version(cls, tag, format)
Extract the version from a tag
 
version_to_tag(cls, format, version)
Generate a tag from a given format and a version
    Repository Creation

Inherited from git.repository.GitRepository: clone, create

Static Methods [hide private]
 
_build_legacy_tag(format, version)
Legacy tags (prior to 0.5.5) dropped epochs and didn't honor the '~'
 
_sanitize_version(version)
sanitize a version so git accepts it as a tag
 
_unsanitize_version(tag)
Reverse _sanitize_version

Inherited from git.repository.GitRepository: strip_sha1

Class Variables [hide private]
  version_mangle_re = '%\\(version%(?P<M>[^%])%(?P<R>([^%]|\\%))...
Instance Variables [hide private]

Inherited from git.repository.GitRepository (private): _bare, _path

Properties [hide private]
  pristine_tar_branch
The name of the pristine-tar branch, whether it already exists or not.

Inherited from git.repository.GitRepository: bare, branch, git_dir, head, path, tags

Inherited from object: __class__

Method Details [hide private]

__init__(self, *args, **kwargs)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • path - path to git repo (or subdir)
  • toplevel - whether path points to the toplevel dir of git repository
Raises:
Overrides: object.__init__
(inherited documentation)

_build_legacy_tag(format, version)
Static Method

 

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'

_mangle_version(cls, format, version)
Class Method

 

Basic version mangling to replce single characters

>>> DebianGitRepository._mangle_version("%(version%-%\%)s", "0-1.2.3")
('%(version)s', '0%1.2.3')

_sanitize_version(version)
Static Method

 

sanitize a version so git accepts it as a tag

as descirbed 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'

_unsanitize_version(tag)
Static Method

 

Reverse _sanitize_version

as descirbed in DEP14

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

create_pristinetar_commits(self, upstream_tree, tarball, component_tarballs)

 

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

Parameters:
  • tarball - path to main tarball
  • component_tarballs - list of tuples of component name and path to additional tarball
  • upstream_tree - the treeish in the git repo to create the commits against

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 (str) - the tag format on the upstream branch
  • upstream_branch (str) - the upstream branch
  • commit - the commit to search for the latest upstream version
  • epoch - an epoch to use
  • debian_release - If set to False don't append a Debian release number to the version number
Returns:
a new debian version
Raises:

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 (str) - tag pattern
  • version (str) - debian version number
Returns: str
sha1 of the commit the tag references to

has_pristine_tar_branch(self)

 

Whether the repo has a pristine-tar branch.

Returns: Bool
True if the repo has pristine-tar commits already, False otherwise

tag_to_version(cls, tag, format)
Class Method

 

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")

version_to_tag(cls, format, version)
Class Method

 

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("%(version%-%\%)s", "0-1.2.3")
'0%1.2.3'

Class Variable Details [hide private]

version_mangle_re

Value:
'%\\(version%(?P<M>[^%])%(?P<R>([^%]|\\%))+\\)s'

Property Details [hide private]

pristine_tar_branch

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

Get Method:
unreachable.pristine_tar_branch(self) - The name of the pristine-tar branch, whether it already exists or not.