Skip to content

Commit b814f97

Browse files
committed
npm run lint
1 parent 65c12ab commit b814f97

File tree

174 files changed

+13292
-13266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+13292
-13266
lines changed

examples/add-and-commit.js

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,65 @@
1-
var nodegit = require("../");
2-
var path = require("path");
3-
var fse = require("fs-extra");
4-
var fileName = "newfile.txt";
5-
var fileContent = "hello world";
6-
var directoryName = "salad/toast/strangerinastrangeland/theresnowaythisexists";
1+
var nodegit = require('../');
2+
var path = require('path');
3+
var fse = require('fs-extra');
4+
var fileName = 'newfile.txt';
5+
var fileContent = 'hello world';
6+
var directoryName = 'salad/toast/strangerinastrangeland/theresnowaythisexists';
77

88
/**
99
* This example creates a certain file `newfile.txt`, adds it to the git
1010
* index and commits it to head. Similar to a `git add newfile.txt`
1111
* followed by a `git commit`
12-
**/
12+
**/
1313

1414
var repo;
1515
var index;
1616
var oid;
1717

18-
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
19-
.then(function(repoResult) {
20-
repo = repoResult;
21-
return fse.ensureDir(path.join(repo.workdir(), directoryName));
22-
}).then(function(){
23-
return fse.writeFile(path.join(repo.workdir(), fileName), fileContent);
24-
})
25-
.then(function() {
26-
return fse.writeFile(
27-
path.join(repo.workdir(), directoryName, fileName),
28-
fileContent
29-
);
30-
})
31-
.then(function() {
32-
return repo.refreshIndex();
33-
})
34-
.then(function(indexResult) {
35-
index = indexResult;
36-
})
37-
.then(function() {
38-
// this file is in the root of the directory and doesn't need a full path
39-
return index.addByPath(fileName);
40-
})
41-
.then(function() {
42-
// this file is in a subdirectory and can use a relative path
43-
return index.addByPath(path.posix.join(directoryName, fileName));
44-
})
45-
.then(function() {
46-
// this will write both files to the index
47-
return index.write();
48-
})
49-
.then(function() {
50-
return index.writeTree();
51-
})
52-
.then(function(oidResult) {
53-
oid = oidResult;
54-
return nodegit.Reference.nameToId(repo, "HEAD");
55-
})
56-
.then(function(head) {
57-
return repo.getCommit(head);
58-
})
59-
.then(function(parent) {
60-
var author = nodegit.Signature.now("Scott Chacon",
61-
"schacon@gmail.com");
62-
var committer = nodegit.Signature.now("Scott A Chacon",
63-
"scott@github.com");
18+
nodegit.Repository.open(path.resolve(__dirname, '../.git'))
19+
.then(function (repoResult) {
20+
repo = repoResult;
21+
return fse.ensureDir(path.join(repo.workdir(), directoryName));
22+
})
23+
.then(function () {
24+
return fse.writeFile(path.join(repo.workdir(), fileName), fileContent);
25+
})
26+
.then(function () {
27+
return fse.writeFile(path.join(repo.workdir(), directoryName, fileName), fileContent);
28+
})
29+
.then(function () {
30+
return repo.refreshIndex();
31+
})
32+
.then(function (indexResult) {
33+
index = indexResult;
34+
})
35+
.then(function () {
36+
// this file is in the root of the directory and doesn't need a full path
37+
return index.addByPath(fileName);
38+
})
39+
.then(function () {
40+
// this file is in a subdirectory and can use a relative path
41+
return index.addByPath(path.posix.join(directoryName, fileName));
42+
})
43+
.then(function () {
44+
// this will write both files to the index
45+
return index.write();
46+
})
47+
.then(function () {
48+
return index.writeTree();
49+
})
50+
.then(function (oidResult) {
51+
oid = oidResult;
52+
return nodegit.Reference.nameToId(repo, 'HEAD');
53+
})
54+
.then(function (head) {
55+
return repo.getCommit(head);
56+
})
57+
.then(function (parent) {
58+
var author = nodegit.Signature.now('Scott Chacon', 'schacon@gmail.com');
59+
var committer = nodegit.Signature.now('Scott A Chacon', 'scott@github.com');
6460

65-
return repo.createCommit("HEAD", author, committer, "message", oid, [parent]);
66-
})
67-
.done(function(commitId) {
68-
console.log("New Commit: ", commitId);
69-
});
61+
return repo.createCommit('HEAD', author, committer, 'message', oid, [parent]);
62+
})
63+
.done(function (commitId) {
64+
console.log('New Commit: ', commitId);
65+
});
Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env node
21
// vim: ft=javascript
32

