FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/example/new-commit.js at master · papandreou/nodegit · GitHub
papandreou
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
example
/
new-commit.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
32 lines (24 loc) · 1.08 KB
Breadcrumbs
nodegit
/
example
/
new-commit.js
Copy path
File metadata and controls
executable file
·
32 lines (24 loc) · 1.08 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
var
git
=
require
(
'../'
)
,
path
=
require
(
'path'
)
;
// This example opens a certain file, `README.md`, at a particular commit,
// and prints the first 10 lines as well as some metadata.
git
.
Repo
.
open
(
path
.
resolve
(
__dirname
,
'../.git'
)
,
function
(
error
,
repo
)
{
if
(
error
)
throw
error
;
repo
.
getCommit
(
'eebd0ead15d62eaf0ba276da53af43bbc3ce43ab'
,
function
(
error
,
commit
)
{
if
(
error
)
throw
error
;
commit
.
getTree
(
function
(
error
,
tree
)
{
if
(
error
)
throw
error
;
var
builder
=
tree
.
builder
(
)
,
buffer
=
new
Buffer
(
"this is a file\n"
)
;
builder
.
insertBlob
(
"/lib/baz.txt"
,
buffer
,
false
)
builder
.
write
(
function
(
error
,
treeId
)
{
if
(
error
)
throw
error
;
var
author
=
git
.
Signature
.
create
(
"Scott Chacon"
,
"schacon@gmail.com"
,
123456789
,
60
)
;
var
committer
=
git
.
Signature
.
create
(
"Scott A Chacon"
,
"scott@github.com"
,
987654321
,
90
)
;
repo
.
createCommit
(
null
,
author
,
committer
,
"message"
,
treeId
,
[
commit
]
,
function
(
error
,
commitId
)
{
console
.
log
(
"New Commit:"
,
commitId
.
sha
(
)
)
;
}
)
;
}
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL