this repo has no description
at main 1.4 kB view raw
1(use sh) 2 3(defn prompt 4 [] 5 (def repo-root ($<_ jj root --ignore-working-copy)) 6 (def template `change_id.shortest(8).prefix() ++ "#," ++ change_id.shortest(8).rest() ++ "#," ++ commit_id.shortest(8).prefix() ++ "#," ++ commit_id.shortest(8).rest() ++ "#," ++ divergent ++ "#," ++ description ++ "#," ++ bookmarks.join(",")`) 7 # (def template "change_id.shortest(8).prefix()") 8 (def stdout ($< jj log -r @ -T ,template --no-graph --no-pager --color never --ignore-working-copy -R ,repo-root)) 9 (def [change-id-prefix change-id-suffix commit-id-prefix commit-id-suffix divergent description branches] (string/split "#," stdout)) 10 {:change-id [change-id-prefix change-id-suffix] 11 :commit-id [commit-id-prefix commit-id-suffix] 12 :divergent (= divergent "true") 13 :description description 14 :branches branches}) 15 16(def color-reset "%f") 17(def color-blue "%F{blue}") 18(def color-pink "%F{magenta}") 19(def color-dark "%F{8}") 20 21(defn render 22 [parsed] 23 (string 24 " [" 25 color-pink 26 ((parsed :change-id) 0) 27 color-dark 28 ((parsed :change-id) 1) 29 color-reset 30 " " 31 color-blue 32 ((parsed :commit-id) 0) 33 color-dark 34 ((parsed :commit-id) 1) 35 color-reset 36 (if-not (empty? (parsed :branches)) 37 (string 38 " on " 39 (parsed :branches))) 40 "]")) 41 42(defn main [&] 43 (def [ok jj] (protect (prompt))) 44 (if ok (prin (render jj))))