githandler¶
Wrappers for interacting with git
Functions
|
Install GPG key |
Classes
|
|
|
Githandler with logic specific to Bioconda Repo |
|
GitHandler for working with a pre-existing local checkout of bioconda-recipes |
|
GitPython abstraction |
|
|
|
GitHandler for working with temporary working directories created on the fly |
Exceptions
Something went wrong interacting with git |
Documentation
- class bioconda_utils.githandler.BiocondaRepo(folder='.', dry_run=False, home='bioconda/bioconda-recipes', fork=None, allow_dirty=True, depth=1)[source]¶
- class bioconda_utils.githandler.BiocondaRepoMixin(repo, dry_run, home='bioconda/bioconda-recipes', fork=None, allow_dirty=False)[source]¶
Githandler with logic specific to Bioconda Repo
- config_file = 'config.yml'¶
location of configuration file within repo
- get_blacklisted(ref=None)[source]¶
Get blacklisted recipes as of ref
- Parameters
ref – Name of branch or commit (HEAD~1 is allowed), defaults to currently checked out branch
- Returns
set
of blacklisted recipes (full path to repo root)
- get_changed_recipes(ref=None, other=None, files=None)[source]¶
Returns list of modified recipes
- Parameters
ref – See
get_merge_base
. Defaults to HEADother – See
get_merge_base
. Defaults to origin/masterfiles – List of files to consider. Defaults to
meta.yaml
andbuild.sh
- Result:
List of unique recipe folders with changes. Path is from repo root (e.g.
recipes/blast
). Recipes outside ofrecipes_folder
are ignored.
- get_recipes_to_build(ref=None, other=None)[source]¶
Returns
list
of recipes to build for merge of ref into otherThis includes all recipes returned by
get_changed_recipes
and all newly unblacklisted, extant recipes withinrecipes_folder
- Returns
list
of recipes that should be built
- get_unblacklisted(ref=None, other=None)[source]¶
Get recipes unblacklisted by a merge of ref into other
- Parameters
ref – Branch or commit or reference, defaults to current branch
other – Same as ref, defaults to
origin/master
- Returns
set
of unblacklisted recipes (full path to repo root)
- recipes_folder = 'recipes'¶
location of recipes folder within repo
- class bioconda_utils.githandler.GitHandler(folder='.', dry_run=False, home='bioconda/bioconda-recipes', fork=None, allow_dirty=True, depth=1)[source]¶
GitHandler for working with a pre-existing local checkout of bioconda-recipes
Restores the branch active when created upon calling
close()
.
- class bioconda_utils.githandler.GitHandlerBase(repo, dry_run, home='bioconda/bioconda-recipes', fork=None, allow_dirty=False)[source]¶
GitPython abstraction
We have to work with three git repositories, the local checkout, the project primary repository and a working repository. The latter may be a fork or may be the same as the primary.
- Parameters
repo (
Repo
) – GitPython Repo object (created by subclasses)dry_run (
bool
) – Don’t push anything to remotehome – string occurring in remote url marking primary project repo
fork – string occurring in remote url marking forked repo
allow_dirty – don’t bail out if repo is dirty
- actor: git.util.Actor¶
Committer and Author
- async branch_is_current(branch, path, master='master')[source]¶
Checks if branch has the most recent commit modifying path as compared to master
- Return type
- commit_and_push_changes(files, branch_name, msg, sign=False)[source]¶
Create recipe commit and pushes to upstream remote
- Return type
- Returns
Boolean indicating whether there were changes committed
- create_local_branch(branch_name, remote_branch=None)[source]¶
Creates local branch from remote branch_name
- dry_run¶
Dry-Run mode - don’t push or commit anything
- fork_remote¶
Remote to pull from
- get_merge_base(ref=None, other=None, try_fetch=False)[source]¶
Determines the merge base for other and ref
See git merge-base. Returns the commit at which ref split from other and from which point on changes would be merged.
- Parameters
ref – One of the two tips for which a merge base is sought. Defaults to the currently checked out HEAD. This is the second argument to
git merge-base
.other – One of the two tips for which a merge base is sought. Defaults to
origin/master
(home_remote
). This is the first argument togit merge-base
.
- Returns
The first merge base for the two references provided if found. May return
None
if no merge base was found. This may for example be the case if branches were deleted or if the repository is shallow and the merge base commit not available.
- home_remote¶
Remote pointing to primary project repo
- static is_sha(ref)[source]¶
Checks if ref is a commit checksum
Verifies that ref is a hex value of length 40
- Return type
- list_changed_files(ref=None, other=None)[source]¶
Lists files that would be added/modified by merge of other into ref
See also
get_merge_base()
.- Parameters
ref – Defaults to
HEAD
(active branch), one of the tips comparedother – Defaults to
origin/master
, other tip compared
- Returns
Generator over modified or created (not deleted) files.
- lock_working_dir¶
Semaphore for things that mess with working directory
- prepare_branch(branch_name)[source]¶
Checks out branch_name, creating it from home remote master if needed
- Return type
- read_from_branch(branch, file_name)[source]¶
Reads contents of file file_name from git branch branch
- Return type
- repo: git.repo.base.Repo¶
GitPython Repo object representing our repository
- exception bioconda_utils.githandler.GitHandlerFailure[source]¶
Something went wrong interacting with git
- class bioconda_utils.githandler.TempBiocondaRepo(username=None, password=None, url_format='https://{userpass}github.com/{user}/{repo}.git', home_user='bioconda', home_repo='bioconda-recipes', fork_user=None, fork_repo=None, dry_run=False)[source]¶
- class bioconda_utils.githandler.TempGitHandler(username=None, password=None, url_format='https://{userpass}github.com/{user}/{repo}.git', home_user='bioconda', home_repo='bioconda-recipes', fork_user=None, fork_repo=None, dry_run=False)[source]¶
GitHandler for working with temporary working directories created on the fly
Throw-away copies of a git repo as provided by this class are useful when we might be working in multiple threads and want to avoid blocking waits for a single repo. It also improves robustness: If something goes wrong with this repo, it will not break the entire process.