38b9b7491b736a6a97e1004975dafe627d1674f4
[babashka-scripts.git] / utils.clj
1 (ns utils
2 (:require [lib :refer [run-cmd]]
3 [clojure.string :as str]))
4
5 (defn git-pull-rebase-branch
6 "Do git pull and rebase branch with master"
7 []
8 (let [current-branch (str/trim (run-cmd ["git" "branch" "--show-current"]))]
9 (print (run-cmd ["git" "pull" "--rebase"]))
10 (when (not (contains? #{"master" "main"} current-branch))
11 (run! print
12 (map run-cmd
13 '[["git" "checkout" "master"]
14 ["git" "pull" "--rebase"]
15 ["git" "checkout" "-"]
16 ["git" "rebase" "master"]])))))