ballet.util.git module¶
-
class
ballet.util.git.
CustomDiffer
(endpoints)[source]¶ Bases:
ballet.util.git.Differ
-
class
ballet.util.git.
LocalMergeBuildDiffer
(repo)[source]¶ Bases:
ballet.util.git.Differ
Diff files on a merge commit on the current active branch.
Merge parent order is guaranteed such that parent 1 is HEAD and parent 2 is topic [1].
-
repo
¶ The repository to check the merge diff on. Must be currently on a branch where the most recent commit is a merge.
References
[1] https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging
-
-
class
ballet.util.git.
NoOpDiffer
(repo)[source]¶ Bases:
ballet.util.git.PullRequestBuildDiffer
A differ that returns an empty changeset
-
class
ballet.util.git.
PullRequestBuildDiffer
(repo)[source]¶ Bases:
ballet.util.git.Differ
Diff files from this pull request against a comparison ref
- Parameters
repo (
Repo
) – repo
-
ballet.util.git.
can_use_local_merge_differ
(repo)[source]¶ Check the repo HEAD is on master after a merge commit
Checks for two qualities of the current project:
The project repo’s head is the master branch
The project repo’s head commit is a merge commit.
Note that fast-forward style merges will not cause the second condition to evaluate to true.
-
ballet.util.git.
create_github_repo
(github, owner, name)[source]¶ Create the repo
:owner/:name
The authenticated account must have the permissions to create the desired repo.
if the desired owner is the user, then this is straightforward
if the desired owner is an organization, then the user must have permission to create a new repo for the organization
- Return type
Repository
- Returns
the created repository
- Raises
github.GithubException.BadCredentialsException – if the token does not have permission to create the desired repo
-
ballet.util.git.
did_git_push_succeed
(push_info)[source]¶ Check whether a git push succeeded
A git push succeeded if it was not “rejected” or “remote rejected”, and if there was not a “remote failure” or an “error”.
- Parameters
push_info (
PushInfo
) – push info- Return type
bool
-
ballet.util.git.
get_diff_endpoints_from_commit_range
(repo, commit_range)[source]¶ Get endpoints of a diff given a commit range
The resulting endpoints can be diffed directly:
a, b = get_diff_endpoints_from_commit_range(repo, commit_range) a.diff(b)
For details on specifying git diffs, see
git diff --help
. For details on specifying revisions, seegit help revisions
.- Parameters
repo (
Repo
) – Repo object initialized with project rootcommit_range (
str
) – commit range as would be interpreted bygit diff
command. Unfortunately only patterns of the forma..b
anda...b
are accepted. Note that the latter pattern finds the merge-base of a and b and uses it as the starting point for the diff.
- Return type
Tuple
[Diffable
,Diffable
]- Returns
starting commit, ending commit (inclusive)
- Raises
ValueError – commit_range is empty or ill-formed
See also
-
ballet.util.git.
push_branches_to_remote
(repo, remote_name, branches)[source]¶ Push selected branches to origin
Similar to:
$ git push origin branch1:branch1 branch2:branch2
- Raises
ballet.exc.BalletError – Push failed in some way