From 62e9a5f8284361876f8879470859907c1915b57b Mon Sep 17 00:00:00 2001 From: Maximiliano Korp Date: Wed, 1 Apr 2015 22:15:17 -0700 Subject: [PATCH 1/2] add StatusFile.inWorkingTree and inIndex convenience methods --- lib/status_file.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/status_file.js b/lib/status_file.js index 1b82aa1cb..ddce025b2 100644 --- a/lib/status_file.js +++ b/lib/status_file.js @@ -82,6 +82,20 @@ var StatusFile = function(args) { }, isIgnored: function() { return data.statusBit & codes.IGNORED; + }, + inWorkingTree: function() { + return status & codes.WT_NEW || + status & codes.WT_MODIFIED || + status & codes.WT_DELETED || + status & codes.WT_TYPECHANGE || + status & codes.WT_RENAMED; + }, + inIndex: function() { + return status & codes.INDEX_NEW || + status & codes.INDEX_MODIFIED || + status & codes.INDEX_DELETED || + status & codes.INDEX_TYPECHANGE || + status & codes.INDEX_RENAMED; } }; }; From edead1ce55c0ac697fffa582ce58b1016324dfe1 Mon Sep 17 00:00:00 2001 From: Maximiliano Korp Date: Wed, 1 Apr 2015 22:22:00 -0700 Subject: [PATCH 2/2] add test for new convenience methods --- test/tests/status_file.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/tests/status_file.js b/test/tests/status_file.js index cd669350d..dd709eee8 100644 --- a/test/tests/status_file.js +++ b/test/tests/status_file.js @@ -20,4 +20,9 @@ describe("StatusFile", function() { assert.ok(this.status.isNew()); assert.ok(!this.status.isModified()); }); + + it("detects working tree and index statuses", function() { + assert.ok(this.status.inWorkingTree()); + assert.ok(!this.status.inIndex()); + }); });