From 38e0e841314625ab3050e2b806ae8aeb60548ca0 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Fri, 7 Jan 2022 22:32:13 +0900 Subject: [PATCH] include/git: Add git_commit() function This commit adds the git_commit() function, which commits all staged changes to the current branch. --- include/git.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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 +} -- 2.47.3