git_cli#
Git CLI related utilities.
Usage example:
from fixa.git_cli import (
temp_cwd,
GitCLIError,
locate_dir_repo,
get_git_branch_from_,git_cli
get_git_commit_id_fr,om_git_cli
get_commit_message_b,y_commit_id
create_local_git_tag,
delete_local_git_tag,
)
- aws_ops_alpha.vendor.git_cli.temp_cwd(path: Union[str, Path])[source]#
Temporarily set the current working directory (CWD) and automatically switch back when it’s done.
Example:
with temp_cwd(Path("/path/to/target/working/directory")): # do something
New in version 0.1.1.
- aws_ops_alpha.vendor.git_cli.locate_dir_repo(path: Path) Path[source]#
Locate the directory of the git repository. Similar to the effect of
git rev-parse --show-toplevel.New in version 0.1.1.
- aws_ops_alpha.vendor.git_cli.get_git_branch_from_git_cli(dir_repo: Union[str, Path]) str[source]#
Use
gitCLI to get the current git branch.Run:
cd $dir_repo git branch --show-current
New in version 0.1.1.
- aws_ops_alpha.vendor.git_cli.get_git_commit_id_from_git_cli(dir_repo: Union[str, Path]) str[source]#
Use
gitCIL to get current git commit id.Run:
cd $dir_repo git rev-parse HEAD
New in version 0.1.1.
- aws_ops_alpha.vendor.git_cli.get_commit_message_by_commit_id(dir_repo: Union[str, Path], commit_id: str) str[source]#
Get the first line of commit message.
Run:
cd $dir_repo git log --format=%B -n 1 ${commit_id}
New in version 0.1.1.