Skip to content

Commit 5622b12

Browse files
committed
o -> pr-num + drop refer
1 parent 34ce5d1 commit 5622b12

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

script/update_or_create_pr.clj

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env bb
22
(ns update-or-create-pr
3-
(:require [babashka.process :as p :refer [sh shell]]
4-
[babashka.fs :as fs]
3+
(:require [babashka.process :as p]
54
[cheshire.core :as json]
65
[clojure.string :as str]))
76

@@ -15,33 +14,33 @@
1514

1615
(defn existing-pr? [target-branch]
1716
(let [pr-data (->
18-
(shell {:out :string :continue true}
19-
"curl"
20-
(str "https://api.github.com/repos/metabase/docs.metabase.github.io/pulls?head=metabase:" "update-" "doc-update-detection"))
17+
(p/shell {:out :string :continue true}
18+
"curl"
19+
(str "https://api.github.com/repos/metabase/docs.metabase.github.io/pulls?head=metabase:" "update-" "doc-update-detection"))
2120
:out
2221
json/parse-string)
2322
pr-num (some #(when (= target-branch (get % "title"))
2423
(get % "number"))
2524
pr-data)]
26-
(println "→ PR number:" o)
25+
(println "→ PR number:" pr-num)
2726
(boolean pr-num)))
2827

2928
(defn -main [& args]
3029
(let [source-branch (or (first args) (usage))
3130
target-branch (str "update-" source-branch)
3231
_ (println "Swithcing to target branch.")
33-
_ (shell "git" "checkout" "-B" target-branch)
32+
_ (p/shell "git" "checkout" "-B" target-branch)
3433
_ (doseq [ad artifact-dirs]
3534
(println "Adding" ad "...")
36-
(shell "git" "add" ad))
37-
{:keys [exit]} (shell {:continue true} "git" "diff" "--cached" "--quiet")]
35+
(p/shell "git" "add" ad))
36+
{:keys [exit]} (p/shell {:continue true} "git" "diff" "--cached" "--quiet")]
3837

3938
(if (zero? exit)
4039
(println "→ No changes to commit.")
4140
(do
4241
(println "→ Changes detected, committing...")
43-
(shell "git" "commit" "-m" (str "[auto] adding content to " target-branch))
44-
(shell "git" "push" "--force" "origin" target-branch)
42+
(p/shell "git" "commit" "-m" (str "[auto] adding content to " target-branch))
43+
(p/shell "git" "push" "--force" "origin" target-branch)
4544
(println "→ Branch updated successfully.")))
4645

4746
(println "→ Checking for existing PR...")
@@ -50,11 +49,11 @@
5049
(println "✓ PR already exists: #" existing-pr?)
5150
(do
5251
(println "→ Creating new PR...")
53-
(shell "gh" "pr" "create"
54-
"--repo" "metabase/docs.metabase.github.io"
55-
"--title" target-branch
56-
"--body" (str "updated: " (pr-str artifact-dirs))
57-
"--head" target-branch)))))
52+
(p/shell "gh" "pr" "create"
53+
"--repo" "metabase/docs.metabase.github.io"
54+
"--title" target-branch
55+
"--body" (str "updated: " (pr-str artifact-dirs))
56+
"--head" target-branch)))))
5857

5958
(when (= *file* (System/getProperty "babashka.file"))
6059
(apply -main *command-line-args*))

0 commit comments

Comments
 (0)