-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
80 lines (71 loc) · 1.8 KB
/
Copy pathindex.js
File metadata and controls
80 lines (71 loc) · 1.8 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import jsonfile from "jsonfile";
import moment from "moment";
import { simpleGit } from "simple-git";
import random from "random";
const path = "./data.json";
const markCommit = (x, y) => {
const date = moment()
.subtract(1, "y")
.add(1, "d")
.add(x, "w")
.add(y, "d")
.format();
const data = {
date: date,
};
jsonfile.writeFile(path, data, () => {
simpleGit().add([path]).commit(date, { "--date": date }).push();
});
};
// const makeCommits = (n) => {
// if (n === 0) return simpleGit().push();
// const x = random.int(0, 54);
// const y = random.int(0, 6);
// const date = moment()
// .subtract(1, "y")
// .add(1, "d")
// .add(x, "w")
// .add(y, "d")
// .format();
// const data = {
// date: date,
// };
// console.log(date);
// jsonfile.writeFile(path, data, () => {
// simpleGit()
// .add([path])
// .commit(
// date,
// {
// "--date": date,
// },
// () => makeCommits(--n)
// );
// // .commit(date, { "--date": date }, makeCommits.bind(this, --n));
// });
// };
const makeCommits = (n) => {
if (n === 0) return simpleGit().push();
const x = random.int(0, 54);
const y = random.int(0, 6);
const date = moment()
.subtract(1, "y")
.add(1, "d")
.add(x, "w")
.add(y, "d")
.format("YYYY-MM-DDTHH:mm:ss");
const data = { date: date };
console.log("Writing data:", data);
console.log("Making commit for date:", date);
jsonfile.writeFile(path, data, (err) => {
if (err) {
console.error(err);
return;
}
simpleGit()
.add([path])
.commit(date, { "--date": date }, () => makeCommits(--n));
});
};
console.log("Starting commits")
makeCommits(100)