From e1035b9f7c0fbf7819409ca96eed64d92d3ef2d1 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sat, 26 Nov 2022 05:34:37 +0530 Subject: [PATCH] git: Fix function git-pull-rebase --- scripts/git.clj | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/git.clj b/scripts/git.clj index aeacbbe..370b315 100755 --- a/scripts/git.clj +++ b/scripts/git.clj @@ -6,8 +6,6 @@ ; Utilities for git operations -(def default-root ".") - (defn- has-git-repo [dir] (first (filter #(= ".git" %) @@ -19,8 +17,7 @@ (filter #(has-git-repo %) (filter #(.isDirectory %) (.listFiles (io/file root))))) -(defn- git-pull [dir] - (p/process ["git" "-C" dir "pull" "--rebase"])) +(defn- git-pull [dir] (p/process ["git" "-C" dir "pull" "--rebase"])) (defn git-pull-all "Runs `git-pull` on all the git repositories in a directory" @@ -34,23 +31,21 @@ p/check :out slurp) - pulls)] + pulls)] ;; Print corresponding directory name when pulling ;; Skip printing already up to date repos (doseq [[dir out] (filter #(not (.contains (second %) "is up to date.")) - (map vector dirs outputs))] + (map vector dirs outputs))] (println (str dir "\n" out))))) (defn git-pull-rebase-branch "Do git pull and rebase branch with master" [dir] + (run-cmd ["git" "pull" "--rebase"]) (let [current-branch (str/trim (run-cmd ["git" "branch" "--show-current"]))] - (git-pull dir) (when (not (contains? #{"master" "main"} current-branch)) (run! print (map run-cmd - '[["git" "checkout" "master"] - ["git" "pull" "--rebase"] - ["git" "checkout" current-branch] - ["git" "rebase" "master"]]))))) + [["git" "checkout" "master"] ["git" "pull" "--rebase"] + ["git" "checkout" current-branch] ["git" "rebase" "master"]]))))) -- 2.43.0