From 04f329f45215f19c279d39521caceaf3872f6569 Mon Sep 17 00:00:00 2001 From: wangyuan249 <35907099+wangyuan249@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:38:18 +0800 Subject: [PATCH 1/7] Dev (#3) * fix readme * change url * judge triage --- README.md | 5 +++++ api/octokit.js | 6 +++++- commands/Commands.js | 22 ++++++++++++++-------- commands/Parse.js | 24 ------------------------ 4 files changed, 24 insertions(+), 33 deletions(-) delete mode 100644 commands/Parse.js diff --git a/README.md b/README.md index 48dabd1..13053d6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,12 @@ Github action commands for automating issue management. +<<<<<<< HEAD Based on work from:
https://github.com/microsoft/vscode-github-triage-actions
+======= +Based on work from: +https://github.com/microsoft/vscode-github-triage-actions +>>>>>>> 318eb971056f08d5e3cbf7cc81d8fbc475966594 and https://github.com/grafana/grafana-github-actions diff --git a/api/octokit.js b/api/octokit.js index f132b2f..430a20f 100644 --- a/api/octokit.js +++ b/api/octokit.js @@ -93,16 +93,20 @@ class OctoKit { isPullRequest: !!issue.pull_request, }; } - async hasWriteAccess(user) { + async hasWriteAccess(user) { this if (user.name in this.writeAccessCache) { core_1.debug('Got permissions from cache for ' + user); return this.writeAccessCache[user.name]; } core_1.debug('Fetching permissions for ' + user); + console.log("######Fetching permissions for \n", user.name.toString()) const permissions = (await this.octokit.repos.getCollaboratorPermissionLevel({ ...this.params, username: user.name, })).data.permission; + console.log("######Permission Result \n",this.writeAccessCache[user.name] = permissions === 'admin' ) + console.log("######Permission Result \n",permissions === 'write' ) + console.log("######Permission Result \n",permissions.toString() ) return (this.writeAccessCache[user.name] = permissions === 'admin' || permissions === 'write'); } async repoHasLabel(name) { diff --git a/commands/Commands.js b/commands/Commands.js index f20c264..e55742f 100644 --- a/commands/Commands.js +++ b/commands/Commands.js @@ -28,11 +28,11 @@ class Commands { return command.type === 'label' && this.action.label === command.name; } if ('comment' in this.action) { -// const userStr = this.fileFetcher(); const userStr = await this.fileFetcher() - console.log("########### userStr: \n\n", userStr.toString()); - console.log("########### this.action.user.name: \n\n", this.action.user.name); - console.log("########### whether has substr: \n\n", userStr.toString().includes(this.action.user.name)); // 获取返回字符串中的某一个值 + // test log in action when merge into master + console.log("########### userStr: \n", userStr.toString()); + console.log("########### this.action.user.name: \n", this.action.user.name); + console.log("########### whether has substr: \n", userStr.toString().includes(this.action.user.name)); // 获取返回字符串中的某一个值 return (command.type === 'comment' && !!this.action.comment.match(new RegExp(`(/|\\\\)${escapeRegExp(command.name)}(\\s|$)`, 'i')) && ((await this.github.hasWriteAccess(this.action.user)) || @@ -85,6 +85,8 @@ class Commands { if ('comment' in this.action && (command.name === 'label' || command.name === 'assign')) { const args = []; let argList = ((_b = (_a = this.action.comment.match(new RegExp(String.raw `(?:\\|/)${command.name}(.*)(?:\r)?(?:\n|$)`))) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '').trim(); + console.log("comment str: ", this.action.comment.toString) + console.log("argList:", argList.toString()) while (argList) { const task = argList[0] === '-' ? 'remove' : 'add'; if (task === 'remove') @@ -114,6 +116,9 @@ class Commands { : this.github.removeLabel(arg.name))); } if (command.name === 'assign') { + console.log("arg.name: 1 ",arg.name) + console.log("arg.name: 2 ",arg.name[0]) + console.log("arg.name: 3 ",arg.name.slice(1)) tasks.push(...args.map((arg) => arg.task === 'add' ? this.github.addAssignee(arg.name[0] === '@' ? arg.name.slice(1) : arg.name) : this.github.removeAssignee(arg.name[0] === '@' ? arg.name.slice(1) : arg.name))); @@ -146,9 +151,10 @@ class Commands { } } } - var url = 'https://raw.githubusercontent.com/wangyuan249/actioTestRepo/master/userList.md'; // 获取课程列表,带参数的get请求 - xhr.open('get', url, false); // 开启一个请求,但还没有向服务器端发起请求,执行后redayState的值变为1 async false 好像是异步 响应更快一些 true不太行s - xhr.send(null); // 向服务器端发起请求,执行后redayState的值变为2 // 补充:当服务器端开始返回请求数据的时候,浏览器端接收到这个数据,redayState的值变为3。 // 当浏览器端结束请求时,redayState的值变为4,status的值变为200(表示请求成功),responseText变为相应的返回值。 + var url = 'https://raw.githubusercontent.com/oam-dev/kubevela/master/.github/comment.userlist'; // 获取课程列表,带参数的get请求 + xhr.open('get', url, false); // 开启一个请求,但还没有向服务器端发起请求,执行后redayState的值变为1 async 异步 当为false时会响应更快一些,而true会有时没有响应 + xhr.send(null); // 向服务器端发起请求,执行后redayState的值变为2 // 补充:当服务器端开始返回请求数据的时候,浏览器端接收到这个数据,redayState的值变为3。 + // 当浏览器端结束请求时,redayState的值变为4,status的值变为200(表示请求成功),responseText变为相应的返回值。 return xhr.responseText.toString() } async run() { @@ -166,4 +172,4 @@ exports.Commands = Commands; function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } -//# sourceMappingURL=Commands.js.map +//# sourceMappingURL=Commands.js.map \ No newline at end of file diff --git a/commands/Parse.js b/commands/Parse.js deleted file mode 100644 index 3b7ecba..0000000 --- a/commands/Parse.js +++ /dev/null @@ -1,24 +0,0 @@ -var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; -// var xhr = new XMLHttpRequest(); - - -function productClickHandler() { - var xhr = new XMLHttpRequest(); // 创建xhr对象 - xhr.onreadystatechange = function() { - if(xhr.readyState == 4) { - if((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) { - // var result = JSON.parse(xhr.responseText); // 将字符串转化为对象,然后才能获取到返回字符串中的某一个值 - var result = xhr.responseText; // 将字符串转化为对象,然后才能获取到返回字符串中的某一个值 - // console.log(result.toString()); // 获取返回字符串中的某一个值 - } else { - alert('Request was unsuccessful: ' + xhr.status); - } - } - } - var url = 'https://raw.githubusercontent.com/wangyuan249/actioTestRepo/master/userList.md'; // 获取课程列表,带参数的get请求 - xhr.open('get', url, false); // 开启一个请求,但还没有向服务器端发起请求,执行后redayState的值变为1 async false 好像是异步 响应更快一些 true不太行s - xhr.send(null); // 向服务器端发起请求,执行后redayState的值变为2 // 补充:当服务器端开始返回请求数据的时候,浏览器端接收到这个数据,redayState的值变为3。 // 当浏览器端结束请求时,redayState的值变为4,status的值变为200(表示请求成功),responseText变为相应的返回值。 - return xhr.responseText.toString() -} -res = productClickHandler() -console.log("res\n", res) \ No newline at end of file From 6087ff083042a29541f7fb04186f138867e78cb5 Mon Sep 17 00:00:00 2001 From: wangyuan249 <35907099+wangyuan249@users.noreply.github.com> Date: Mon, 5 Jul 2021 13:08:32 +0800 Subject: [PATCH 2/7] Dev (#4) * fix readme * change url * judge triage --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 13053d6..86aabf4 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ Github action commands for automating issue management. -<<<<<<< HEAD Based on work from:
https://github.com/microsoft/vscode-github-triage-actions
-======= -Based on work from: -https://github.com/microsoft/vscode-github-triage-actions ->>>>>>> 318eb971056f08d5e3cbf7cc81d8fbc475966594 and https://github.com/grafana/grafana-github-actions + From 7e8d94a0f0c1a5f05306b1eb50001755aa1b3773 Mon Sep 17 00:00:00 2001 From: wangyuan249 <35907099+wangyuan249@users.noreply.github.com> Date: Mon, 5 Jul 2021 13:11:38 +0800 Subject: [PATCH 3/7] Update Commands.js --- commands/Commands.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/commands/Commands.js b/commands/Commands.js index e55742f..79f6dac 100644 --- a/commands/Commands.js +++ b/commands/Commands.js @@ -30,7 +30,7 @@ class Commands { if ('comment' in this.action) { const userStr = await this.fileFetcher() // test log in action when merge into master - console.log("########### userStr: \n", userStr.toString()); + // console.log("########### userStr: \n", userStr.toString()); console.log("########### this.action.user.name: \n", this.action.user.name); console.log("########### whether has substr: \n", userStr.toString().includes(this.action.user.name)); // 获取返回字符串中的某一个值 return (command.type === 'comment' && @@ -85,7 +85,9 @@ class Commands { if ('comment' in this.action && (command.name === 'label' || command.name === 'assign')) { const args = []; let argList = ((_b = (_a = this.action.comment.match(new RegExp(String.raw `(?:\\|/)${command.name}(.*)(?:\r)?(?:\n|$)`))) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '').trim(); - console.log("comment str: ", this.action.comment.toString) + console.log("comment str1: ", this.action.comment.toString) + console.log("comment str2: ", this.action.comment.name) + console.log("comment str3: ", this.action.comment) console.log("argList:", argList.toString()) while (argList) { const task = argList[0] === '-' ? 'remove' : 'add'; @@ -116,9 +118,9 @@ class Commands { : this.github.removeLabel(arg.name))); } if (command.name === 'assign') { - console.log("arg.name: 1 ",arg.name) - console.log("arg.name: 2 ",arg.name[0]) - console.log("arg.name: 3 ",arg.name.slice(1)) +// console.log("arg.name: 1 ",arg.name) +// console.log("arg.name: 2 ",arg.name[0]) +// console.log("arg.name: 3 ",arg.name.slice(1)) tasks.push(...args.map((arg) => arg.task === 'add' ? this.github.addAssignee(arg.name[0] === '@' ? arg.name.slice(1) : arg.name) : this.github.removeAssignee(arg.name[0] === '@' ? arg.name.slice(1) : arg.name))); @@ -172,4 +174,4 @@ exports.Commands = Commands; function escapeRegExp(string) { return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string } -//# sourceMappingURL=Commands.js.map \ No newline at end of file +//# sourceMappingURL=Commands.js.map From 1f25f710bc0f588369364ec4b7f2a8561a468784 Mon Sep 17 00:00:00 2001 From: wangyuan249 <35907099+wangyuan249@users.noreply.github.com> Date: Mon, 5 Jul 2021 17:06:38 +0800 Subject: [PATCH 4/7] Update Commands.js --- commands/Commands.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/Commands.js b/commands/Commands.js index 79f6dac..ca73d52 100644 --- a/commands/Commands.js +++ b/commands/Commands.js @@ -30,7 +30,7 @@ class Commands { if ('comment' in this.action) { const userStr = await this.fileFetcher() // test log in action when merge into master - // console.log("########### userStr: \n", userStr.toString()); + console.log("########### userStr: \n", userStr.toString()); console.log("########### this.action.user.name: \n", this.action.user.name); console.log("########### whether has substr: \n", userStr.toString().includes(this.action.user.name)); // 获取返回字符串中的某一个值 return (command.type === 'comment' && From d1d57d837e91c143ab21e5f0e7dba33658690e99 Mon Sep 17 00:00:00 2001 From: wangyuan249 <35907099+wangyuan249@users.noreply.github.com> Date: Mon, 5 Jul 2021 17:26:16 +0800 Subject: [PATCH 5/7] Update Commands.js --- commands/Commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/commands/Commands.js b/commands/Commands.js index ca73d52..04679bc 100644 --- a/commands/Commands.js +++ b/commands/Commands.js @@ -30,6 +30,7 @@ class Commands { if ('comment' in this.action) { const userStr = await this.fileFetcher() // test log in action when merge into master + console.log("Test in release 0.3") console.log("########### userStr: \n", userStr.toString()); console.log("########### this.action.user.name: \n", this.action.user.name); console.log("########### whether has substr: \n", userStr.toString().includes(this.action.user.name)); // 获取返回字符串中的某一个值 From c8d8a729c7a9ef304256f4d0b5651526211a54c4 Mon Sep 17 00:00:00 2001 From: wangyuan249 <35907099+wangyuan249@users.noreply.github.com> Date: Tue, 6 Jul 2021 10:29:01 +0800 Subject: [PATCH 6/7] Update octokit.js --- api/octokit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/octokit.js b/api/octokit.js index 430a20f..6a940c3 100644 --- a/api/octokit.js +++ b/api/octokit.js @@ -93,7 +93,7 @@ class OctoKit { isPullRequest: !!issue.pull_request, }; } - async hasWriteAccess(user) { this + async hasWriteAccess(user) { if (user.name in this.writeAccessCache) { core_1.debug('Got permissions from cache for ' + user); return this.writeAccessCache[user.name]; @@ -455,4 +455,4 @@ function isIssue(object) { 'milestoneId' in object; return isIssue; } -//# sourceMappingURL=octokit.js.map \ No newline at end of file +//# sourceMappingURL=octokit.js.map From 791282304857201c797f1a59b40e268bfa462df5 Mon Sep 17 00:00:00 2001 From: wangyuan249 <249401644@qq.com> Date: Tue, 6 Jul 2021 14:25:11 +0800 Subject: [PATCH 7/7] release version --- commands/Commands.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/commands/Commands.js b/commands/Commands.js index 04679bc..8cc3961 100644 --- a/commands/Commands.js +++ b/commands/Commands.js @@ -30,7 +30,7 @@ class Commands { if ('comment' in this.action) { const userStr = await this.fileFetcher() // test log in action when merge into master - console.log("Test in release 0.3") + console.log("Test in release 0.2 --data 0706") console.log("########### userStr: \n", userStr.toString()); console.log("########### this.action.user.name: \n", this.action.user.name); console.log("########### whether has substr: \n", userStr.toString().includes(this.action.user.name)); // 获取返回字符串中的某一个值 @@ -119,9 +119,6 @@ class Commands { : this.github.removeLabel(arg.name))); } if (command.name === 'assign') { -// console.log("arg.name: 1 ",arg.name) -// console.log("arg.name: 2 ",arg.name[0]) -// console.log("arg.name: 3 ",arg.name.slice(1)) tasks.push(...args.map((arg) => arg.task === 'add' ? this.github.addAssignee(arg.name[0] === '@' ? arg.name.slice(1) : arg.name) : this.github.removeAssignee(arg.name[0] === '@' ? arg.name.slice(1) : arg.name)));