]>
Commit | Line | Data |
---|---|---|
00a96276 JN |
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"]]))))) | |
cd6a808b JN |
17 | |
18 | (defn run-seq | |
19 | "Run a sequence of shell commands on a sequence of arguments. | |
20 | ||
21 | Examples: | |
22 | ||
23 | 1. Play and delete each video from a folder | |
24 | ls | bb -i '(run-seq ["mpv" "rm"] *input*)' | |
25 | " | |
26 | [commands arguments] | |
27 | (doseq [argument arguments | |
28 | command commands] | |
29 | (println (run-cmd [command argument])))) |