Skip to content

Commit d5eb3a9

Browse files
committed
fix: 🐛 handling of apply license template with custom licenses
1 parent 161c083 commit d5eb3a9

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

bot/compliance-checks/license/index.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ const CODEFAIR_DOMAIN = process.env.CODEFAIR_APP_DOMAIN;
1717
* @returns {boolean} - Returns true if a license is found in the repository, false otherwise
1818
*/
1919
export async function checkForLicense(context, owner, repoName) {
20-
const licenseFilesTypes = [
21-
"LICENSE",
22-
"LICENSE.md",
23-
"LICENSE.txt",
24-
];
20+
const licenseFilesTypes = ["LICENSE", "LICENSE.md", "LICENSE.txt"];
2521

2622
for (const filePath of licenseFilesTypes) {
2723
const file = await checkForFile(context, owner, repoName, filePath);
@@ -137,8 +133,8 @@ export async function updateLicenseDatabase(repository, license) {
137133
license_content: licenseContent,
138134
custom_license_title:
139135
licenseId === "Custom"
140-
? licenseId
141-
: existingLicense.custom_license_title,
136+
? existingLicense.custom_license_title
137+
: "",
142138
},
143139
where: { repository_id: repository.id },
144140
});
@@ -153,7 +149,7 @@ export async function updateLicenseDatabase(repository, license) {
153149
license_status: licenseContentEmpty ? "invalid" : "valid",
154150
license_id: licenseId,
155151
license_content: licenseContent,
156-
custom_license_title: licenseId === "Custom" ? licenseId : "",
152+
custom_license_title: "",
157153
repository: {
158154
connect: {
159155
id: repository.id,
@@ -194,17 +190,9 @@ export async function applyLicenseTemplate(
194190

195191
if (subjects.license.status && licenseId && licenseId !== "Custom") {
196192
baseTemplate += `## LICENSE ✔️\n\nA \`LICENSE\` file is found at the root level of the repository.\n\n${licenseBadge}\n\n`;
197-
} else if (
198-
subjects.license.status &&
199-
licenseId === "Custom" &&
200-
customTitle === ""
201-
) {
193+
} else if (subjects.license.status && licenseId === "Custom" && !customTitle) {
202194
baseTemplate += `## LICENSE ❗\n\nA custom \`LICENSE\` file has been found at the root level of this repository.\n > [!NOTE]\n> While using a custom license is normally acceptable for Zenodo, please note that Zenodo's API currently cannot handle custom licenses. If you plan to make a FAIR release, you will be required to select a license from the SPDX license list to ensure proper archival and compliance.\n\nClick the "Edit license" button below to provide a license title or to select a new license.\n\n${licenseBadge}\n\n`;
203-
} else if (
204-
subjects.license.status &&
205-
licenseId === "Custom" &&
206-
customTitle !== ""
207-
) {
195+
} else if (subjects.license.status && licenseId === "Custom" && customTitle) {
208196
baseTemplate += `## LICENSE ✔️\n\nA custom \`LICENSE\` file titled as **${customTitle}**, has been found at the root level of this repository. If you would like to update the title or change license, click the "Edit license" button below.\n\n${licenseBadge}\n\n`;
209197
} else {
210198
baseTemplate += `## LICENSE ❌\n\nTo make your software reusable, a \`LICENSE\` file is expected at the root level of your repository.\nIf you would like Codefair to add a license file, click the "Add license" button below to go to our interface for selecting and adding a license. You can also add a license file yourself, and Codefair will update the dashboard when it detects it on the main branch.\n\n${licenseBadge}\n\n`;

0 commit comments

Comments
 (0)