forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstatus.js
24 lines (20 loc) · 781 Bytes
/
status.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var nodegit = require("../"),
path = require("path");
// This code shows working directory changes similar to git status
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
.then(function(repo) {
repo.getStatus().then(function(statuses) {
function statusToText(status) {
var words = [];
if (status.isNew()) { words.push("NEW"); }
if (status.isModified()) { words.push("MODIFIED"); }
if (status.isTypechange()) { words.push("TYPECHANGE"); }
if (status.isRenamed()) { words.push("RENAMED"); }
if (status.isIgnored()) { words.push("IGNORED"); }
return words.join(" ");
}
statuses.forEach(function(file) {
console.log(file.path() + " " + statusToText(file));
});
});
});