From c5d45c94e985f6ee572d492e6f6f731b98b022eb Mon Sep 17 00:00:00 2001 From: Partouf Date: Fri, 6 Dec 2024 19:39:50 +0100 Subject: [PATCH] add gh commit list --- cpp-build-results.js | 10 ++++++++-- html/gh-commits.js | 34 +++++++++++++++++++++++++++++++++ views/library_build_results.pug | 13 +++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 html/gh-commits.js diff --git a/cpp-build-results.js b/cpp-build-results.js index bb30f24..5587fdb 100644 --- a/cpp-build-results.js +++ b/cpp-build-results.js @@ -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 diff --git a/html/gh-commits.js b/html/gh-commits.js new file mode 100644 index 0000000..b5ee63e --- /dev/null +++ b/html/gh-commits.js @@ -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 = $(`${shorthash}`); + elem.attr("href", `/cpp_library_build_results/${lib_name}/${lib_version}/${shorthash}`); + + const li = $("
  • "); + li.append(elem); + + const desc = $(""); + 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); diff --git a/views/library_build_results.pug b/views/library_build_results.pug index e24f0f1..373f5f9 100644 --- a/views/library_build_results.pug +++ b/views/library_build_results.pug @@ -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")