From: Matthias Kruk Date: Fri, 7 Jan 2022 13:32:13 +0000 (+0900) Subject: include/git: Add git_commit() function X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=38e0e841314625ab3050e2b806ae8aeb60548ca0;p=toolbox include/git: Add git_commit() function This commit adds the git_commit() function, which commits all staged changes to the current branch. --- diff --git a/include/git.sh b/include/git.sh index b43b46e..7e4c0c1 100644 --- a/include/git.sh +++ b/include/git.sh @@ -39,6 +39,21 @@ git_clone() { return 0 } +git_branch_new() { + local repository="$1" + local branch="$2" + + local output + + if ! output=$(cd "$repository" && git branch "$branch" 2>&1); then + log_error "Could not create branch $branch in $repository" + log_highlight "git branch" <<< "$output" | log_error + return 1 + fi + + return 0 +} + git_branch_get_current() { local repository="$1" @@ -135,3 +150,18 @@ git_push() { return 0 } + +git_commit() { + local repository="$1" + local message="$2" + + local output + + if ! output=$(cd "$repository" && git commit -F - <<< "$message" 2>&1); then + log_error "Could not commit to $repository" + log_highlight "git commit" <<< "$output" | log_error + return 1 + fi + + return 0 +}