FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/example/read-file.js at emscripten · elfscript/nodegit · GitHub
elfscript
nodegit
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
example
/
read-file.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (21 loc) · 898 Bytes
Breadcrumbs
nodegit
/
example
/
read-file.js
Copy path
File metadata and controls
27 lines (21 loc) · 898 Bytes
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
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
(
'59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5'
,
function
(
error
,
commit
)
{
if
(
error
)
throw
error
;
commit
.
getEntry
(
'README.md'
,
function
(
error
,
entry
)
{
if
(
error
)
throw
error
;
entry
.
getBlob
(
function
(
error
,
blob
)
{
if
(
error
)
throw
error
;
console
.
log
(
entry
.
name
(
)
,
entry
.
sha
(
)
,
blob
.
size
(
)
+
'b'
)
;
console
.
log
(
'========================================================\n\n'
)
;
var
firstTenLines
=
blob
.
toString
(
)
.
split
(
'\n'
)
.
slice
(
0
,
10
)
.
join
(
'\n'
)
;
console
.
log
(
firstTenLines
)
;
console
.
log
(
'...'
)
;
}
)
;
}
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL