Add a babashka script to get authors and changes for a release
diff --git a/bb.edn b/bb.edn new file mode 100644 index 0000000..f8b09f8 --- /dev/null +++ b/bb.edn
@@ -0,0 +1,12 @@ +{:paths ["extra"] + :tasks + {:requires ([tasks :as t]) + + latest-release {:doc "Get version number of latest release" + :task (println (t/latest-release))} + + authors {:doc "List all authors for current release" + :task (println (t/authors))} + + changes {:doc "List all changes for the current release" + :task (println (t/changes-since)) }}}
diff --git a/extra/tasks.clj b/extra/tasks.clj new file mode 100755 index 0000000..eb48512 --- /dev/null +++ b/extra/tasks.clj
@@ -0,0 +1,34 @@ +(ns tasks + (:require + [babashka.process :refer [process shell]] + [clojure.string :as str])) + +;; majorly inspired by the Announce script from git, see +;; https://github.com/git/git/blob/ecaae0c78185918cb24292407354f58c043b6ca8/Announce + +(defn latest-release [] + (->> "git describe --abbrev=0" + (shell {:out :string}) + :out + str/trim)) + +(defn authors + ([] (authors (latest-release))) + ([release] + (->> release + (format "git shortlog -s --no-merges --group=author --group=trailer:co-authored-by %s..") + (shell {:out :string}) + :out + str/split-lines + (map (fn [line] (-> line (str/split #"\t") second))) + (sort-by str/lower-case) + (str/join ", ")))) + +(defn changes-since + ([] (changes-since (latest-release))) + ([release] + (-> (process (format "git log --no-merges %s.." release)) + (process {:out :string} "git shortlog") + deref + :out))) +