FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add convenience methods to status file by maxkorp · Pull Request #524 · nodegit/nodegit · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 14 additions & 0 deletions lib/status_file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
};
Expand Down
5 changes: 5 additions & 0 deletions test/tests/status_file.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
});

Back | FazBrowse Home | New Git URL