Skip to content

Commit ab08f72

Browse files
author
Rintaro Okamura
committed
[patch] ✨ Add --dry-run option
Signed-off-by: Rintaro Okamura <[email protected]>
1 parent 466aaff commit ab08f72

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/gitwerk/command/semver_auto.clj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[gitwerk.service.semver-auto :as semver-auto]))
88

99
(defn semver-auto
10-
[repodir]
10+
[repodir dry-run?]
1111
(let [repo (git/repo repodir)
1212
message (-> repo
1313
(git/latest-log)
@@ -17,13 +17,15 @@
1717
(semver/latest-tag))
1818
(semver/default-version-str))
1919
new-tag (semver-auto/semver-auto message tag)]
20-
(when (not (= tag new-tag))
21-
(git/tag repo new-tag)
20+
(when-not (= tag new-tag)
21+
(when-not dry-run?
22+
(git/tag repo new-tag))
2223
{:old tag
2324
:new new-tag})))
2425

25-
(defn run [ctx _]
26-
(let [res (semver-auto ".")]
26+
(defn run [{:keys [options] :as ctx} _]
27+
(let [{:keys [dry-run?]} options
28+
res (semver-auto "." dry-run?)]
2729
(if res
2830
{:status 0
2931
:console-out

src/gitwerk/core.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
[["-f" "--file PATH" "config"
2929
:id :config-filename
3030
:default "config.edn"]
31+
[nil "--dry-run" :id :dry-run?]
3132
["-e" "--edn" :id :edn?]
3233
["-d" "--debug" :id :debug?]
3334
["-h" "--help" :id :help?]])

0 commit comments

Comments
 (0)