FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/examples/create-new-repo.js at v0.11.2 · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
23
(23)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
examples
/
create-new-repo.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (46 loc) · 1.34 KB
Breadcrumbs
nodegit
/
examples
/
create-new-repo.js
Copy path
File metadata and controls
50 lines (46 loc) · 1.34 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
var
nodegit
=
require
(
"../"
)
;
var
path
=
require
(
"path"
)
;
var
promisify
=
require
(
"promisify-node"
)
;
var
fse
=
promisify
(
require
(
"fs-extra"
)
)
;
var
fileName
=
"newfile.txt"
;
var
fileContent
=
"hello world"
;
var
repoDir
=
"../../newRepo"
;
fse
.
ensureDir
=
promisify
(
fse
.
ensureDir
)
;
var
repository
;
var
index
;
fse
.
ensureDir
(
path
.
resolve
(
__dirname
,
repoDir
)
)
.
then
(
function
(
)
{
return
nodegit
.
Repository
.
init
(
path
.
resolve
(
__dirname
,
repoDir
)
,
0
)
;
}
)
.
then
(
function
(
repo
)
{
repository
=
repo
;
return
fse
.
writeFile
(
path
.
join
(
repository
.
workdir
(
)
,
fileName
)
,
fileContent
)
;
}
)
.
then
(
function
(
)
{
return
repository
.
openIndex
(
)
;
}
)
.
then
(
function
(
idx
)
{
index
=
idx
;
return
index
.
read
(
1
)
;
}
)
.
then
(
function
(
)
{
return
index
.
addByPath
(
fileName
)
;
}
)
.
then
(
function
(
)
{
return
index
.
write
(
)
;
}
)
.
then
(
function
(
)
{
return
index
.
writeTree
(
)
;
}
)
.
then
(
function
(
oid
)
{
var
author
=
nodegit
.
Signature
.
create
(
"Scott Chacon"
,
"schacon@gmail.com"
,
123456789
,
60
)
;
var
committer
=
nodegit
.
Signature
.
create
(
"Scott A Chacon"
,
"scott@github.com"
,
987654321
,
90
)
;
// Since we're creating an inital commit, it has no parents. Note that unlike
// normal we don't get the head either, because there isn't one yet.
return
repository
.
createCommit
(
"HEAD"
,
author
,
committer
,
"message"
,
oid
,
[
]
)
;
}
)
.
done
(
function
(
commitId
)
{
console
.
log
(
"New Commit: "
,
commitId
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL