Skip to content

Commit 1eaf5bc

Browse files
committed
fix linting of examples
1 parent 666f946 commit 1eaf5bc

16 files changed

+702
-576
lines changed

examples/add-and-commit.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
var nodegit = require('../');
2-
var path = require('path');
3-
var Promise = require('nodegit-promise');
4-
var promisify = require('promisify-node');
5-
var fse = promisify(require('fs-extra'));
6-
var fileName = 'newfile.txt';
7-
var fileContent = 'hello world';
8-
var directoryName = 'salad/toast/strangerinastrangeland/theresnowaythisexists';
1+
var nodegit = require("../");
2+
var path = require("path");
3+
var promisify = require("promisify-node");
4+
var fse = promisify(require("fs-extra"));
5+
var fileName = "newfile.txt";
6+
var fileContent = "hello world";
7+
var directoryName = "salad/toast/strangerinastrangeland/theresnowaythisexists";
98
// ensureDir is an alias to mkdirp, which has the callback with a weird name
10-
// and in the 3rd position of 4 (the 4th being used for recursion). We have to force
11-
// promisify it, because promisify-node won't detect it on its own and assumes sync
9+
// and in the 3rd position of 4 (the 4th being used for recursion). We have to
10+
// force promisify it, because promisify-node won't detect it on its
11+
// own and assumes sync
1212
fse.ensureDir = promisify(fse.ensureDir);
1313

1414
/**
15-
* This example creates a certain file `newfile.txt`, adds it to the git index and
16-
* commits it to head. Similar to a `git add newfile.txt` followed by a `git commit`
15+
* This example creates a certain file `newfile.txt`, adds it to the git
16+
* index and commits it to head. Similar to a `git add newfile.txt`
17+
* followed by a `git commit`
1718
**/
1819

1920
var repo;
2021
var index;
2122
var oid;
22-
var parent;
2323

24-
nodegit.Repository.open(path.resolve(__dirname, '../.git'))
24+
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
2525
.then(function(repoResult) {
2626
repo = repoResult;
2727
return fse.ensureDir(path.join(repo.workdir(), directoryName));
2828
}).then(function(){
2929
return fse.writeFile(path.join(repo.workdir(), fileName), fileContent);
3030
})
3131
.then(function() {
32-
return fse.writeFile(path.join(repo.workdir(), directoryName, fileName), fileContent);
32+
return fse.writeFile(
33+
path.join(repo.workdir(), directoryName, fileName),
34+
fileContent
35+
);
3336
})
3437
.then(function() {
3538
return repo.openIndex();
@@ -52,17 +55,19 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
5255
})
5356
.then(function(oidResult) {
5457
oid = oidResult;
55-
return nodegit.Reference.nameToId(repo, 'HEAD');
58+
return nodegit.Reference.nameToId(repo, "HEAD");
5659
})
5760
.then(function(head) {
5861
return repo.getCommit(head);
5962
})
6063
.then(function(parent) {
61-
var author = nodegit.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60);
62-
var committer = nodegit.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90);
64+
var author = nodegit.Signature.create("Scott Chacon",
65+
"schacon@gmail.com", 123456789, 60);
66+
var committer = nodegit.Signature.create("Scott A Chacon",
67+
"scott@github.com", 987654321, 90);
6368

64-
return repo.createCommit('HEAD', author, committer, 'message', oid, [parent]);
69+
return repo.createCommit("HEAD", author, committer, "message", oid, [parent]);
6570
})
6671
.done(function(commitId) {
67-
console.log('New Commit: ', commitId);
72+
console.log("New Commit: ", commitId);
6873
});

examples/apps/git_profanity_check.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
//
1111
// node git_profanity_check some/repo/.git
1212
//
13-
var git = require('../../');
13+
var git = require("../../");
1414

15-
var curses = ['put', 'curse', 'words', 'here'];
16-
var path = './.git';
17-
var branch = 'master';
18-
var reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi');
15+
var curses = ["put", "curse", "words", "here"];
16+
var path = "./.git";
17+
var branch = "master";
18+
var reCurse = new RegExp("\\b(?:" + curses.join("|") + ")\\b", "gi");
1919

