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

Add label on plugin repo user change #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const NEW_PLUGIN = "plugin added";
const REMOVE_PLUGIN = "plugin removed";
const PLUGIN_CHANGE = "plugin change";
const NON_AUTHOR_PLUGIN_CHANGE = "non-author plugin change";
const PLUGIN_REPO_CHANGED_USER = "plugin repo changed user";
const PACKAGE_CHANGE = "package change";
const DEPENDENCY_CHANGE = "dependency change";
const READY_TO_MERGE = "ready to merge";
Expand Down Expand Up @@ -65,6 +66,7 @@ export = (app: Probot) => {
let diffLines: string[] = [];
const prAuthor = (await github.issues.get(context.issue())).data.user!.login.toLowerCase();
let nonAuthorChange = false;
let pluginRepoChange = false;
await Promise.all(pluginFiles.map(async file => {
let pluginName = file.filename.replace("plugins/", "");
if (file.status == "removed") {
Expand Down Expand Up @@ -106,6 +108,9 @@ export = (app: Probot) => {
let oldPluginURL = extractURL(oldPlugin.repository);
changedPluginAuthors.add(sanitizeAuthor(oldPluginURL.user));
addPluginAuthors(oldPlugin.authors);
if (oldPluginURL.user != user) {
pluginRepoChange = true;
}
diffLines.push(`\`${pluginName}\`: [${oldPlugin.commit}...${newPlugin.commit}](https://github.com/${oldPluginURL.user}/${oldPluginURL.repo}/compare/${oldPlugin.commit}...${user}:${newPlugin.commit})`);
} else if (file.status == "added") {
diffLines.push(`New plugin \`${pluginName}\`: https://github.com/${user}/${repo}/tree/${newPlugin.commit}`);
Expand All @@ -130,6 +135,14 @@ export = (app: Probot) => {
await setHasLabel(false, NON_AUTHOR_PLUGIN_CHANGE);
}

if (pluginRepoChange)
{
difftext = "**Plugin repository has changed**\n\n" + difftext;
await setHasLabel(true, PLUGIN_REPO_CHANGED_USER);
} else {
await setHasLabel(false, PLUGIN_REPO_CHANGED_USER);
}

if (dependencyFiles.length > 0 || otherFiles.length > 0) {
difftext = "**Includes non-plugin changes**\n\n" + difftext;
}
Expand Down