Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created February 8, 2021 17:53
Show Gist options
  • Save enjalot/688b9026ed865a790bfb390fca9c9b67 to your computer and use it in GitHub Desktop.
Save enjalot/688b9026ed865a790bfb390fca9c9b67 to your computer and use it in GitHub Desktop.
a set of scripts to pull the git history from the d3 git repositories
let fs = require("fs")
let {exec} = require("child_process")
// read package.json
let packageText = fs.readFileSync("./d3/package.json").toString()
let packageJson = JSON.parse(packageText)
// loop through dependencies
let depends = Object.keys(packageJson.dependencies)
console.log("dependencies", depends)
// clone each repo
depends.forEach(repo => {
let command = `git clone https://github.com/d3/${repo}.git`
exec(command, (error, stdout, stderr) => {
// TODO: handle errors.
})
})
let fs = require("fs")
let {exec} = require("child_process")
// read package.json
let packageText = fs.readFileSync("./d3/package.json").toString()
let packageJson = JSON.parse(packageText)
// loop through dependencies
let depends = Object.keys(packageJson.dependencies)
console.log("dependencies", depends)
// clone each repo
//let repo = "d3"
let commits = []
depends.forEach(repo => {
let txt = fs.readFileSync(`data/${repo}.001.json`).toString()
let json = JSON.parse(txt)
json.forEach(c => {
c.repo = repo
commits.push(c)
})
})
fs.writeFileSync(`data/combined.001.json`, JSON.stringify(commits))
let fs = require("fs")
let {exec} = require("child_process")
// read package.json
let packageText = fs.readFileSync("./d3/package.json").toString()
let packageJson = JSON.parse(packageText)
// loop through dependencies
let depends = Object.keys(packageJson.dependencies)
console.log("dependencies", depends)
// clone each repo
//let repo = "d3"
depends.forEach(repo => {
let txt = fs.readFileSync(`data/${repo}.001.🔪sv`).toString()
lines = txt.split("☕")
commits = lines.slice(1).map(line => {
let l = line.split("🔪");
return {
hash: l[0],
date: l[1],
author: l[2],
subject: l[3],
body: l[4]
};
})
fs.writeFileSync(`data/${repo}.001.json`, JSON.stringify(commits))
})
let fs = require("fs")
let {exec} = require("child_process")
// read package.json
let packageText = fs.readFileSync("./d3/package.json").toString()
let packageJson = JSON.parse(packageText)
// loop through dependencies
let depends = Object.keys(packageJson.dependencies)
console.log("dependencies", depends)
// clone each repo
depends.forEach(repo => {
let command = `cd ${repo}; git log --pretty=format:"☕%h🔪%ad🔪%an🔪%s🔪%b" --date="iso" --no-merges --compact-summary > ../data/${repo}.001.🔪sv`
exec(command, (error, stdout, stderr) => {
// TODO: handle errors.
})
})
@curran
Copy link

curran commented Apr 23, 2021

Here's an updated version that includes commits from the original d3 repo: https://gist.github.com/curran/18287ef2c4b64ffba32000aad47c292b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment