mirror of
https://github.com/ghndrx/docker-test-image.git
synced 2026-02-10 14:55:14 +00:00
s
This commit is contained in:
@@ -1,24 +1,27 @@
|
|||||||
const commitInfoElement = document.getElementById('commit-info');
|
window.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
const repository = 'ghndrx/docker-test-image'; // Replace with your desired repository
|
||||||
fetch('https://api.github.com/repos/ghndrx/docker-test-image/commits')
|
|
||||||
.then(response => response.json())
|
try {
|
||||||
.then(data => {
|
const response = await fetch(`https://api.github.com/repos/${repository}/commits`);
|
||||||
if (data.length > 0) {
|
const commits = await response.json();
|
||||||
const latestCommit = data[0];
|
|
||||||
const commitMessage = latestCommit.commit.message;
|
const commitList = document.getElementById('commit-list');
|
||||||
const commitAuthor = latestCommit.commit.author.name;
|
|
||||||
const commitDate = new Date(latestCommit.commit.author.date).toLocaleString();
|
if (commits.length > 0) {
|
||||||
|
commits.forEach(commit => {
|
||||||
commitInfoElement.innerHTML = `
|
const commitElement = document.createElement('div');
|
||||||
<p><strong>Message:</strong> ${commitMessage}</p>
|
commitElement.classList.add('commit');
|
||||||
<p><strong>Author:</strong> ${commitAuthor}</p>
|
commitElement.innerHTML = `
|
||||||
<p><strong>Date:</strong> ${commitDate}</p>
|
<p><strong>${commit.commit.author.name}</strong></p>
|
||||||
`;
|
<p>${commit.commit.message}</p>
|
||||||
} else {
|
`;
|
||||||
commitInfoElement.innerHTML = '<p>No commits found.</p>';
|
commitList.appendChild(commitElement);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
commitList.innerHTML = '<p>No commits found.</p>';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching commits:', error);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
commitInfoElement.innerHTML = '<p>Error loading commit information.</p>';
|
|
||||||
console.error(error);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Reference in New Issue
Block a user