]> njoseph.me Git - babashka-scripts.git/blobdiff - utils.clj
Add utils and shell aliases
[babashka-scripts.git] / utils.clj
diff --git a/utils.clj b/utils.clj
new file mode 100644 (file)
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"]])))))