2020
// Default path is `.git`.
2121
if (process.argv.length < 3) {
22-
console.log('No path passed as argument, defaulting to .git.');
22+
console.log("No path passed as argument, defaulting to .git.");
2323
}
2424
// Otherwise defaults.
2525
else {
2626
path = process.argv[2];
2727

2828
// Set repo branch
2929
if (process.argv.length < 4) {
30-
console.log('No branch passed as argument, defaulting to master.');
30+
console.log("No branch passed as argument, defaulting to master.");
3131
}
3232
else {
3333
branch = process.argv[3];
@@ -44,12 +44,12 @@ git.Repo.open(path)
4444
var history = firstCommit.history();
4545

4646
// Iterate over every commit message and test for words.
47-
history.on('commit', function(commit) {
47+
history.on("commit", function(commit) {
4848
var message = commit.message();
4949

5050
if (reCurse.test(message)) {
51-
console.log('Curse detected in commit', commit.sha());
52-
console.log('=> ', message);
51+
console.log("Curse detected in commit", commit.sha());
52+
console.log("=> ", message);
5353
return;
5454
}
5555
});

examples/clone.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var nodegit = require('../');
1+
var nodegit = require("../");
22
var promisify = require("promisify-node");
33
var fse = promisify(require("fs-extra"));
44
var path = "/tmp/nodegit-clone-demo";
@@ -11,20 +11,20 @@ fse.remove(path).then(function() {
1111
path,
1212
{ ignoreCertErrors: 1})
1313
.then(function(repo) {
14-
return repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5');
14+
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
1515
})
1616
.then(function(commit) {
17-
return commit.getEntry('README.md')
17+
return commit.getEntry("README.md");
1818
})
1919
.then(function(entryResult) {
2020
entry = entryResult;
2121
return entry.getBlob();
2222
})
2323
.done(function(blob) {
24-
console.log(entry.filename(), entry.sha(), blob.rawsize() + 'b');
25-
console.log('========================================================\n\n');
26-
var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
24+
console.log(entry.filename(), entry.sha(), blob.rawsize() + "b");
25+
console.log("========================================================\n\n");
26+
var firstTenLines = blob.toString().split("\n").slice(0, 10).join("\n");
2727
console.log(firstTenLines);
28-
console.log('...');
28+
console.log("...");
2929
});
3030
});

examples/create-new-repo.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
var nodegit = require('../');
2-
var path = require('path');
3-
var Promise = require('nodegit-promise');
4-
var promisify = require('promisify-node');
5-
var fse = promisify(require('fs-extra'));
6-
var fileName = 'newfile.txt';
7-
var fileContent = 'hello world';
8-
var repoDir = '../../newRepo';
1+
var nodegit = require("../");
2+
var path = require("path");
3+
var promisify = require("promisify-node");
4+
var fse = promisify(require("fs-extra"));
5+
var fileName = "newfile.txt";
6+
var fileContent = "hello world";
7+
var repoDir = "../../newRepo";
98

109
fse.ensureDir = promisify(fse.ensureDir);
1110

@@ -37,13 +36,15 @@ fse.ensureDir(path.resolve(__dirname, repoDir))
3736
return index.writeTree();
3837
})
3938
.then(function(oid) {
40-
var author = nodegit.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60);
41-
var committer = nodegit.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90);
39+
var author = nodegit.Signature.create("Scott Chacon",
40+
"schacon@gmail.com", 123456789, 60);
41+
var committer = nodegit.Signature.create("Scott A Chacon",
42+
"scott@github.com", 987654321, 90);
4243

4344
// Since we're creating an inital commit, it has no parents. Note that unlike
4445
// normal we don't get the head either, because there isn't one yet.
45-
return repository.createCommit('HEAD', author, committer, 'message', oid, []);
46+
return repository.createCommit("HEAD", author, committer, "message", oid, []);
4647
})
4748
.done(function(commitId) {
48-
console.log('New Commit: ', commitId);
49+
console.log("New Commit: ", commitId);
4950
});

examples/details-for-tree-entry.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
var nodegit = require('../');
2-
var path = require('path');
1+
var nodegit = require("../");
2+
var path = require("path");
33

44
/**
55
* This shows how to get details from a tree entry or a blob
66
**/
77

8-
nodegit.Repository.open(path.resolve(__dirname, '../.git'))
9-
.then(function(repo) {
10-
return repo.getTree("e1b0c7ea57bfc5e30ec279402a98168a27838ac9")
11-
.then(function(tree) {
12-
var treeEntry = tree.entryByIndex(0);
8+
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
9+
.then(function(repo) {
10+
return repo.getTree("e1b0c7ea57bfc5e30ec279402a98168a27838ac9")
11+
.then(function(tree) {
12+
var treeEntry = tree.entryByIndex(0);
1313

14-
// Tree entry doesn't have any data associated with the actual entry
15-
// To get that we need to get the index entry that this points to
16-
return repo.openIndex().then(function(index) {
17-
var indexEntry = index.getByPath(treeEntry.path());
14+
// Tree entry doesn't have any data associated with the actual entry
15+
// To get that we need to get the index entry that this points to
16+
return repo.openIndex().then(function(index) {
17+
var indexEntry = index.getByPath(treeEntry.path());
1818

19-
// With the index entry we can now view the details for the tree entry
20-
console.log("Entry path: " + indexEntry.path());
21-
console.log("Entry time in seconds: " + indexEntry.mtime().seconds());
22-
console.log("Entry oid: " + indexEntry.id().toString());
23-
console.log("Entry size: " + indexEntry.fileSize());
19+
// With the index entry we can now view the details for the tree entry
20+
console.log("Entry path: " + indexEntry.path());
21+
console.log("Entry time in seconds: " + indexEntry.mtime().seconds());
22+
console.log("Entry oid: " + indexEntry.id().toString());
23+
console.log("Entry size: " + indexEntry.fileSize());
24+
});
2425
});
2526
})
26-
}).done(function() {
27-
console.log("Done!");
28-
});
27+
.done(function() {
28+
console.log("Done!");
29+
});

examples/diff-commits.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
var nodegit = require('../');
2-
var path = require('path');
1+
var nodegit = require("../");
2+
var path = require("path");
33

44
// This code examines the diffs between a particular commit and all of its
55
// parents. Since this commit is not a merge, it only has one parent. This is
66
// similar to doing `git show`.
77

8-
nodegit.Repository.open(path.resolve(__dirname, '../.git'))
8+
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
99
.then(function(repo) {
10-
return repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5');
10+
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
1111
})
1212
.then(function(commit) {
13-
console.log('commit ' + commit.sha());
14-
console.log('Author:', commit.author().name() + ' <' + commit.author().email() + '>');
15-
console.log('Date:', commit.date());
16-
console.log('\n ' + commit.message());
13+
console.log("commit " + commit.sha());
14+
console.log("Author:", commit.author().name() +
15+
" <" + commit.author().email() + ">");
16+
console.log("Date:", commit.date());
17+
console.log("\n " + commit.message());
1718

1819
return commit.getDiff();
1920
})
@@ -24,7 +25,8 @@ nodegit.Repository.open(path.resolve(__dirname, '../.git'))
2425
patch.hunks().forEach(function(hunk) {
2526
console.log(hunk.header().trim());
2627
hunk.lines().forEach(function(line) {
27-
console.log(String.fromCharCode(line.origin()) + line.content().trim());
28+
console.log(String.fromCharCode(line.origin()) +
29+
line.content().trim());
2830
});
2931
});
3032
});

examples/fetch.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
var nodegit = require('../');
2-
var path = require('path');
1+
var nodegit = require("../");
2+
var path = require("path");
33

4-
nodegit.Repository.open(path.resolve(__dirname, '../.git')).then(function(repo) {
5-
return repo.fetch("origin", {
6-
credentials: function(url, userName) {
7-
return nodegit.Cred.sshKeyFromAgent(userName);
8-
}
4+
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
5+
.then(function(repo) {
6+
return repo.fetch("origin", {
7+
credentials: function(url, userName) {
8+
return nodegit.Cred.sshKeyFromAgent(userName);
9+
}
10+
});
11+
}).done(function() {
12+
console.log("It worked!");
913
});
10-
}).done(function() {
11-
console.log("It worked!");
12-
});

0 commit comments

Comments
 (0)