-
Notifications
You must be signed in to change notification settings - Fork 26
/
scratch.js
65 lines (59 loc) · 1.48 KB
/
scratch.js
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
const git = require("isomorphic-git")
const path = require("path")
const fs = require("fs")
// const repo = {
// dir: "/tmp/isomorphic-git",
// fs
// }
// const main = async () => {
// console.log("start")
// await git.clone({
// ...repo,
// url:
// "https://cors-buster-tbgktfqyku.now.sh/github.com/isomorphic-git/isomorphic-git",
// singleBranch: true,
// depth: 1
// })
// let pushResponse = await git.push({
// ...repo,
// remote: "origin",
// ref: "master",
// authUsername: process.env.GITHUB_TOKEN,
// authPassword: process.env.GITHUB_TOKEN
// })
// console.log(pushResponse)
// console.log("done")
// }
const repo = {
dir: "/tmp/igit-" + Date.now(),
fs
}
const main = async () => {
fs.mkdirSync(repo.dir)
await git.init(repo)
fs.writeFileSync(repo.dir + "/a", "a")
await git.add({ ...repo, filepath: "a" })
await git.commit({
...repo,
author: { name: "dummy", email: "dummy" },
message: "Add a"
})
console.log("a stasus", await git.status({ ...repo, filepath: "a" }))
fs.mkdirSync(repo.dir + "/src")
fs.writeFileSync(repo.dir + "/src/b", "b")
await git.add({ ...repo, filepath: "src/b" })
console.log(
"src/b stasus before",
await git.status({ ...repo, filepath: "src/b" })
)
await git.commit({
...repo,
author: { name: "dummy", email: "dummy" },
message: "Add b"
})
console.log(
"src/b stasus after",
await git.status({ ...repo, filepath: "src/b" })
)
}
main()