]> git.corax.cc Git - toolbox/commitdiff
include/git: Add git_commit() function
authorMatthias Kruk <m@m10k.eu>
Fri, 7 Jan 2022 13:32:13 +0000 (22:32 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 7 Jan 2022 13:32:13 +0000 (22:32 +0900)
This commit adds the git_commit() function, which commits all staged
changes to the current branch.

include/git.sh

index b43b46e1ad5cf6ac2dab5de6e7a56e2a87d38bcd..7e4c0c13ad6f8a9982910ae72d5751336d38612e 100644 (file)
@@ -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
+}