-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2-dump-glog.ts
55 lines (46 loc) · 1.44 KB
/
2-dump-glog.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import gitlog from "npm:gitlog";
import { resolve } from "@std/path";
import { ensureDir } from "jsr:@std/fs";
for await (const org of Deno.readDir("repos")) {
if (!org.isDirectory) continue;
for await (const repo of Deno.readDir(resolve("repos", org.name))) {
if (!org.isDirectory) continue;
console.info("Processing repository", repo.name);
const path = resolve("repos", org.name, repo.name);
const glog = await gitlog({
repo: path,
number: 1_000_000, // as many as we can
fields: [
// "abbrevHash",
"hash",
// "subject",
// "authorName",
"authorDate",
"authorEmail",
],
all: true,
});
type AugmentedGlog = ((typeof glog)[number] & { contributions: number })[];
for (const commit of glog) {
const contributions = await new Deno.Command("git", {
args: ["show", "--stat", commit.hash],
cwd: path,
})
.output()
.then(({ stdout }) => {
const text = new TextDecoder().decode(stdout);
const result = /(\d+) insertion/.exec(text);
if (!result) {
return 0;
}
return parseInt(result[1]);
});
(commit as AugmentedGlog[number]).contributions = contributions;
}
await ensureDir(resolve("glogs", org.name));
await Deno.writeTextFile(
resolve("glogs", org.name, repo.name + ".json"),
JSON.stringify(glog, null, 2)
);
}
}