git
checkout_branch(branch, create=True)
¶
Checkout a branch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
branch |
str
|
name of branch to checkout |
required |
create |
bool
|
create new branch |
True
|
Returns:
Type | Description |
---|---|
Res[str]
|
A |
Source code in m/git.py
commit(msg)
¶
get_branch()
¶
Get the current git branch name.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
get_commits(first, latest='HEAD')
¶
Get a list of all the commits between two tags.
May return None
in the special case when first
is 0.0.0
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
first |
str
|
The first tag. |
required |
latest |
str
|
The second tag, defaults to HEAD. |
'HEAD'
|
Returns:
Type | Description |
---|---|
Res[list[str] | None]
|
A |
Source code in m/git.py
get_current_commit_sha()
¶
Find the sha of the current commit.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
get_first_commit_sha()
¶
Find the first commit sha in the repository.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
get_remote_url()
¶
Find the remote url of the repo.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
get_repo_path()
¶
Get the absolute path to the repository.
Returns:
Type | Description |
---|---|
Res[str]
|
An issue or a string of the path to the repo. |
get_status(*, check_stash=False)
¶
Find the current git status.
Note that checking for stashed changes is not part of the regular git
status. To opt in you must set check_stash=True
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
check_stash |
bool
|
Check if there are any stashed changes. |
False
|
Returns:
Type | Description |
---|---|
Res[tuple[str, str]]
|
A |
Source code in m/git.py
list_tags(pattern)
¶
List all the tags matching a pattern.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern |
str
|
The pattern to match. |
required |
Returns:
Type | Description |
---|---|
Res[dict[str, str]]
|
A |
Source code in m/git.py
pull()
¶
Pull branch.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
push_branch(branch)
¶
raw_status()
¶
Obtain the output of "git status".
Returns:
Type | Description |
---|---|
Res[str]
|
A |
remove_git_tag(tag)
¶
Remove a git tag.
It is important to remove the local tag before removing the remote tag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag |
str
|
The tag to remove. |
required |
Returns:
Type | Description |
---|---|
Res[str]
|
A |
Source code in m/git.py
stage_all()
¶
Stage the current changes in the branch.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
stash()
¶
Stash the current changes in the branch.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
stash_pop()
¶
Pop the changes stored in the git stash.
Returns:
Type | Description |
---|---|
Res[str]
|
A |
tag_release(version, sha, *, major_only)
¶
Create a git tags for a release.
This is done to keep a major and minor versions tags pointing to the latest.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
str
|
The version to tag. |
required |
sha |
str
|
The commit sha to tag. |
required |
major_only |
bool
|
Only create the major tag. |
required |
Returns:
Type | Description |
---|---|
Res[str]
|
A |
Source code in m/git.py
update_git_tag(tag, sha, remote_tags, *, skip=False)
¶
Create or move a git tag.
The remote_tags should be provided to determine if we need to remove them before moving the tag. See https://stackoverflow.com/a/28280404 for more details on the git commands.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag |
str
|
The tag to set. |
required |
sha |
str
|
The commit sha to set the tag to. |
required |
remote_tags |
list[str]
|
The list of remote tags. |
required |
skip |
bool
|
Skip process if set to true. |
False
|
Returns:
Type | Description |
---|---|
Res[str]
|
A |