Known subclasses: gbp.deb.rollbackgit.RollbackDebianGitRepository

A git repository that holds the source of a Debian package

Method __init__ No summary
Instance Variable pristine_tar Undocumented
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 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 debian_version_from_upstream Build the Debian version that a package based on upstream commit commit would carry taking into account a possible epoch.
Class Method version_to_tag Generate a tag from a given format and a version
Class Method tag_to_version Extract the version from a tag
Method pristine_tar_branch The name of the pristine-tar branch, whether it already exists or not.
Method has_pristine_tar_branch Whether the repo has a pristine-tar branch.
Method create_pristine_tar_commits Create pristine-tar commits for a package with main tarball and (optional) component tarballs based on upstream_tree
Method get_pristine_tar_commit Get the pristine-tar commit for the given source package's latest version.
Method create_upstream_tarball_via_pristine_tar Undocumented
Method create_upstream_tarball_via_git_archive Create a compressed orig tarball in output_dir using git archive
Method vcs_tag_parent If linking to the upstream VCS get the commit id
Static Method _build_legacy_tag Legacy tags (prior to 0.5.5) dropped epochs and didn't honor the '~'
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 _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_submodules Create a compressed source tree archive with submodules.
Method _archive_comp_single Create a compressed source tree archive without submodules

Inherited from GitRepository (via PkgGitRepository):

Class Method git_inout As _git_inout but can be used without an instance
Method path The absolute path to the repository
Method git_dir The absolute path to git's metadata
Method bare Whether this is a bare repository
Method tags List of all tags in the repository
Method branch The currently checked out branch
Method head SHA1 of the current HEAD
Method rename_branch Rename branch
Method create_branch Create a new branch
Method delete_branch Delete branch branch
Method get_branch On what branch is the current working copy
Method has_branch Check if the repository has branch named branch.
Method set_branch Switch to branch branch
Method get_merge_branch Get the branch we'd merge from
Method get_merge_base Get the common ancestor between two commits
Method merge Merge changes from the named commit into the current branch
Method abort_merge Abort a merge
Method is_in_merge Undocumented
Method is_fast_forward Check if an update from from_branch to to_branch would be a fast forward or if the branch is up to date already.
Method get_local_branches Get a list of local branches
Method get_remote_branches Get a list of remote branches
Method update_ref Update ref ref to commit new if ref currently points to old
Method branch_contains Check if branch branch contains commit commit
Method set_upstream_branch Set upstream branches for local branch
Method get_upstream_branch Get upstream branch for the local branch
Method create_tag Create a new tag.
Method delete_tag Delete a tag named tag
Method move_tag Undocumented
Method has_tag Check if the repository has a tag named tag.
Method describe Describe commit, relative to the latest tag reachable from it.
Method find_tag Find the closest tag to a given commit
Method find_branch_tag Find the closest tag on a certain branch to a given commit
Method get_tags List tags
Method verify_tag Verify a signed tag
Method force_head Force HEAD to a specific commit
Method is_clean Does the repository contain any uncommitted modifications?
Method clean Remove untracked files from the working tree.
Method status Check status of repository.
Method is_empty Is the repository empty?
Method rev_parse Find the SHA1 of a given name
Static Method strip_sha1 Strip a given sha1 and check if the resulting hash has the expected length.
Method checkout Checkout treeish
Method has_treeish Check if the repository has the treeish object treeish.
Method write_tree Create a tree object from the current index
Method make_tree Create a tree based on contents.
Method get_obj_type Get type of a git repository object
Method list_tree Get a trees content. It returns a list of objects that match the 'ls-tree' output: [mode, type, sha1, path].
Method get_config Gets the config value associated with name
Method set_config Set a git config value in this repository
Method set_user_name Sets the full name to use for git commits.
Method set_user_email Sets the email address to use for git commits.
Method get_author_info Determine a sane values for author name and author email from git's config and environment variables.
Method get_remotes Get a list of remote repositories
Method get_remote_repos Get all remote repositories
Method has_remote_repo Do we know about a remote named name?
Method add_remote_repo Add a tracked remote repository
Method remove_remote_repo Undocumented
Method fetch Download objects and refs from another repository.
Method pull Fetch and merge from another repository
Method push Push changes to the remote repo
Method push_tag Push a tag to the remote repo
Method add_files Add files to a the repository
Method remove_files Remove files from the repository
Method list_files List files in index and working tree
Method write_file Hash a single file and write it into the object database
Method rename_file Rename file, directory, or symlink
Method commit_staged Commit currently staged files to the repository
Method commit_all No summary
Method commit_files Commit the given files to the repository
Method commit_dir Replace the current tip of branch branch with the contents from unpack_dir
Method commit_tree Commit a tree with commit msg msg and parents parents
Method get_commits Get commits from since to until touching paths
Method show Show a git object
Method grep_log Get commmits matching regex
Method get_subject Gets the subject of a commit.
Method get_commit_info Look up data of a specific commit-ish. Dereferences given commit-ish to the commit it points to.
Method format_patches Output the commits between start and end as patches in output_dir.
Method apply_patch Apply a patch using git apply
Method diff Diff two git repository objects
Method diff_status Get file-status of two git repository objects
Method archive Create an archive from a treeish
Method collect_garbage Cleanup unnecessary files and optimize the local repository
Method has_submodules Does the repo have any submodules?
Method add_submodule Add a submodule
Method update_submodules Update all submodules
Method get_submodules List the submodules of treeish
Class Method create Create a repository at path
Class Method clone Clone a git repository at remote to path.
Instance Variable _path The path to the working tree
Instance Variable _bare Whether this is a bare repository
Method _check_bare Check whether this is a bare repository
Method _get_git_dir Undocumented
Instance Variable _git_dir Undocumented
Method _check_repo Undocumented
Static Method __build_env Prepare environment for subprocess calls
Method _git_getoutput Run a git command and return the output
Method _git_inout Run a git command with input and return output
Method _git_command Execute git command with arguments args and environment env at path.
Method _cmd_has_feature Check if the git command has certain feature enabled.
Method _get_branches Get a list of branches
Method _status Undocumented
Method _commit Undocumented
def __init__(self, *args, **kwargs):
Parameterspathpath to git repo (or subdir) (type: str)
toplevelwhether path points to the toplevel dir of git repository (type: bool)
pristine_tar =
Undocumented
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 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.

