Source code for gitone.caamp

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from typing import Optional

import git


[docs]def caamp(commit_message: Optional[str] = None) -> None: """Amend the previous commit with changes made to tracked files, then push. :param message: The commit message to be passed to the git commit command. :note: A commit message will be automatically generated if the ``message`` argument is not provided. """ repo = git.Repo(search_parent_directories=True) print(repo.git.add("--update")) if commit_message: print(repo.git.commit("--all", "--amend", message=commit_message)) else: print(repo.git.commit("--amend", "--reuse-message=HEAD"), repo.git.push("--force"))
if __name__ == "__main__": caamp()