Skip to content

Commit

Permalink
add gh commit list
Browse files Browse the repository at this point in the history
  • Loading branch information
partouf committed Dec 6, 2024
1 parent 9e8b6fc commit c5d45c9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cpp-build-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ class CppBuildResultsView {
const clang_semvers = succeeded_compilers.filter(result => result.compiler === 'clang').map(result => semver.parse(result.compiler_semver)).filter(Boolean);
const min_clang_ver = _.first(semver.sort(clang_semvers));

const repo_owner = "fmtlib";
const repo_name = "fmt";

return await this.results_view({
lib: {
commit_url: `https://github.com/fmtlib/fmt/commit/${commit_hash}`,
commit_url: `https://github.com/${repo_owner}/${repo_name}/commit/${commit_hash}`,
commit_hash: commit_hash,
name: `${library} ${library_version}`,
repo_owner,
repo_name,
name: `${library}`,
version: `${library_version}`
},
view: {
show_all_compilers
Expand Down
34 changes: 34 additions & 0 deletions html/gh-commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Octokit, App } from "https://esm.sh/octokit";

async function list_last_10(owner, repo, lib_name, lib_version) {
const octokit = new Octokit({
// auth: 'YOUR-TOKEN'
});

const list = await octokit.request('GET /repos/{owner}/{repo}/commits', {
owner: owner,
repo: repo,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
});

const morediv = $(".more-commits");
for (const item of list.data) {
const shorthash = item.sha.substring(0, 8);

const elem = $(`<a>${shorthash}</a>`);
elem.attr("href", `/cpp_library_build_results/${lib_name}/${lib_version}/${shorthash}`);

const li = $("<li />");
li.append(elem);

const desc = $("<span />");
desc.html(" " + item.commit.author.date);
li.append(desc);

morediv.append(li);
}
}

list_last_10(window.repo_owner, window.repo_name, window.lib_name, window.lib_version);
13 changes: 13 additions & 0 deletions views/library_build_results.pug
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,22 @@ block prepend content
a(href=compiler.package_url target='_blank')
i(class='fa-solid fa-paperclip')

div
h3 more commits

ul(class="more-commits")

script
| if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
| document.querySelectorAll('.table-striped').forEach(table => {
| table.classList.add('table-dark');
| });
| }
script
| window.repo_owner = "fmtlib";
| window.repo_name = "fmt"
| window.lib_name = "#{lib.name}";
| window.lib_version = "#{lib.version}";
script(src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous")

script(type="module" src="/gh-commits.js")

0 comments on commit c5d45c9

Please sign in to comment.