diff --git a/helpers/email_templates/success.html b/helpers/email_templates/success.html
index 9e5b2d5..927a9a0 100644
--- a/helpers/email_templates/success.html
+++ b/helpers/email_templates/success.html
@@ -75,9 +75,8 @@
Congratulations on Your DEI Badge!
We are thrilled to inform you that your recent review submission of your
- Open Source Project has been recognized and rewarded an All In CHAOSS
- DEI
- {{badgeName}} badge.
+ Open Source Project has been recognized and rewarded a CHAOSS DEI
+ Project {{badgeName}} badge.
Once Again, congratulations on this well-deserved Badge!
@@ -98,14 +97,6 @@ Congratulations on Your DEI Badge!
{{htmlLink}}
- In the coming 3-4 days, we will share a supplemental report on your
- project's language inclusivity. This report will provide valuable
- insights into how inclusive your project's language is to diversw
- audiences. This report is only a supplement to your DEI Badge and has no
- impact on current or future badges. The report will only be sent to this
- email and can be used in any way that you see fit.
-
-
Thank you for your ongoing DEI efforts!
diff --git a/providers/github/APICalls.js b/providers/github/APICalls.js
index 0b58df5..476ed71 100644
--- a/providers/github/APICalls.js
+++ b/providers/github/APICalls.js
@@ -2,6 +2,7 @@ const { Octokit } = require("@octokit/rest");
const Repo = require("../../database/models/repo.model.js");
const bronzeBadge = require("../../badges/bronzeBadge.js");
const mailer = require("../../helpers/mailer.js");
+const axios = require("axios");
/**
* Calls the GitHub API to get the user info.
@@ -71,7 +72,7 @@ const getUserRepositories = async (octokit) => {
} catch (error) {
return {
repositories: null,
- errors: [error.message],
+ errors: "GitHub API returning no repository(ies).",
};
}
};
@@ -137,7 +138,6 @@ const getFileContentAndSHA = async (octokit, repositoryFullName, filePath) => {
};
}
};
-
/**
* Scans a list of repositories to try and apply for a badge
* @param {*} userId Id of the user
@@ -159,7 +159,6 @@ const scanRepositories = async (userId, name, email, repositoryIds) => {
console.error(info_errors);
continue;
}
-
const { file, errors: file_errors } = await getFileContentAndSHA(
octokit,
info.fullName,
@@ -176,6 +175,20 @@ const scanRepositories = async (userId, name, email, repositoryIds) => {
where: { githubRepoId: info.id, DEICommitSHA: file.sha },
});
+ // retrieve DEI template
+ const template_content = await axios.get(
+ "https://api.github.com/repos/badging/badging/contents/Template.DEI.md"
+ );
+ const template = Buffer.from(
+ template_content.data.content,
+ "base64"
+ ).toString();
+
+ console.log({
+ repo: file.content,
+ template_to_test: template,
+ });
+
if (file.content) {
if (existingRepo) {
// Compare the DEICommitSHA with the existing repo's DEICommitSHA
@@ -194,6 +207,11 @@ const scanRepositories = async (userId, name, email, repositoryIds) => {
// Handle case when DEI.md file is not changed
results.push(`${info.url} was already badged`);
}
+ } else if (file.content && file.content === template) {
+ // check if file content is copy/paste from template
+ results.push(
+ `Please provide DEI information specific to ${info.url} by editing the template`
+ );
} else {
// Repo not badged before, badge it
bronzeBadge(
diff --git a/providers/gitlab/APICalls.js b/providers/gitlab/APICalls.js
index 2b91ae8..c630e83 100644
--- a/providers/gitlab/APICalls.js
+++ b/providers/gitlab/APICalls.js
@@ -173,6 +173,20 @@ const scanRepositories = async (userId, name, email, repositoryIds) => {
where: { gitlabRepoId: info.id, DEICommitSHA: file.sha },
});
+ // retrieve DEI template
+ const template_content = await axios.get(
+ "https://api.github.com/repos/badging/badging/contents/Template.DEI.md"
+ );
+ const template = Buffer.from(
+ template_content.data.content,
+ "base64"
+ ).toString();
+
+ console.log({
+ repo: file.content,
+ template_to_test: template,
+ });
+
if (file.content) {
if (existingRepo) {
// Compare the DEICommitSHA with the existing repo's DEICommitSHA
@@ -191,6 +205,11 @@ const scanRepositories = async (userId, name, email, repositoryIds) => {
// Handle case when DEI.md file is not changed
results.push(`${info.url} was already badged`);
}
+ } else if (file.content && file.content === template) {
+ // check if file content is copy/paste from template
+ results.push(
+ `Please provide DEI information specific to ${info.url} by editing the template`
+ );
} else {
// Repo not badged before, badge it
bronzeBadge(
diff --git a/routes/index.js b/routes/index.js
index 190d33c..9338ac2 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -31,7 +31,6 @@ const reposToBadge = async (req, res) => {
const userId = req.body.userId;
const provider = req.body.provider;
const repositoryIds = selectedRepos.map((repo) => repo.id);
-
if (!provider) {
res.status(400).send("provider missing");
return;
@@ -55,22 +54,43 @@ const reposToBadge = async (req, res) => {
}
// Process the selected repos as needed
- if (provider === "github") {
- const results = await github_helpers.scanRepositories(
- user.id,
- user.name,
- user.email,
- repositoryIds
- );
- res.status(200).json({ results });
- } else if (provider === "gitlab") {
- const results = await gitlab_helpers.scanRepositories(
- user.id,
- user.name,
- user.email,
- repositoryIds
- );
- res.status(200).json({ results });
+ if (process.env.NODE_ENV === "development") {
+ if (provider === "github") {
+ const results = await github_helpers.scanRepositories(
+ user.id,
+ user.name,
+ user.email,
+ selectedRepos
+ );
+ res.status(200).json({ results });
+ } else if (provider === "gitlab") {
+ const results = await gitlab_helpers.scanRepositories(
+ user.id,
+ user.name,
+ user.email,
+ selectedRepos
+ );
+ res.status(200).json({ results });
+ }
+ } else if (process.env.NODE_ENV === "production") {
+ // process the selected repositories in production
+ if (provider === "github") {
+ const results = await github_helpers.scanRepositories(
+ user.id,
+ user.name,
+ user.email,
+ repositoryIds
+ );
+ res.status(200).json({ results });
+ } else if (provider === "gitlab") {
+ const results = await gitlab_helpers.scanRepositories(
+ user.id,
+ user.name,
+ user.email,
+ repositoryIds
+ );
+ res.status(200).json({ results });
+ }
} else {
res.status(400).send(`Unknown provider: ${provider}`);
}