X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/67d5a15a20df70f416cf78efb2137344f239da2f..00a9627659403ac2a910f8753cc2b1510384d6c3:/utils.clj diff --git a/utils.clj b/utils.clj new file mode 100644 index 0000000..38b9b74 --- /dev/null +++ b/utils.clj @@ -0,0 +1,16 @@ +(ns utils + (:require [lib :refer [run-cmd]] + [clojure.string :as str])) + +(defn git-pull-rebase-branch + "Do git pull and rebase branch with master" + [] + (let [current-branch (str/trim (run-cmd ["git" "branch" "--show-current"]))] + (print (run-cmd ["git" "pull" "--rebase"])) + (when (not (contains? #{"master" "main"} current-branch)) + (run! print + (map run-cmd + '[["git" "checkout" "master"] + ["git" "pull" "--rebase"] + ["git" "checkout" "-"] + ["git" "rebase" "master"]])))))