From 1346c7409e1ac232f1c1d9b1707606f3cc302573 Mon Sep 17 00:00:00 2001 From: Ayush Gaud Date: Thu, 16 Nov 2023 03:25:43 +0900 Subject: [PATCH] print promise of link-pr --- src/wrike_ist/core.cljs | 39 +++++++++++++++++++++------------------ src/wrike_ist/wrike.cljs | 1 + 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/wrike_ist/core.cljs b/src/wrike_ist/core.cljs index 14eb0b4..395044d 100644 --- a/src/wrike_ist/core.cljs +++ b/src/wrike_ist/core.cljs @@ -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")))) diff --git a/src/wrike_ist/wrike.cljs b/src/wrike_ist/wrike.cljs index 601a348..b3f6ede 100644 --- a/src/wrike_ist/wrike.cljs +++ b/src/wrike_ist/wrike.cljs @@ -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)]