1- var nodegit = require ( '../' ) ;
2- var path = require ( 'path' ) ;
3- var Promise = require ( 'nodegit-promise' ) ;
4- var promisify = require ( 'promisify-node' ) ;
5- var fse = promisify ( require ( 'fs-extra' ) ) ;
6- var fileName = 'newfile.txt' ;
7- var fileContent = 'hello world' ;
8- var directoryName = 'salad/toast/strangerinastrangeland/theresnowaythisexists' ;
1+ var nodegit = require ( "../" ) ;
2+ var path = require ( "path" ) ;
3+ var promisify = require ( "promisify-node" ) ;
4+ var fse = promisify ( require ( "fs-extra" ) ) ;
5+ var fileName = "newfile.txt" ;
6+ var fileContent = "hello world" ;
7+ var directoryName = "salad/toast/strangerinastrangeland/theresnowaythisexists" ;
98// ensureDir is an alias to mkdirp, which has the callback with a weird name
10- // and in the 3rd position of 4 (the 4th being used for recursion). We have to force
11- // promisify it, because promisify-node won't detect it on its own and assumes sync
9+ // and in the 3rd position of 4 (the 4th being used for recursion). We have to
10+ // force promisify it, because promisify-node won't detect it on its
11+ // own and assumes sync
1212fse . ensureDir = promisify ( fse . ensureDir ) ;
1313
1414/**
15- * This example creates a certain file `newfile.txt`, adds it to the git index and
16- * commits it to head. Similar to a `git add newfile.txt` followed by a `git commit`
15+ * This example creates a certain file `newfile.txt`, adds it to the git
16+ * index and commits it to head. Similar to a `git add newfile.txt`
17+ * followed by a `git commit`
1718**/
1819
1920var repo ;
2021var index ;
2122var oid ;
22- var parent ;
2323
24- nodegit . Repository . open ( path . resolve ( __dirname , ' ../.git' ) )
24+ nodegit . Repository . open ( path . resolve ( __dirname , " ../.git" ) )
2525. then ( function ( repoResult ) {
2626 repo = repoResult ;
2727 return fse . ensureDir ( path . join ( repo . workdir ( ) , directoryName ) ) ;
2828} ) . then ( function ( ) {
2929 return fse . writeFile ( path . join ( repo . workdir ( ) , fileName ) , fileContent ) ;
3030} )
3131. then ( function ( ) {
32- return fse . writeFile ( path . join ( repo . workdir ( ) , directoryName , fileName ) , fileContent ) ;
32+ return fse . writeFile (
33+ path . join ( repo . workdir ( ) , directoryName , fileName ) ,
34+ fileContent
35+ ) ;
3336} )
3437. then ( function ( ) {
3538 return repo . openIndex ( ) ;
@@ -52,17 +55,19 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
5255} )
5356. then ( function ( oidResult ) {
5457 oid = oidResult ;
55- return nodegit . Reference . nameToId ( repo , ' HEAD' ) ;
58+ return nodegit . Reference . nameToId ( repo , " HEAD" ) ;
5659} )
5760. then ( function ( head ) {
5861 return repo . getCommit ( head ) ;
5962} )
6063. then ( function ( parent ) {
61- var author = nodegit . Signature . create ( "Scott Chacon" , "schacon@gmail.com" , 123456789 , 60 ) ;
62- var committer = nodegit . Signature . create ( "Scott A Chacon" , "scott@github.com" , 987654321 , 90 ) ;
64+ var author = nodegit . Signature . create ( "Scott Chacon" ,
65+ "schacon@gmail.com" , 123456789 , 60 ) ;
66+ var committer = nodegit . Signature . create ( "Scott A Chacon" ,
67+ "scott@github.com" , 987654321 , 90 ) ;
6368
64- return repo . createCommit ( ' HEAD' , author , committer , ' message' , oid , [ parent ] ) ;
69+ return repo . createCommit ( " HEAD" , author , committer , " message" , oid , [ parent ] ) ;
6570} )
6671. done ( function ( commitId ) {
67- console . log ( ' New Commit: ' , commitId ) ;
72+ console . log ( " New Commit: " , commitId ) ;
6873} ) ;
0 commit comments