43
// Copyright 2011-2014, Tim Branyen @tbranyen <tim@tabdeveloper.com>
@@ -10,50 +9,50 @@
109
//
1110
// node git_profanity_check some/repo/.git
1211
//
13-
var git = require("../../");
12+
var git = require('../../');
1413

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");
14+
var curses = ['put', 'curse', 'words', 'here'];
15+
var path = './.git';
16+
var branch = 'master';
17+
var reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi');
1918

2019
// Default path is `.git`.
2120
if (process.argv.length < 3) {
22-
console.log("No path passed as argument, defaulting to .git.");
21+
console.log('No path passed as argument, defaulting to .git.');
2322
}
2423
// Otherwise defaults.
2524
else {
2625
path = process.argv[2];
2726

2827
// Set repo branch
2928
if (process.argv.length < 4) {
30-
console.log("No branch passed as argument, defaulting to master.");
31-
}
32-
else {
29+
console.log('No branch passed as argument, defaulting to master.');
30+
} else {
3331
branch = process.argv[3];
3432
}
3533
}
3634

3735
// Open repository.
3836
git.Repo.open(path)
39-
.then(function(repo) {
40-
// Open branch, default to master.
41-
return repo.getBranchCommit(branch);
42-
}).then(function(firstCommit) {
43-
// Iterate history
44-
var history = firstCommit.history();
45-
46-
// Iterate over every commit message and test for words.
47-
history.on("commit", function(commit) {
48-
var message = commit.message();
49-
50-
if (reCurse.test(message)) {
51-
console.log("Curse detected in commit", commit.sha());
52-
console.log("=> ", message);
53-
return;
54-
}
37+
.then(function (repo) {
38+
// Open branch, default to master.
39+
return repo.getBranchCommit(branch);
40+
})
41+
.then(function (firstCommit) {
42+
// Iterate history
43+
var history = firstCommit.history();
44+
45+
// Iterate over every commit message and test for words.
46+
history.on('commit', function (commit) {
47+
var message = commit.message();
48+
49+
if (reCurse.test(message)) {
50+
console.log('Curse detected in commit', commit.sha());
51+
console.log('=> ', message);
52+
return;
53+
}
54+
});
55+
56+
// Start history iteration.
57+
history.start();
5558
});
56-
57-
// Start history iteration.
58-
history.start();
59-
});

examples/checkout-remote-branch.js

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

4-
var remoteBranchName = "REMOTE-BRANCH-NAME";
4+
var remoteBranchName = 'REMOTE-BRANCH-NAME';
55

6-
nodegit.Repository.open(path.resolve(__dirname, "../.git"))
7-
.then(function(repo) {
8-
9-
return repo.getHeadCommit()
6+
nodegit.Repository.open(path.resolve(__dirname, '../.git'))
7+
.then(function (repo) {
8+
return repo
9+
.getHeadCommit()
1010
.then(function (targetCommit) {
1111
return repo.createBranch(remoteBranchName, targetCommit, false);
1212
})
1313
.then(function (reference) {
1414
return repo.checkoutBranch(reference, {});
1515
})
1616
.then(function () {
17-
return repo.getReferenceCommit(
18-
"refs/remotes/origin/" + remoteBranchName);
17+
return repo.getReferenceCommit('refs/remotes/origin/' + remoteBranchName);
1918
})
2019
.then(function (commit) {
2120
nodegit.Reset.reset(repo, commit, 3, {});
2221
});
23-
24-
}).done(function() {
25-
console.log("All done!");
26-
});
22+
})
23+
.done(function () {
24+
console.log('All done!');
25+
});

examples/clone.js

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
var nodegit = require("../");
2-
var fse = require("fs-extra");
3-
var path = "/tmp/nodegit-clone-demo";
1+
var nodegit = require('../');
2+
var fse = require('fs-extra');
3+
var path = '/tmp/nodegit-clone-demo';
44

5-
fse.remove(path).then(function() {
5+
fse.remove(path).then(function () {
66
var entry;
77

8-
nodegit.Clone(
9-
"https://github.com/nodegit/nodegit.git",
10-
path,
11-
{
8+
nodegit
9+
.Clone('https://github.com/nodegit/nodegit.git', path, {
1210
fetchOpts: {
1311
callbacks: {
14-
certificateCheck: function() {
12+
certificateCheck: function () {
1513
// github will fail cert check on some OSX machines
1614
// this overrides that check
1715
return 0;
18-
}
19-
}
20-
}
16+
},
17+
},
18+
},
2119
})
22-
.then(function(repo) {
23-
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
24-
})
25-
.then(function(commit) {
26-
return commit.getEntry("README.md");
27-
})
28-
.then(function(entryResult) {
29-
entry = entryResult;
30-
return entry.getBlob();
31-
})
32-
.done(function(blob) {
33-
console.log(entry.name(), entry.sha(), blob.rawsize() + "b");
34-
console.log("========================================================\n\n");
35-
var firstTenLines = blob.toString().split("\n").slice(0, 10).join("\n");
36-
console.log(firstTenLines);
37-
console.log("...");
38-
});
20+
.then(function (repo) {
21+
return repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5');
22+
})
23+
.then(function (commit) {
24+
return commit.getEntry('README.md');
25+
})
26+
.then(function (entryResult) {
27+
entry = entryResult;
28+
return entry.getBlob();
29+
})
30+
.done(function (blob) {
31+
console.log(entry.name(), entry.sha(), blob.rawsize() + 'b');
32+
console.log('========================================================\n\n');
33+
var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
34+
console.log(firstTenLines);
35+
console.log('...');
36+
});
3937
});
Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
var nodegit = require("../");
2-
var fse = require("fs-extra");
3-
var path = "/tmp/nodegit-github-2factor-demo";
1+
var nodegit = require('../');
2+
var fse = require('fs-extra');
3+
var path = '/tmp/nodegit-github-2factor-demo';
44

5-
var token = "{Your GitHub user token}";
6-
var repoOwner = "{The orgname or username that owns the repo}";
7-
var repoName = "{The name of the repo}";
5+
var token = '{Your GitHub user token}';
6+
var repoOwner = '{The orgname or username that owns the repo}';
7+
var repoName = '{The name of the repo}';
88

99
// To clone with 2 factor auth enabled, you have to use a github oauth token
1010
// over https, it can't be done with actual 2 factor.
1111
// https://github.com/blog/1270-easier-builds-and-deployments-using-git-over-https-and-oauth
1212

1313
// If the repo is public, you can use a callback instead
14-
var repoUrl = "https://github.com/" + repoOwner + "/" + repoName + ".git";
14+
var repoUrl = 'https://github.com/' + repoOwner + '/' + repoName + '.git';
1515

1616
var opts = {
1717
fetchOpts: {
1818
callbacks: {
19-
credentials: function() {
20-
return nodegit.Cred.userpassPlaintextNew(token, "x-oauth-basic");
19+
credentials: function () {
20+
return nodegit.Cred.userpassPlaintextNew(token, 'x-oauth-basic');
2121
},
22-
certificateCheck: function() {
22+
certificateCheck: function () {
2323
return 0;
24-
}
25-
}
26-
}
24+
},
25+
},
26+
},
2727
};
2828

29-
fse.remove(path).then(function() {
30-
nodegit.Clone(repoUrl, path, opts)
31-
.done(function(repo) {
32-
if (repo instanceof nodegit.Repository) {
33-
console.info("We cloned the repo!");
34-
}
35-
else {
36-
console.error("Something borked :(");
37-
}
38-
});
29+
fse.remove(path).then(function () {
30+
nodegit.Clone(repoUrl, path, opts).done(function (repo) {
31+
if (repo instanceof nodegit.Repository) {
32+
console.info('We cloned the repo!');
33+
} else {
34+
console.error('Something borked :(');
35+
}
36+
});
3937
});

0 commit comments

Comments
 (0)