Skip to content

Commit

Permalink
don't fail if target branch is not release
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Nov 15, 2023
1 parent b8ea8e8 commit 248240d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions resources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12347,8 +12347,8 @@ wrike_ist.wrike.is_wrike_task_in_folder_QMARK_=function(a){return wrike_ist.wrik
" parentIds: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(d)," superParentIds: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(e)].join(""));console.info(["is-wrike-task-in-folder?: Folder names to match: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(wrike_ist.wrike.folder_names)].join(""));var f=cljs.core.concat.cljs$core$IFn$_invoke$arity$2(d,e);b=function(){return function k(h){return new cljs.core.LazySeq(null,function(){for(;;){var l=cljs.core.seq(h);if(l){if(cljs.core.chunked_seq_QMARK_(l)){var m=
cljs.core.chunk_first(l),n=cljs.core.count(m),p=cljs.core.chunk_buffer(n);a:for(var q=0;;)if(q<n){var r=cljs.core._nth(m,q);r=wrike_ist.wrike.fetch_folder_details(r,wrike_ist.wrike.folder_names);cljs.core.chunk_append(p,r);q+=1}else{m=!0;break a}return m?cljs.core.chunk_cons(cljs.core.chunk(p),k(cljs.core.chunk_rest(l))):cljs.core.chunk_cons(cljs.core.chunk(p),null)}p=cljs.core.first(l);p=wrike_ist.wrike.fetch_folder_details(p,wrike_ist.wrike.folder_names);return cljs.core.cons(p,k(cljs.core.rest(l)))}return null}},
null,null)}(f)}();Promise.all(b);return Promise.all(b).then(function(g){if(cljs.core.truth_(cljs.core.some(cljs.core.true_QMARK_,g)))return console.info("is-wrike-task-in-folder?: Matching folders found"),!0;console.info("is-wrike-task-in-folder?: Task is not a valid bug ticket of part of a planned release");return!1})})};
wrike_ist.wrike.check_valid_task=function(a,b){return new Promise(function(c,d){return cljs.core.truth_(cljs.core.truth_(b)?clojure.string.starts_with_QMARK_(b,"release"):b)?(console.info("check-valid-task: PR is targeted to release branch, checking if task is a valid bug ticket or part of planned releases"),wrike_ist.wrike.is_wrike_task_in_folder_QMARK_(a).then(function(e){if(cljs.core.truth_(e))return console.info("check-valid-task: Task is in the folder or an inherited folder: true"),c.cljs$core$IFn$_invoke$arity$1?
c.cljs$core$IFn$_invoke$arity$1(a):c.call(null,a);console.error("check-valid-task: Task not found in folder");e=Error("check-valid-task: Task not found in folder");return d.cljs$core$IFn$_invoke$arity$1?d.cljs$core$IFn$_invoke$arity$1(e):d.call(null,e)})):null})};
wrike_ist.wrike.check_valid_task=function(a,b){return new Promise(function(c,d){if(cljs.core.truth_(cljs.core.truth_(b)?clojure.string.starts_with_QMARK_(b,"release"):b))return console.info("check-valid-task: PR is targeted to release branch, checking if task is a valid bug ticket or part of planned releases"),wrike_ist.wrike.is_wrike_task_in_folder_QMARK_(a).then(function(e){if(cljs.core.truth_(e))return console.info("check-valid-task: Task is in the folder or an inherited folder: true"),c.cljs$core$IFn$_invoke$arity$1?
c.cljs$core$IFn$_invoke$arity$1(a):c.call(null,a);console.error("check-valid-task: Task not found in folder");e=Error("check-valid-task: Task not found in folder");return d.cljs$core$IFn$_invoke$arity$1?d.cljs$core$IFn$_invoke$arity$1(e):d.call(null,e)});console.info("check-valid-task: PR is not targeted to release branch, returning success");return c.cljs$core$IFn$_invoke$arity$1?c.cljs$core$IFn$_invoke$arity$1(a):c.call(null,a)})};
wrike_ist.wrike.link_pr=function(a){var b=cljs.core.__destructure_map(a),c=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$206$pr_url);a=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$210$permalink);var d=cljs.core.get.cljs$core$IFn$_invoke$arity$2(b,cljs$cst$207$target_branch),e=wrike_ist.wrike.check_valid_task(a,d);return wrike_ist.wrike.find_task(a).then(function(f){f=cljs.core.__destructure_map(f);f=cljs.core.get.cljs$core$IFn$_invoke$arity$2(f,"id");var g=["https://www.wrike.com/api/v4/tasks/",
cljs.core.str.cljs$core$IFn$_invoke$arity$1(f),"/comments"].join("");return httpurr.client.node.get(g,new cljs.core.PersistentArrayMap(null,1,[cljs$cst$183$headers,wrike_ist.wrike.headers()],null)).then(function(h){return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(function(k,l){return cljs.core.truth_(cljs.core.get.cljs$core$IFn$_invoke$arity$2(l,"text").includes(c))?cljs.core.reduced(Promise.reject(cljs$cst$211$present)):k},Promise.resolve(),cljs.core.get.cljs$core$IFn$_invoke$arity$2(wrike_ist.wrike.parse_body(h),
"data"))}).then(function(){var h=function(l){l=wrike_ist.wrike.link_html(b);l=cljs.core.clj__GT_js(new cljs.core.PersistentArrayMap(null,2,[cljs$cst$212$text,l,cljs$cst$213$plainText,!1],null));return httpurr.client.node.post(g,new cljs.core.PersistentArrayMap(null,2,[cljs$cst$183$headers,wrike_ist.wrike.headers(),cljs$cst$184$body,JSON.stringify(l)],null))},k=function(l){var m=null;if(0<arguments.length){m=0;for(var n=Array(arguments.length-0);m<n.length;)n[m]=arguments[m+0],++m;m=new cljs.core.IndexedSeq(n,
Expand Down
4 changes: 2 additions & 2 deletions resources/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions src/wrike_ist/wrike.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,23 @@
(defn check-valid-task
[permalink target-branch]
(js/Promise.
(fn [resolve reject]
(when (and target-branch (str/starts-with? target-branch "release"))
(.info js/console (str "check-valid-task: PR is targeted to release branch, checking if task is a valid bug ticket or part of planned releases"))
(let [task-in-folder-promise (is-wrike-task-in-folder? permalink)]
(.then task-in-folder-promise
(fn [task-in-folder?]
(if task-in-folder?
(do
(.info js/console "check-valid-task: Task is in the folder or an inherited folder: true")
(resolve permalink))
(do
(.error js/console "check-valid-task: Task not found in folder")
(reject (js/Error. "check-valid-task: Task not found in folder")))))))))))

(fn [resolve reject]
(if (and target-branch (str/starts-with? target-branch "release"))
(do
(.info js/console (str "check-valid-task: PR is targeted to release branch, checking if task is a valid bug ticket or part of planned releases"))
(let [task-in-folder-promise (is-wrike-task-in-folder? permalink)]
(.then task-in-folder-promise
(fn [task-in-folder?]
(if task-in-folder?
(do
(.info js/console "check-valid-task: Task is in the folder or an inherited folder: true")
(resolve permalink))
(do
(.error js/console "check-valid-task: Task not found in folder")
(reject (js/Error. "check-valid-task: Task not found in folder"))))))))
(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 248240d

Please sign in to comment.