Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc]Fix the double label problem caused by too fast operation #24

Merged
merged 6 commits into from
Oct 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions doc-label-check/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ const enums_1 = __webpack_require__(346);
const utils_1 = __webpack_require__(611);
const labels_1 = __webpack_require__(66);
const logger_1 = __webpack_require__(504);
function processIssue(octokit, repo, owner, issue_number, htmlUrl, description, labelPattern, logger,labelsin,user1,botname) {
function processIssue(octokit, repo, owner, issue_number, htmlUrl, description, labelPattern, logger,labelsin,user1) {
return __awaiter(this, void 0, void 0, function* () {
logger.debug(`--- ${htmlUrl} ---`);
// Labels extracted from an issue description
Expand All @@ -2545,7 +2545,7 @@ function processIssue(octokit, repo, owner, issue_number, htmlUrl, description,
});
// Labels added or removed by users
const labelsToIgnore = utils_1.removeDuplicates(listEventsData
.filter(event => utils_1.isLabelEvent(event) && !utils_1.isCreatedByUser(event,botname))
.filter(event => utils_1.isLabelEvent(event) && utils_1.isCreatedByUser(event))
.map(({ label }) => label && label.name));
logger.debug(listEventsData)
logger.debug('Labels to ignore:');
Expand Down Expand Up @@ -2588,24 +2588,28 @@ function processIssue(octokit, repo, owner, issue_number, htmlUrl, description,

const labelsToAdd = labelsToProcess.filter(shouldAdd).map(labels_1.getName);
var issuelabels=utils_1.removeDuplicates(labelsToAdd.concat(labelsin));
console.log(issuelabels);
console.log(labelsToRemove);
if(labelsToRemove.length!=0){
issuelabels=issuelabels.filter((x)=>labelsToRemove.some((item=>x!=item)))}
var corrent=0
console.log(issuelabels);
console.log(labelsToRemove);
if(labelsToRemove.length!=0){
issuelabels=issuelabels.filter((x)=>labelsToRemove.some((item=>x!=item)))}
console.log("-----------------------");
console.log(issuelabels);
console.log("-----------------------");
var num=0
var isdocmis=0
for(let index=0;index<Labels.length;index++){
if(issuelabels.includes(Labels[index])){
console.log(Labels[index],"issue exists");
if(Labels[index]=='doc-info-missing'){
isdocmis=1
}
console.log(Labels[index],"issue exists");
if(Labels[index]=='doc-info-missing'){
isdocmis=1
}
}else{
num=num+1
}
if(labelsToAdd.includes(Labels[index])){
corrent=1;
}
}
const errmessage="@"+user1+":Thanks for your contribution. For this PR, do we need to update docs?\n(The [PR template contains info about doc](https://github.com/apache/pulsar/blob/master/.github/PULL_REQUEST_TEMPLATE.md#documentation), which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)"
if(num==4 && isdocmis==0){
Expand Down Expand Up @@ -2645,6 +2649,14 @@ function processIssue(octokit, repo, owner, issue_number, htmlUrl, description,
labels: labelsToAdd,
});
}
if(corrent==1){
yield octokit.issues.removeLabel({
owner,
repo,
issue_number,
name:"doc-info-missing"
})
}
});
}
function main() {
Expand All @@ -2653,7 +2665,6 @@ function main() {
try {
const token = core.getInput('github-token', { required: true });
const labelPattern = core.getInput('label-pattern', { required: true });
const botname = core.getInput('bot-name', { required:true });
const quiet = core.getInput('quiet', { required: false });
const offset = core.getInput('offset', { required: false });
utils_1.validateEnum('quiet', quiet, enums_1.Quiet);
Expand All @@ -2675,7 +2686,7 @@ function main() {
if (body === undefined || html_url === undefined) {
return;
}
yield processIssue(octokit, repo, owner, issue_number, html_url, body, labelPattern, logger,labelsin,user1,botname);
yield processIssue(octokit, repo, owner, issue_number, html_url, body, labelPattern, logger,labelsin,user1);
break;
}
case 'pull_request':
Expand All @@ -2692,7 +2703,7 @@ function main() {
if (body === undefined || html_url === undefined) {
return;
}
yield processIssue(octokit, repo, owner, issue_number, html_url, body, labelPattern, logger,labelsin,user1,botname);
yield processIssue(octokit, repo, owner, issue_number, html_url, body, labelPattern, logger,labelsin,user1);
break;
}
case 'schedule': {
Expand Down Expand Up @@ -7218,8 +7229,8 @@ exports.isLabelEvent = isLabelEvent;
* @param event issue event
* @returns true if a given event is created by a user otherwise false
*/
function isCreatedByUser(event,botname) {
return event.actor.login === botname;
function isCreatedByUser(event) {
return event.actor.type === 'User';;
}
exports.isCreatedByUser = isCreatedByUser;
/**
Expand Down