Parametersformattag pattern (type: str)
versiondebian version number (type: str)
Returnssha1 of the commit the tag references to (type: str)
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.

Parametersupstream_tag_formatthe tag format on the upstream branch (type: str)
upstream_branchthe upstream branch (type: str)
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
Returnsa new debian version
RaisesGitRepositoryErrorif no upstream tag was found
@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'
@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'
@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 _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..'
@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")
@property
def pristine_tar_branch(self):

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

def has_pristine_tar_branch(self):

Whether the repo has a pristine-tar branch.

ReturnsTrue if the repo has pristine-tar commits already, False otherwise (type: Bool)
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

Parametersupstream_treethe treeish in the git repo to create the commits against
soureslist of tarball as UpstreamSource. First one being the main tarball the other ones additional tarballs.
def get_pristine_tar_commit(self, source, component=None):

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

def create_upstream_tarball_via_pristine_tar(self, source, output_dir, comp, upstream_signatures, component=None):
Undocumented
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

Parameterssourcedebian source package (type: DebianSource)
output_diroutput directory
typestr
treeishgit treeish (type: str)
compcompressor (type: Compressor)
with_submoduleswether to add submodules (type: bool)
componentcomponent to add to tarball name (type: str

Raises GitRepositoryError in case of an error

)
def vcs_tag_parent(self, vcs_tag_format, version):

If linking to the upstream VCS get the commit id

API Documentation for git-buildpackage, generated by pydoctor at 2021-02-01 08:15:22.