File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ var nodegit = require ( "../" ) ,
2
+ path = require ( "path" ) ;
3
+
4
+ // This code shows working directory changes similar to git status
5
+
6
+ nodegit . Repository . open ( path . resolve ( __dirname , "../.git" ) )
7
+ . then ( function ( repo ) {
8
+ repo . getStatus ( ) . then ( function ( statuses ) {
9
+ function statusToText ( status ) {
10
+ var words = [ ] ;
11
+ if ( status . isNew ( ) ) { words . push ( "NEW" ) ; }
12
+ if ( status . isModified ( ) ) { words . push ( "MODIFIED" ) ; }
13
+ if ( status . isTypechange ( ) ) { words . push ( "TYPECHANGE" ) ; }
14
+ if ( status . isRenamed ( ) ) { words . push ( "RENAMED" ) ; }
15
+ if ( status . isIgnored ( ) ) { words . push ( "IGNORED" ) ; }
16
+
17
+ return words . join ( " " ) ;
18
+ }
19
+
20
+ statuses . forEach ( function ( file ) {
21
+ console . log ( file . path ( ) + " " + statusToText ( file ) ) ;
22
+ } ) ;
23
+ } ) ;
24
+ } ) ;
You can’t perform that action at this time.
0 commit comments