Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Nov 15, 2023
1 parent 0fc4679 commit 1f8263b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
44 changes: 19 additions & 25 deletions src/wrike_ist/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,29 @@
: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)]
(let [link-pr-promise (wrike/link-pr details)]
(.then link-pr-promise
(fn [link-pr-result]
(.log js/console (str "Result of link-pr: " link-pr-result))
(condp = state
:draft link-pr-result
:open (-> (wrike/progress-task details (core/getInput "opened"))
(.then
(fn [progress-result]
(.log js/console (str "Result of progress-task: " progress-result))
(js/Promise.resolve progress-result))))
:merged (-> (wrike/complete-task details (core/getInput "merged"))
(.then
(fn [complete-result]
(.log js/console (str "Result of complete-task: " complete-result))
(js/Promise.resolve complete-result))))
:closed (-> (wrike/cancel-task details (core/getInput "closed"))
(.then
(fn [cancel-result]
(.log js/console (str "Result of cancel-task: " cancel-result))
(js/Promise.resolve cancel-result))))
:else (js/Promise.resolve)))))
(-> (case state
:draft
(wrike/link-pr details)

(.catch #(core/setFailed (.-message %)))
:open
(js/Promise.all
[(wrike/link-pr details)
(wrike/progress-task details (core/getInput "opened"))])

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

: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"))))

6 changes: 5 additions & 1 deletion src/wrike_ist/wrike.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@
(.then check-valid-task-promise
(fn [result]
(.log js/console (str "check-valid-task-promise value: " result))))])))
(.catch #(js/Promise.reject %)))))
(.catch
#(do
(.log js/console (str "link-pr: Rejected with reason: " %))
(js/Promise.reject %))))))



(defn folder-statuses
Expand Down

0 comments on commit 1f8263b

Please sign in to comment.