Skip to content

Commit

Permalink
add co-authoring to changelog
Browse files Browse the repository at this point in the history
Signed-off-by: ClaytonTDM <[email protected]>
  • Loading branch information
ClaytonTDM committed Oct 9, 2024
1 parent be8c73b commit 4e5c522
Showing 1 changed file with 52 additions and 31 deletions.
83 changes: 52 additions & 31 deletions game/cl.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Changelog</title>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", () => {
const commitList = document.createElement("ul");
document.body.appendChild(commitList);
const apiUrl =
"https://api.github.com/repos/roblnet13/pvz/commits";
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Changelog</title>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", () => {
const commitList = document.createElement("ul");
document.body.appendChild(commitList);
const apiUrl =
"https://api.github.com/repos/roblnet13/pvz/commits";

fetch(apiUrl)
.then((response) => response.json())
.then((commits) => {
commits.forEach((commit) => {
const listItem = document.createElement("li");
const itemText = document.createElement("pre");
itemText.innerHTML = `<b>${commit.commit.author.name}</b>: `;
itemText.innerText += commit.commit.message;
commitList.appendChild(listItem);
listItem.appendChild(itemText);
});
})
.catch((error) => {
console.error("Error fetching commits:", error);
});
});
</script>
</body>
</html>
fetch(apiUrl)
.then((response) => response.json())
.then((commits) => {
commits.forEach((commit) => {
const listItem = document.createElement("li");
const itemText = document.createElement("pre");
const authorName = commit.commit.author.name;
const commitMessage = commit.commit.message;
const coAuthors = [];

// Extract co-authors if present
const coAuthorRegex = /Co-authored-by: ([^<]+) <[^>]+>/g;
let match;
while ((match = coAuthorRegex.exec(commitMessage)) !== null) {
coAuthors.push(match[1]);
}

let allAuthors;
if (coAuthors.length === 1) {
allAuthors = `${authorName} and ${coAuthors[0]}`;
} else if (coAuthors.length > 1) {
allAuthors = `${coAuthors.length + 1} people`;
} else {
allAuthors = authorName;
}

itemText.innerHTML = `<b>${allAuthors}</b>: `;
itemText.innerText += commitMessage.split("\n")[0];

commitList.appendChild(listItem);
listItem.appendChild(itemText);
});
})
.catch((error) => {
console.error("Error fetching commits:", error);
});
});
</script>
</body>
</html>

0 comments on commit 4e5c522

Please sign in to comment.