Skip to content

Commit 2b009fd

Browse files
committed
Merge pull request #524 from nodegit/status-file-extras
Add convenience methods to status file
2 parents 12a2b60 + edead1c commit 2b009fd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/status_file.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ var StatusFile = function(args) {
8282
},
8383
isIgnored: function() {
8484
return data.statusBit & codes.IGNORED;
85+
},
86+
inWorkingTree: function() {
87+
return status & codes.WT_NEW ||
88+
status & codes.WT_MODIFIED ||
89+
status & codes.WT_DELETED ||
90+
status & codes.WT_TYPECHANGE ||
91+
status & codes.WT_RENAMED;
92+
},
93+
inIndex: function() {
94+
return status & codes.INDEX_NEW ||
95+
status & codes.INDEX_MODIFIED ||
96+
status & codes.INDEX_DELETED ||
97+
status & codes.INDEX_TYPECHANGE ||
98+
status & codes.INDEX_RENAMED;
8599
}
86100
};
87101
};

test/tests/status_file.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ describe("StatusFile", function() {
2020
assert.ok(this.status.isNew());
2121
assert.ok(!this.status.isModified());
2222
});
23+
24+
it("detects working tree and index statuses", function() {
25+
assert.ok(this.status.inWorkingTree());
26+
assert.ok(!this.status.inIndex());
27+
});
2328
});

0 commit comments

Comments
 (0)