From 8babd2bfedc5ac2bd7b5001b3a3f6164ce7a520e Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:05:36 +0000 Subject: [PATCH 1/6] feat: no backlinks --- helpers/github.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/helpers/github.ts b/helpers/github.ts index 42d76e68..bad4811e 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -77,6 +77,11 @@ export async function getAllIssues(ownerName: string, repoName: string) { // remove PRs from the project issues issues = issues.filter((issue) => !issue.pull_request); + issues = issues.map((issue) => { + issue.html_url = issue.html_url.replace("https://github.com", "https://www.github.com"); + return issue; + }); + return issues; } From f851c767f2a6409975b6d3bcd9510d62e1a2390c Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:21:03 +0000 Subject: [PATCH 2/6] fix: auth through octo --- helpers/github.ts | 16 ++++++++++++++++ index.ts | 10 ++++++++-- opt.json | 5 ++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/helpers/github.ts b/helpers/github.ts index bad4811e..59868cd7 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -62,6 +62,22 @@ export async function forceCloseMissingIssues(devpoolIssues: GitHubIssue[], proj } } +/** + * Stops forks from spamming real Ubiquity issues with links to their forks + * @returns true if the authenticated user is Ubiquity + */ +export async function isUbq() { + try { + const { + data: { login }, + } = await octokit.users.getAuthenticated(); + return login && login === "ubiquity" ? true : false; + } catch (e: unknown) { + console.warn(`Getting authenticated user failed: ${e}`); + return false; + } +} + /** * Returns all issues in a repo * @param ownerName owner name diff --git a/index.ts b/index.ts index e5c25b27..8506272f 100644 --- a/index.ts +++ b/index.ts @@ -12,6 +12,7 @@ import { getSocialMediaText, GitHubIssue, GitHubLabel, + isUbq, LABELS, octokit, } from "./helpers/github"; @@ -35,6 +36,8 @@ async function main() { // aggregate all project issues const allProjectIssues: GitHubIssue[] = []; + const isUbiquity = await isUbq(); + // for each project URL for (const projectUrl of projectUrls) { // get owner and repository names from project URL @@ -47,6 +50,8 @@ async function main() { for (const projectIssue of projectIssues) { // if issue exists in devpool const devpoolIssue = getIssueByLabel(devpoolIssues, `id: ${projectIssue.node_id}`); + const body = isUbiquity ? projectIssue.html_url : projectIssue.html_url.replace("https://github.com", "https://www.github.com"); + if (devpoolIssue) { // If project issue doesn't have the "Price" label (i.e. it has been removed) then close // the devpool issue if it is not already closed, no need to pollute devpool repo with draft issues @@ -90,7 +95,7 @@ async function main() { repo: DEVPOOL_REPO_NAME, issue_number: devpoolIssue.number, title: projectIssue.title, - body: projectIssue.html_url, + body, state: projectIssue.state as "open" | "closed", labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); @@ -104,12 +109,13 @@ async function main() { if (projectIssue.state === "closed") continue; // if issue doesn't have the "Price" label then skip it, no need to pollute repo with draft issues if (!(projectIssue.labels as GitHubLabel[]).some((label) => label.name.includes(LABELS.PRICE))) continue; + // create a new issue const createdIssue = await octokit.rest.issues.create({ owner: DEVPOOL_OWNER_NAME, repo: DEVPOOL_REPO_NAME, title: projectIssue.title, - body: projectIssue.html_url, + body, labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); console.log(`Created: ${createdIssue.data.html_url} (${projectIssue.html_url})`); diff --git a/opt.json b/opt.json index 648f519a..1a0df256 100644 --- a/opt.json +++ b/opt.json @@ -7,16 +7,15 @@ "ubiquity/devpool-directory", "ubiquity/card-issuance", "ubiquity/research", + "ubiquity/recruiting", "ubiquity/business-development", "ubiquity/ubiquibar", "ubiquity/ubiquibot", "ubiquity/ubiquibot-telegram", - "ubiquibot/configuration", - "ubiquibot/comment-incentives", "ubiquibot/production", "ubiquibot/sandbox", "ubiquibot/e2e-tests", "ubiquibot/staging" ] -} +} \ No newline at end of file From 334d1eb171f2f5ec0383b932b330d5e1d01afb75 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:23:42 +0000 Subject: [PATCH 3/6] fix: remove old replace method --- helpers/github.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/helpers/github.ts b/helpers/github.ts index 59868cd7..64b72782 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -93,11 +93,6 @@ export async function getAllIssues(ownerName: string, repoName: string) { // remove PRs from the project issues issues = issues.filter((issue) => !issue.pull_request); - issues = issues.map((issue) => { - issue.html_url = issue.html_url.replace("https://github.com", "https://www.github.com"); - return issue; - }); - return issues; } From 25c93c8c51968f306856ab05346bc8e563d483d2 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 16 Feb 2024 11:08:18 +0000 Subject: [PATCH 4/6] fix: small details --- helpers/github.ts | 6 +++--- index.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helpers/github.ts b/helpers/github.ts index 64b72782..38a8545b 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -66,12 +66,12 @@ export async function forceCloseMissingIssues(devpoolIssues: GitHubIssue[], proj * Stops forks from spamming real Ubiquity issues with links to their forks * @returns true if the authenticated user is Ubiquity */ -export async function isUbq() { +export async function checkIfForked() { try { const { - data: { login }, + data: { id }, } = await octokit.users.getAuthenticated(); - return login && login === "ubiquity" ? true : false; + return id && id === 76412717 ? true : false; } catch (e: unknown) { console.warn(`Getting authenticated user failed: ${e}`); return false; diff --git a/index.ts b/index.ts index 8506272f..dce24c84 100644 --- a/index.ts +++ b/index.ts @@ -12,7 +12,7 @@ import { getSocialMediaText, GitHubIssue, GitHubLabel, - isUbq, + checkIfForked, LABELS, octokit, } from "./helpers/github"; @@ -36,7 +36,7 @@ async function main() { // aggregate all project issues const allProjectIssues: GitHubIssue[] = []; - const isUbiquity = await isUbq(); + const isFork = await checkIfForked(); // for each project URL for (const projectUrl of projectUrls) { @@ -50,7 +50,7 @@ async function main() { for (const projectIssue of projectIssues) { // if issue exists in devpool const devpoolIssue = getIssueByLabel(devpoolIssues, `id: ${projectIssue.node_id}`); - const body = isUbiquity ? projectIssue.html_url : projectIssue.html_url.replace("https://github.com", "https://www.github.com"); + const body = isFork ? projectIssue.html_url : projectIssue.html_url.replace("https://github.com", "https://www.github.com"); if (devpoolIssue) { // If project issue doesn't have the "Price" label (i.e. it has been removed) then close From 598c6b6aa91b25049be81db616c67d68c6c7536e Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 16 Feb 2024 20:11:10 +0000 Subject: [PATCH 5/6] fix: isfork fix --- helpers/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpers/github.ts b/helpers/github.ts index 38a8545b..a154d14d 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -71,7 +71,7 @@ export async function checkIfForked() { const { data: { id }, } = await octokit.users.getAuthenticated(); - return id && id === 76412717 ? true : false; + return id && id === 76412717 ? false : true; } catch (e: unknown) { console.warn(`Getting authenticated user failed: ${e}`); return false; From 7af7742d79938e910ed6b4b6f5d89949aab96c03 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:05:15 +0000 Subject: [PATCH 6/6] fix: yes means no --- helpers/github.ts | 2 +- index.ts | 2 +- yarn.lock | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/github.ts b/helpers/github.ts index a154d14d..e4154aa0 100644 --- a/helpers/github.ts +++ b/helpers/github.ts @@ -71,7 +71,7 @@ export async function checkIfForked() { const { data: { id }, } = await octokit.users.getAuthenticated(); - return id && id === 76412717 ? false : true; + return id !== 76412717; } catch (e: unknown) { console.warn(`Getting authenticated user failed: ${e}`); return false; diff --git a/index.ts b/index.ts index dce24c84..09c92646 100644 --- a/index.ts +++ b/index.ts @@ -50,7 +50,7 @@ async function main() { for (const projectIssue of projectIssues) { // if issue exists in devpool const devpoolIssue = getIssueByLabel(devpoolIssues, `id: ${projectIssue.node_id}`); - const body = isFork ? projectIssue.html_url : projectIssue.html_url.replace("https://github.com", "https://www.github.com"); + const body = isFork ? projectIssue.html_url.replace("https://github.com", "https://www.github.com") : projectIssue.html_url; if (devpoolIssue) { // If project issue doesn't have the "Price" label (i.e. it has been removed) then close diff --git a/yarn.lock b/yarn.lock index b3a7aa81..9ca2add1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1057,7 +1057,7 @@ resolved "https://registry.yarnpkg.com/@mswjs/cookies/-/cookies-1.1.0.tgz#1528eb43630caf83a1d75d5332b30e75e9bb1b5b" integrity sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw== -"@mswjs/data@^0.16.1": +"@mswjs/data@0.16.1": version "0.16.1" resolved "https://registry.yarnpkg.com/@mswjs/data/-/data-0.16.1.tgz#ee41b95b8f2e954a07b0eb54154592a2459064d1" integrity sha512-VhJvL/VmgAuU9/tDOcKcxHfNd+8nxYntZnrkaQEQPvZZnFwQQR9bzI1FTRROGxCHVoyfv9v84AEkl/7CIw4FAg==