refactor: simplify constant names
This commit is contained in:
Родитель
10b5148354
Коммит
46ae1b1ad0
|
@ -12,12 +12,12 @@ module.exports = function (context, req) {
|
|||
'Authorization': 'token ' + constants_1.ACCESS_TOKEN
|
||||
};
|
||||
var pullRequestNumber = req.number;
|
||||
github_1.getPullRequest(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, pullRequestNumber, function (pullRequest) {
|
||||
github_1.getPullRequest(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, pullRequestNumber, function (pullRequest) {
|
||||
var creationMessage = pullRequest.body;
|
||||
var firstBlockOfCreationMessage = creationMessage.split(firstBlockTitle)[0];
|
||||
if (firstBlockOfCreationMessage) {
|
||||
var linkedItemsNumbers = utils_1.distinct(functions_1.searchLinkedItemsNumbersInComment(firstBlockOfCreationMessage));
|
||||
github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, linkedItemsNumbers, function (results) {
|
||||
github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, linkedItemsNumbers, function (results) {
|
||||
var issuesNumber = results
|
||||
.filter(function (r) { return r.__typename === 'Issue'; })
|
||||
.map(function (r) { return r.__typename === 'Issue' ? r.number : null; })
|
||||
|
@ -28,19 +28,19 @@ module.exports = function (context, req) {
|
|||
return;
|
||||
}
|
||||
if (constants_1.ACTIVATE_MUTATION) {
|
||||
github_1.getIssuesLabels(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, issuesNumber, function (issuesWithLabels) {
|
||||
github_1.getIssuesLabels(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, issuesNumber, function (issuesWithLabels) {
|
||||
if (req.action === 'closed') {
|
||||
var issuesWithLabelsWithExpectedLabel = issuesWithLabels.filter(function (iwl) { return iwl.labels.some(function (label) { return label === labelPRinProgress; }); });
|
||||
issuesWithLabelsWithExpectedLabel.map(function (issueWithLabels) {
|
||||
var labels = utils_1.distinct(issueWithLabels.labels.filter(function (label) { return label !== labelPRinProgress; }));
|
||||
github_1.setLabelsForIssue(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, issueWithLabels.number, labels);
|
||||
github_1.setLabelsForIssue(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, issueWithLabels.number, labels);
|
||||
});
|
||||
}
|
||||
if (req.action === 'opened' || req.action === 'reopened') {
|
||||
var issuesWithLabelsWithoutExpectedLabel = issuesWithLabels.filter(function (iwl) { return iwl.labels.every(function (label) { return label !== labelPRinProgress; }); });
|
||||
issuesWithLabelsWithoutExpectedLabel.map(function (issueWithLabels) {
|
||||
var labels = utils_1.distinct(issueWithLabels.labels.concat([labelPRinProgress]));
|
||||
github_1.setLabelsForIssue(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, issueWithLabels.number, labels);
|
||||
github_1.setLabelsForIssue(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, issueWithLabels.number, labels);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { getPullRequest, getIssueOrPullRequestLinks, setLabelsForIssue, getIssuesLabels } from '../shared/github';
|
||||
import { searchLinkedItemsNumbersInComment, completeFunction } from '../shared/functions';
|
||||
import { distinct } from '../shared/utils';
|
||||
import { ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
import { ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
|
||||
const firstBlockTitle = '## PR Type';
|
||||
const labelPRinProgress = 'PR in progress';
|
||||
|
@ -16,8 +16,8 @@ module.exports = (context, req) => {
|
|||
|
||||
getPullRequest(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
pullRequestNumber,
|
||||
(pullRequest) => {
|
||||
// retrieve first block of creation block where user puts the linked issues
|
||||
|
@ -27,7 +27,7 @@ module.exports = (context, req) => {
|
|||
if (firstBlockOfCreationMessage) {
|
||||
const linkedItemsNumbers = distinct(searchLinkedItemsNumbersInComment(firstBlockOfCreationMessage));
|
||||
|
||||
getIssueOrPullRequestLinks(githubApiHeaders, REPO_OWNER, REPO_NAME, linkedItemsNumbers, (results) => {
|
||||
getIssueOrPullRequestLinks(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, linkedItemsNumbers, (results) => {
|
||||
const issuesNumber = results
|
||||
.filter(r => r.__typename === 'Issue')
|
||||
.map(r => r.__typename === 'Issue' ? r.number : null)
|
||||
|
@ -40,7 +40,7 @@ module.exports = (context, req) => {
|
|||
}
|
||||
|
||||
if (ACTIVATE_MUTATION) {
|
||||
getIssuesLabels(githubApiHeaders, REPO_OWNER, REPO_NAME, issuesNumber, (issuesWithLabels) => {
|
||||
getIssuesLabels(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, issuesNumber, (issuesWithLabels) => {
|
||||
if (req.action === 'closed') {
|
||||
// filter issues which DOES already contain the label
|
||||
const issuesWithLabelsWithExpectedLabel =
|
||||
|
@ -49,7 +49,7 @@ module.exports = (context, req) => {
|
|||
// remove label 'PR in progress'
|
||||
issuesWithLabelsWithExpectedLabel.map(issueWithLabels => {
|
||||
const labels = distinct(issueWithLabels.labels.filter(label => label !== labelPRinProgress));
|
||||
setLabelsForIssue(githubApiHeaders, REPO_OWNER, REPO_NAME, issueWithLabels.number, labels);
|
||||
setLabelsForIssue(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, issueWithLabels.number, labels);
|
||||
});
|
||||
}
|
||||
if (req.action === 'opened' || req.action === 'reopened') {
|
||||
|
@ -60,7 +60,7 @@ module.exports = (context, req) => {
|
|||
// add label 'PR in progress'
|
||||
issuesWithLabelsWithoutExpectedLabel.map(issueWithLabels => {
|
||||
const labels = distinct(issueWithLabels.labels.concat([labelPRinProgress]));
|
||||
setLabelsForIssue(githubApiHeaders, REPO_OWNER, REPO_NAME, issueWithLabels.number, labels);
|
||||
setLabelsForIssue(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, issueWithLabels.number, labels);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
|
|
@ -9,11 +9,11 @@ module.exports = function (context) {
|
|||
'User-Agent': 'github-bot-uwp-toolkit',
|
||||
'Authorization': 'token ' + constants_1.ACCESS_TOKEN
|
||||
};
|
||||
github_1.getAllMilestones(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, function (milestones) {
|
||||
github_1.getAllMilestones(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, function (milestones) {
|
||||
var currentMilestone = milestones
|
||||
.filter(function (m) { return m.state === 'OPEN' && !!m.dueOn; })
|
||||
.sort(function (m1, m2) { return new Date(m1.dueOn).getTime() - new Date(m2.dueOn).getTime(); })[0];
|
||||
github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, null, function (issues) {
|
||||
github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, null, function (issues) {
|
||||
var exclusiveLabels = [
|
||||
'PR in progress',
|
||||
'work in progress',
|
||||
|
@ -90,7 +90,7 @@ var makeDecisionsForIssuesInCurrentMilestone = function (githubApiHeaders, issue
|
|||
};
|
||||
var makeDecisionsForIssuesNotInMilestone = function (githubApiHeaders, issues) {
|
||||
var decisions = issues.map(function (issue) {
|
||||
var numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent(constants_1.BOT_USERNAME, issue);
|
||||
var numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent(constants_1.BOT_LOGIN, issue);
|
||||
if (numberOfAlertsAlreadySent === 2) {
|
||||
return {
|
||||
issue: issue,
|
||||
|
@ -115,7 +115,7 @@ var makeDecisionsForIssuesNotInMilestone = function (githubApiHeaders, issues) {
|
|||
});
|
||||
decisions.filter(function (d) { return d.decision === 'close'; }).forEach(function (d) {
|
||||
github_1.commentGitHubIssue(githubApiHeaders, d.issue.id, 'Issue is inactive. It was automatically closed.');
|
||||
github_1.closeGitHubIssue(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, d.issue.number, d.issue.id);
|
||||
github_1.closeGitHubIssue(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, d.issue.number, d.issue.id);
|
||||
});
|
||||
}
|
||||
return decisions;
|
||||
|
|
|
@ -2,7 +2,7 @@ import { addDays, distinct } from '../shared/utils';
|
|||
import { completeFunction, containsExclusiveLabels } from '../shared/functions';
|
||||
import { IssueNode } from '../shared/models';
|
||||
import { getAllMilestones, getAllGitHubIssuesRecursively, commentGitHubIssue, closeGitHubIssue } from '../shared/github';
|
||||
import { ACCESS_TOKEN, REPO_OWNER, REPO_NAME, NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACTIVATE_MUTATION, BOT_USERNAME } from '../shared/constants';
|
||||
import { ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACTIVATE_MUTATION, BOT_LOGIN } from '../shared/constants';
|
||||
|
||||
module.exports = (context) => {
|
||||
const githubApiHeaders = {
|
||||
|
@ -12,8 +12,8 @@ module.exports = (context) => {
|
|||
|
||||
getAllMilestones(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
(milestones) => {
|
||||
const currentMilestone = milestones
|
||||
.filter(m => m.state === 'OPEN' && !!m.dueOn)
|
||||
|
@ -22,8 +22,8 @@ module.exports = (context) => {
|
|||
|
||||
getAllGitHubIssuesRecursively(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
null,
|
||||
(issues) => {
|
||||
const exclusiveLabels = [
|
||||
|
@ -140,8 +140,9 @@ const makeDecisionsForIssuesNotInMilestone = (githubApiHeaders: any, issues: Iss
|
|||
// take a decision about the issue (send a new alert or close it)
|
||||
const decisions = issues.map<IssueActivityDecision>(issue => {
|
||||
const numberOfAlertsAlreadySent = detectNumberOfAlertsAlreadySent(
|
||||
BOT_USERNAME,
|
||||
issue);
|
||||
BOT_LOGIN,
|
||||
issue
|
||||
);
|
||||
|
||||
if (numberOfAlertsAlreadySent === 2) {
|
||||
return {
|
||||
|
@ -182,8 +183,8 @@ const makeDecisionsForIssuesNotInMilestone = (githubApiHeaders: any, issues: Iss
|
|||
|
||||
closeGitHubIssue(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
d.issue.number,
|
||||
d.issue.id);
|
||||
});
|
||||
|
|
|
@ -9,11 +9,11 @@ module.exports = function (context) {
|
|||
'User-Agent': 'github-bot-uwp-toolkit',
|
||||
'Authorization': 'token ' + constants_1.ACCESS_TOKEN
|
||||
};
|
||||
github_1.getAllMilestones(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, function (milestones) {
|
||||
github_1.getAllMilestones(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, function (milestones) {
|
||||
var currentMilestone = milestones
|
||||
.filter(function (m) { return m.state === 'OPEN' && !!m.dueOn; })
|
||||
.sort(function (m1, m2) { return new Date(m1.dueOn).getTime() - new Date(m2.dueOn).getTime(); })[0];
|
||||
github_1.getAllOpenPullRequests(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, function (pullRequests) {
|
||||
github_1.getAllOpenPullRequests(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, function (pullRequests) {
|
||||
var exclusiveLabels = [
|
||||
'help wanted',
|
||||
'mute-bot'
|
||||
|
|
|
@ -2,7 +2,7 @@ import { getAllMilestones, getAllOpenPullRequests, commentGitHubPullRequest } fr
|
|||
import { containsExclusiveLabels, completeFunction } from '../shared/functions';
|
||||
import { PullRequest } from '../shared/models';
|
||||
import { addDays } from '../shared/utils';
|
||||
import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
|
||||
module.exports = (context) => {
|
||||
const githubApiHeaders = {
|
||||
|
@ -12,8 +12,8 @@ module.exports = (context) => {
|
|||
|
||||
getAllMilestones(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
(milestones) => {
|
||||
const currentMilestone = milestones
|
||||
.filter(m => m.state === 'OPEN' && !!m.dueOn)
|
||||
|
@ -22,8 +22,8 @@ module.exports = (context) => {
|
|||
|
||||
getAllOpenPullRequests(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
(pullRequests) => {
|
||||
const exclusiveLabels = [
|
||||
'help wanted',
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = function (context) {
|
|||
'User-Agent': 'github-bot-uwp-toolkit',
|
||||
'Authorization': 'token ' + constants_1.ACCESS_TOKEN
|
||||
};
|
||||
github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, null, function (issues) {
|
||||
github_1.getAllGitHubIssuesRecursively(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, null, function (issues) {
|
||||
var exclusiveLabels = [
|
||||
'PR in progress',
|
||||
'work in progress',
|
||||
|
|
|
@ -2,7 +2,7 @@ import { addDays, distinct } from '../shared/utils';
|
|||
import { completeFunction } from '../shared/functions';
|
||||
import { IssueNode } from '../shared/models';
|
||||
import { getAllGitHubIssuesRecursively, commentGitHubIssue } from '../shared/github';
|
||||
import { NUMBER_OF_DAYS_WITHOUT_RESPONSE, ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
import { NUMBER_OF_DAYS_WITHOUT_RESPONSE, ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
|
||||
module.exports = (context) => {
|
||||
const githubApiHeaders = {
|
||||
|
@ -12,8 +12,8 @@ module.exports = (context) => {
|
|||
|
||||
getAllGitHubIssuesRecursively(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
null,
|
||||
(issues) => {
|
||||
const exclusiveLabels = [
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = function (context) {
|
|||
'User-Agent': 'github-bot-uwp-toolkit',
|
||||
'Authorization': 'token ' + constants_1.ACCESS_TOKEN
|
||||
};
|
||||
github_1.getAllGitHubIssuesRecursivelyFilterWithLabels(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, null, ["pending-uservoice-creation"], function (issues) {
|
||||
github_1.getAllGitHubIssuesRecursivelyFilterWithLabels(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, null, ["pending-uservoice-creation"], function (issues) {
|
||||
context.log("Total of " + issues.length + " issues pending uservoice creation.");
|
||||
context.log(issues);
|
||||
var issuesWithoutActivity = issues.filter(function (issue) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { addDays } from '../shared/utils';
|
||||
import { completeFunction } from '../shared/functions';
|
||||
import { getAllGitHubIssuesRecursivelyFilterWithLabels, commentGitHubIssue } from '../shared/github';
|
||||
import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, REPO_OWNER, REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
import { NUMBER_OF_DAYS_WITHOUT_ACTIVITY, ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
|
||||
module.exports = (context) => {
|
||||
const githubApiHeaders = {
|
||||
|
@ -11,8 +11,8 @@ module.exports = (context) => {
|
|||
|
||||
getAllGitHubIssuesRecursivelyFilterWithLabels(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
null,
|
||||
["pending-uservoice-creation"],
|
||||
(issues) => {
|
||||
|
|
10
readme.md
10
readme.md
|
@ -51,10 +51,10 @@ These environment variables should be set to launch the bot.
|
|||
|
||||
| Variable | Description | Default value |
|
||||
|-|-|-|
|
||||
| GITHUB_BOT_UWP_TOOLKIT_USERNAME | Username of the GitHub account of the bot | uwptoolkitbot |
|
||||
| GITHUB_BOT_UWP_TOOLKIT_ACCESS_TOKEN | Personal Access Token used to retrieve data from the GitHub API | |
|
||||
| GITHUB_BOT_UWP_TOOLKIT_REPO_OWNER | Target Repository owner | windows-toolkit |
|
||||
| GITHUB_BOT_UWP_TOOLKIT_REPO_NAME | Target Repository name | WindowsCommunityToolkit |
|
||||
| GITHUB_BOT_UWP_TOOLKIT_ACTIVATE_MUTATION | Activate GitHub mutation calls | false |
|
||||
| GITHUB_BOT_LOGIN | Login of the GitHub account of the bot | uwptoolkitbot |
|
||||
| GITHUB_BOT_ACCESS_TOKEN | Personal Access Token used to retrieve data from the GitHub API | |
|
||||
| GITHUB_BOT_TARGET_REPO_OWNER | Target Repository owner | windows-toolkit |
|
||||
| GITHUB_BOT_TARGET_REPO_NAME | Target Repository name | WindowsCommunityToolkit |
|
||||
| GITHUB_BOT_ACTIVATE_MUTATION | Activate GitHub mutation calls | false |
|
||||
| NUMBER_OF_DAYS_WITHOUT_ACTIVITY | Number of days without activity to check on `inactiveIssues` function | 7 |
|
||||
| NUMBER_OF_DAYS_WITHOUT_RESPONSE | Number of days without response to check on `noResponseFromCommunityOnIssues` function | 7 |
|
|
@ -1,10 +1,10 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BOT_USERNAME = process.env.GITHUB_BOT_UWP_TOOLKIT_USERNAME || 'uwptoolkitbot';
|
||||
exports.ACCESS_TOKEN = process.env.GITHUB_BOT_UWP_TOOLKIT_ACCESS_TOKEN;
|
||||
exports.REPO_OWNER = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_OWNER || 'windows-toolkit';
|
||||
exports.REPO_NAME = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_NAME || 'WindowsCommunityToolkit';
|
||||
exports.ACTIVATE_MUTATION = process.env.GITHUB_BOT_UWP_TOOLKIT_ACTIVATE_MUTATION === 'true' ? true : false;
|
||||
exports.BOT_LOGIN = process.env.GITHUB_BOT_LOGIN || 'uwptoolkitbot';
|
||||
exports.ACCESS_TOKEN = process.env.GITHUB_BOT_ACCESS_TOKEN;
|
||||
exports.TARGET_REPO_OWNER = process.env.GITHUB_BOT_TARGET_REPO_OWNER || 'windows-toolkit';
|
||||
exports.TARGET_REPO_NAME = process.env.GITHUB_BOT_TARGET_REPO_NAME || 'WindowsCommunityToolkit';
|
||||
exports.ACTIVATE_MUTATION = process.env.GITHUB_BOT_ACTIVATE_MUTATION === 'true' ? true : false;
|
||||
exports.NUMBER_OF_DAYS_WITHOUT_ACTIVITY = process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY) : 7;
|
||||
exports.NUMBER_OF_DAYS_WITHOUT_RESPONSE = process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE) : 7;
|
||||
//# sourceMappingURL=constants.js.map
|
|
@ -1,7 +1,7 @@
|
|||
export const BOT_USERNAME = process.env.GITHUB_BOT_UWP_TOOLKIT_USERNAME || 'uwptoolkitbot';
|
||||
export const ACCESS_TOKEN = process.env.GITHUB_BOT_UWP_TOOLKIT_ACCESS_TOKEN;
|
||||
export const REPO_OWNER = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_OWNER || 'windows-toolkit';
|
||||
export const REPO_NAME = process.env.GITHUB_BOT_UWP_TOOLKIT_REPO_NAME || 'WindowsCommunityToolkit';
|
||||
export const ACTIVATE_MUTATION = process.env.GITHUB_BOT_UWP_TOOLKIT_ACTIVATE_MUTATION === 'true' ? true : false;
|
||||
export const BOT_LOGIN = process.env.GITHUB_BOT_LOGIN || 'uwptoolkitbot';
|
||||
export const ACCESS_TOKEN = process.env.GITHUB_BOT_ACCESS_TOKEN;
|
||||
export const TARGET_REPO_OWNER = process.env.GITHUB_BOT_TARGET_REPO_OWNER || 'windows-toolkit';
|
||||
export const TARGET_REPO_NAME = process.env.GITHUB_BOT_TARGET_REPO_NAME || 'WindowsCommunityToolkit';
|
||||
export const ACTIVATE_MUTATION = process.env.GITHUB_BOT_ACTIVATE_MUTATION === 'true' ? true : false;
|
||||
export const NUMBER_OF_DAYS_WITHOUT_ACTIVITY = process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_ACTIVITY) : 7;
|
||||
export const NUMBER_OF_DAYS_WITHOUT_RESPONSE = process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE ? parseInt(process.env.NUMBER_OF_DAYS_WITHOUT_RESPONSE) : 7;
|
|
@ -15,9 +15,9 @@ module.exports = function (context, req) {
|
|||
'Authorization': 'token ' + constants_1.ACCESS_TOKEN
|
||||
};
|
||||
var pullRequestNumber = req.number;
|
||||
github_1.getPullRequest(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, pullRequestNumber, function (pullRequest) {
|
||||
var linkedItemsNumbers = getLinkedItemsNumbersInPullRequest(constants_1.BOT_USERNAME, pullRequest);
|
||||
github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.REPO_OWNER, constants_1.REPO_NAME, linkedItemsNumbers, function (results) {
|
||||
github_1.getPullRequest(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, pullRequestNumber, function (pullRequest) {
|
||||
var linkedItemsNumbers = getLinkedItemsNumbersInPullRequest(constants_1.BOT_LOGIN, pullRequest);
|
||||
github_1.getIssueOrPullRequestLinks(githubApiHeaders, constants_1.TARGET_REPO_OWNER, constants_1.TARGET_REPO_NAME, linkedItemsNumbers, function (results) {
|
||||
var unclosedIssuesNumber = results
|
||||
.filter(function (r) { return r.__typename === 'Issue' && r.closed === false; })
|
||||
.map(function (r) { return r.__typename === 'Issue' ? r.number : null; })
|
||||
|
|
|
@ -2,7 +2,7 @@ import { distinct } from '../shared/utils';
|
|||
import { completeFunction, searchLinkedItemsNumbersInComment } from '../shared/functions';
|
||||
import { PullRequestNode } from '../shared/models';
|
||||
import { getPullRequest, getIssueOrPullRequestLinks, commentGitHubIssue } from '../shared/github';
|
||||
import { ACCESS_TOKEN, REPO_OWNER, REPO_NAME, BOT_USERNAME, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
import { ACCESS_TOKEN, TARGET_REPO_OWNER, TARGET_REPO_NAME, BOT_LOGIN, ACTIVATE_MUTATION } from '../shared/constants';
|
||||
|
||||
module.exports = (context, req) => {
|
||||
if (req.action !== 'closed' || !req.pull_request.merged) {
|
||||
|
@ -20,17 +20,17 @@ module.exports = (context, req) => {
|
|||
|
||||
getPullRequest(
|
||||
githubApiHeaders,
|
||||
REPO_OWNER,
|
||||
REPO_NAME,
|
||||
TARGET_REPO_OWNER,
|
||||
TARGET_REPO_NAME,
|
||||
pullRequestNumber,
|
||||
(pullRequest) => {
|
||||
// get linked items (can be issue or PR)
|
||||
const linkedItemsNumbers = getLinkedItemsNumbersInPullRequest(
|
||||
BOT_USERNAME,
|
||||
BOT_LOGIN,
|
||||
pullRequest
|
||||
);
|
||||
|
||||
getIssueOrPullRequestLinks(githubApiHeaders, REPO_OWNER, REPO_NAME, linkedItemsNumbers, (results) => {
|
||||
getIssueOrPullRequestLinks(githubApiHeaders, TARGET_REPO_OWNER, TARGET_REPO_NAME, linkedItemsNumbers, (results) => {
|
||||
const unclosedIssuesNumber = results
|
||||
.filter(r => r.__typename === 'Issue' && r.closed === false)
|
||||
.map(r => r.__typename === 'Issue' ? r.number : null)
|
||||
|
|
Загрузка…
Ссылка в новой задаче