Skip to content

Commit

Permalink
tweak pr script to ignore forks and prioritize merged ones
Browse files Browse the repository at this point in the history
  • Loading branch information
cldwalker committed Jan 10, 2024
1 parent c46a62c commit 38c06e2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bin/bb-github-pr-for-commit
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
(cli/error "Failed to fetch github information" (pr-str {:error (ex-message e)})))))

(defn- fetch-response [commit options]
(let [{:keys [body]} (fetch-response* commit options)]
(if-let [url (-> body (json/parse-string true) first :html_url)]
(let [{:keys [body]} (fetch-response* commit options)
repos (json/parse-string body true)]
(if-let [url (if (= 1 (count repos))
(-> repos first :html_url)
(let [repos' (remove #(get-in % [:base :repo :fork]) repos)]
(prn :URLS (map :html_url repos'))
(->> repos' (filter :merged_at) first :html_url)))]
(do (misc/open-url url)
url)
url)
(cli/error "No github PR found for this commit"))))

(defn -main [{:keys [options arguments summary]}]
Expand Down

0 comments on commit 38c06e2

Please sign in to comment.