Skip to content

Commit

Permalink
print promise of link-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Nov 15, 2023
1 parent 248240d commit 1346c74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/wrike_ist/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,32 @@
:repository-name repository-name})
links)))))

(defn main
[]
(defn main []
(let [payload (.-payload (.-context github))]
(if-let [pr (.-pull_request payload)]
(loop [links (extract-details pr)]
(when-let [{:keys [state] :as details} (first links)]
(-> (case state
:draft
(wrike/link-pr details)
(let [link-pr-promise (wrike/link-pr details)]
(-> (case state
:draft
link-pr-promise

:open
(js/Promise.all
[(wrike/link-pr details)
(wrike/progress-task details (core/getInput "opened"))])
:open
(js/Promise.all
[link-pr-promise
(wrike/progress-task details (core/getInput "opened"))])

:merged
(wrike/complete-task details (core/getInput "merged"))
:merged
(wrike/complete-task details (core/getInput "merged"))

:closed
(wrike/cancel-task details (core/getInput "closed"))
:closed
(wrike/cancel-task details (core/getInput "closed"))

;; else ignore
(js/Promise.resolve))
(.catch #(core/setFailed (.-message %))))
(recur (rest links))))
(js/console.log "No pull_request in payload"))))
;; else ignore
(js/Promise.resolve))
(.then
(fn [result]
(.log js/console (str "Result of link-pr: " result)))
(.catch #(core/setFailed (.-message %)))))
(recur (rest links)))))
(js/console.log "No pull_request in payload"))))
1 change: 1 addition & 0 deletions src/wrike_ist/wrike.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
(do
(.info js/console "check-valid-task: PR is not targeted to release branch, returning success")
(resolve permalink))))))

(defn link-pr
[{:keys [pr-url permalink target-branch] :as details}]
(let [check-valid-task-promise (check-valid-task permalink target-branch)]
Expand Down

0 comments on commit 1346c74

Please sign in to comment.