Published
Edited
Feb 6, 2021
2 stars
Insert cell
Insert cell
Insert cell
// octokit = new Octokit({auth: github_token});
octokit = new Octokit();
Insert cell
Insert cell
github_token = null // write here your GitHub token
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// page = 1
Insert cell
// per_page = 10
Insert cell
// commits = (await fetch(`https://api.github.com/repos/${owner}/${repo}/commits?page=${page}&per_page=${per_page}`)).json()
Insert cell
dot_string = {
let result = "\n";
for(var i = 0; i < commits.length; i++){
// if (i == 0) {
commits[i].parents.forEach(d => result = result +
`"${d.sha}" [label = "${d.sha.substring(0,4)}"] \n`);
// }
let sha = commits[i].sha;
let sha_short = sha.substring(0,4);
result = result + `"${sha}"`
+ ` [label = "${sha_short}"]`
+ "\n";
}
for(var i = 0; i < commits.length; i++){
let sha = commits[i].sha;
let sha_short = sha.substring(0,4);
commits[i].parents.forEach(d => result = result +
`"${d.sha}" -> "${sha}" \n`);
}
return result;
}
Insert cell
// next_and_last_page = (await fetch(`https://api.github.com/repos/${owner}/${repo}/commits?page=${page}&per_page=${per_page}`)).headers.get('link')
Insert cell
// last_page = {
// const regexp = /\?page=(\d+)/g;
// const array = [...next_and_last_page.matchAll(regexp)];
// return parseInt(array[1][1]);
// }
Insert cell
d3 = require("d3")
Insert cell
dot = require("@observablehq/graphviz@0.2")
Insert cell
Octokit = (await import('https://cdn.skypack.dev/@octokit/rest@16.28.3')).default
Insert cell
// octokit.repos.listCommits({
// "owner": owner,
// "repo": repo,
// "per_page": per_page}
// );
Insert cell
// {
// // let result;
// let result = octokit
// .paginate(`GET /repos/${owner}/${repo}/commits`, {
// "owner": owner,
// "repo": repo,
// })
// // .then(d => console.log(d));
// // .then(d => d);
// return result;
// }
Insert cell
commits = octokit
.paginate(`GET /repos/${owner}/${repo}/commits`, {
"owner": owner,
"repo": repo,
// "since": "2021-01-01T00:00:00Z"
"since": date1
})
Insert cell
import {text} from "@jashkenas/inputs"
Insert cell
import {date} from "@jashkenas/inputs"
Insert cell
await octokit.request('GET /rate_limit')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more