pj-nodegit 0.18.5 → 0.18.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/package.json +4 -5
  2. package/lib/README.md +0 -3
  3. package/lib/attr.js +0 -20
  4. package/lib/blame.js +0 -20
  5. package/lib/blob.js +0 -73
  6. package/lib/branch.js +0 -19
  7. package/lib/buf.js +0 -11
  8. package/lib/checkout.js +0 -51
  9. package/lib/cherrypick.js +0 -73
  10. package/lib/clone.js +0 -33
  11. package/lib/commit.js +0 -437
  12. package/lib/config.js +0 -25
  13. package/lib/convenient_hunks.js +0 -61
  14. package/lib/convenient_patch.js +0 -131
  15. package/lib/credential.js +0 -33
  16. package/lib/diff.js +0 -113
  17. package/lib/diff_file.js +0 -38
  18. package/lib/diff_line.js +0 -32
  19. package/lib/enums.js +0 -689
  20. package/lib/error.js +0 -17
  21. package/lib/filter_registry.js +0 -25
  22. package/lib/index.js +0 -103
  23. package/lib/libgit2.js +0 -6
  24. package/lib/merge.js +0 -72
  25. package/lib/nodegit.js +0 -1333
  26. package/lib/note.js +0 -17
  27. package/lib/object.js +0 -45
  28. package/lib/odb_object.js +0 -9
  29. package/lib/oid.js +0 -23
  30. package/lib/rebase.js +0 -142
  31. package/lib/reference.js +0 -213
  32. package/lib/remote.js +0 -270
  33. package/lib/repository.js +0 -1982
  34. package/lib/reset.js +0 -76
  35. package/lib/revert.js +0 -77
  36. package/lib/revwalk.js +0 -142
  37. package/lib/signature.js +0 -38
  38. package/lib/stash.js +0 -62
  39. package/lib/status.js +0 -18
  40. package/lib/status_file.js +0 -106
  41. package/lib/status_list.js +0 -12
  42. package/lib/submodule.js +0 -51
  43. package/lib/tag.js +0 -135
  44. package/lib/tree.js +0 -175
  45. package/lib/tree_entry.js +0 -99
  46. package/lib/utils/lookup_wrapper.js +0 -39
  47. package/lib/utils/normalize_fetch_options.js +0 -43
  48. package/lib/utils/normalize_options.js +0 -29
  49. package/lib/utils/shallow_clone.js +0 -14
package/lib/commit.js DELETED
@@ -1,437 +0,0 @@
1
- var events = require("events");
2
- var fp = require("lodash/fp");
3
- var NodeGit = require("../");
4
- var Commit = NodeGit.Commit;
5
- var LookupWrapper = NodeGit.Utils.lookupWrapper;
6
-
7
- var _amend = Commit.prototype.amend;
8
- var _parent = Commit.prototype.parent;
9
-
10
- /**
11
- * Retrieves the commit pointed to by the oid
12
- * @async
13
- * @param {Repository} repo The repo that the commit lives in
14
- * @param {String|Oid|Commit} id The commit to lookup
15
- * @return {Commit}
16
- */
17
- Commit.lookup = LookupWrapper(Commit);
18
-
19
- /**
20
- * @async
21
- * @param {Number} n
22
- * @return {Commit}
23
- */
24
- Commit.prototype.parent = function(n) {
25
- var repo = this.repo;
26
- return _parent.call(this, n).then(p => {
27
- p.repo = repo;
28
- return p;
29
- });
30
- };
31
-
32
- /**
33
- * Amend a commit
34
- * @async
35
- * @param {String} update_ref
36
- * @param {Signature} author
37
- * @param {Signature} committer
38
- * @param {String} message_encoding
39
- * @param {String} message
40
- * @param {Tree|Oid} tree
41
- * @return {Oid}
42
- */
43
- Commit.prototype.amend = function (
44
- updateRef, author, committer, message_encoding, message, tree) {
45
- var repo = this.repo;
46
- var _this = this;
47
- var treePromise;
48
-
49
- if (tree instanceof NodeGit.Oid){
50
- treePromise = repo.getTree(tree);
51
- } else {
52
- treePromise = Promise.resolve(tree);
53
- }
54
-
55
- return treePromise
56
- .then(function(treeObject){
57
- return _amend.call(_this,
58
- updateRef,
59
- author,
60
- committer,
61
- message_encoding,
62
- message,
63
- treeObject
64
- );
65
- });
66
- };
67
-
68
- /**
69
- * Amend a commit with the given signature
70
- * @async
71
- * @param {String} updateRef
72
- * @param {Signature} author
73
- * @param {Signature} committer
74
- * @param {String} messageEncoding
75
- * @param {String} message
76
- * @param {Tree|Oid} tree
77
- * @param {Function} onSignature Callback to be called with string to be signed
78
- * @return {Oid}
79
- */
80
- Commit.prototype.amendWithSignature = function(
81
- updateRef,
82
- author,
83
- committer,
84
- messageEncoding,
85
- message,
86
- tree,
87
- onSignature
88
- ) {
89
- let repo = this.repo;
90
- let parentOids = this.parents();
91
- let _this = this;
92
- let promises = [];
93
-
94
- if (tree instanceof NodeGit.Oid) {
95
- promises.push(repo.getTree(tree));
96
- } else {
97
- promises.push(Promise.resolve(tree));
98
- }
99
-
100
- parentOids.forEach(function (parentOid) {
101
- promises.push(repo.getCommit(parentOid));
102
- });
103
-
104
- let treeObject;
105
- let parents;
106
- let commitContent;
107
- let commit;
108
- let skippedSigning;
109
- let resolvedAuthor;
110
- let resolvedCommitter;
111
- let resolvedMessageEncoding;
112
- let resolvedMessage;
113
- let resolvedTree;
114
-
115
- let createCommitPromise = Promise.all(promises)
116
- .then(function(results) {
117
- treeObject = fp.head(results);
118
- parents = fp.tail(results);
119
- return _this.getTree();
120
- })
121
- .then(function(commitTreeResult) {
122
- let commitTree = commitTreeResult;
123
-
124
- let truthyArgs = fp.omitBy(
125
- fp.isNil,
126
- {
127
- author,
128
- committer,
129
- messageEncoding,
130
- message,
131
- tree: treeObject
132
- }
133
- );
134
-
135
- let commitFields = {
136
- author: _this.author(),
137
- committer: _this.committer(),
138
- messageEncoding: _this.messageEncoding(),
139
- message: _this.message(),
140
- tree: commitTree
141
- };
142
-
143
- ({
144
- author: resolvedAuthor,
145
- committer: resolvedCommitter,
146
- messageEncoding: resolvedMessageEncoding,
147
- message: resolvedMessage,
148
- tree: resolvedTree
149
- } = fp.assign(
150
- commitFields,
151
- truthyArgs
152
- ));
153
-
154
- return Commit.createBuffer(
155
- repo,
156
- resolvedAuthor,
157
- resolvedCommitter,
158
- resolvedMessageEncoding,
159
- resolvedMessage,
160
- resolvedTree,
161
- parents.length,
162
- parents
163
- );
164
- })
165
- .then(function(commitContentResult) {
166
- commitContent = commitContentResult;
167
- if (!commitContent.endsWith("\n")) {
168
- commitContent += "\n";
169
- }
170
- return onSignature(commitContent);
171
- })
172
- .then(function({ code, field, signedData }) {
173
- switch (code) {
174
- case NodeGit.Error.CODE.OK:
175
- return Commit.createWithSignature(
176
- repo,
177
- commitContent,
178
- signedData,
179
- field
180
- );
181
- case NodeGit.Error.CODE.PASSTHROUGH:
182
- skippedSigning = true;
183
- return Commit.create(
184
- repo,
185
- updateRef,
186
- resolvedAuthor,
187
- resolvedCommitter,
188
- resolvedMessageEncoding,
189
- resolvedMessage,
190
- resolvedTree,
191
- parents.length,
192
- parents
193
- );
194
- default: {
195
- const error = new Error(
196
- `Commit.amendWithSignature threw with error code ${code}`
197
- );
198
- error.errno = code;
199
- throw error;
200
- }
201
- }
202
- });
203
-
204
- if (!updateRef) {
205
- return createCommitPromise;
206
- }
207
-
208
- return createCommitPromise
209
- .then(function(commitOid) {
210
- if (skippedSigning) {
211
- return commitOid;
212
- }
213
-
214
- return repo.getCommit(commitOid)
215
- .then(function(commitResult) {
216
- commit = commitResult;
217
- return repo.getReference(updateRef);
218
- }).then(function(ref) {
219
- return ref.setTarget(
220
- commitOid,
221
- `commit (amend): ${commit.summary()}`
222
- );
223
- }).then(function() {
224
- return commitOid;
225
- });
226
- });
227
- };
228
-
229
- /**
230
- * Retrieve the commit time as a Date object.
231
- * @return {Date}
232
- */
233
- Commit.prototype.date = function() {
234
- return new Date(this.timeMs());
235
- };
236
-
237
- /**
238
- * Generate an array of diff trees showing changes between this commit
239
- * and its parent(s).
240
- *
241
- * @async
242
- * @return {Array<Diff>} an array of diffs
243
- */
244
- Commit.prototype.getDiff = function() {
245
- return this.getDiffWithOptions(null);
246
- };
247
-
248
- /**
249
- * Generate an array of diff trees showing changes between this commit
250
- * and its parent(s).
251
- *
252
- * @async
253
- * @param {Object} options
254
- * @return {Array<Diff>} an array of diffs
255
- */
256
- Commit.prototype.getDiffWithOptions = function(options) {
257
- var commit = this;
258
-
259
- return commit.getTree().then(function(thisTree) {
260
- return commit.getParents().then(function(parents) {
261
- var diffs;
262
- if (parents.length) {
263
- diffs = parents.map(function(parent) {
264
- return parent.getTree().then(function(parentTree) {
265
- return thisTree.diffWithOptions(parentTree, options);
266
- });
267
- });
268
- } else {
269
- diffs = [thisTree.diffWithOptions(null, options)];
270
- }
271
-
272
- return Promise.all(diffs);
273
- });
274
- });
275
- };
276
-
277
- /**
278
- * Retrieve the entry represented by path for this commit.
279
- * Path must be relative to repository root.
280
- *
281
- * @async
282
- * @param {String} path
283
- * @return {TreeEntry}
284
- */
285
- Commit.prototype.getEntry = function(path) {
286
- return this.getTree().then(function(tree) {
287
- return tree.getEntry(path);
288
- });
289
- };
290
-
291
- /**
292
- * Retrieve the commit's parents as commit objects.
293
- *
294
- * @async
295
- * @param {number} limit Optional amount of parents to return.
296
- * @return {Array<Commit>} array of commits
297
- */
298
- Commit.prototype.getParents = function(limit) {
299
- var parents = [];
300
-
301
- // If no limit was set, default to the maximum parents.
302
- limit = typeof limit === "number" ? limit : this.parentcount();
303
- limit = Math.min(limit, this.parentcount());
304
-
305
- for (var i = 0; i < limit; i++) {
306
- var oid = this.parentId(i);
307
- var parent = this.repo.getCommit(oid);
308
-
309
- parents.push(parent);
310
- }
311
-
312
- // Wait for all parents to complete, before returning.
313
- return Promise.all(parents);
314
- };
315
-
316
- /**
317
- * @typedef extractedSignature
318
- * @type {Object}
319
- * @property {String} signature the signature of the commit
320
- * @property {String} signedData the extracted signed data
321
- */
322
-
323
- /**
324
- * Retrieve the signature and signed data for a commit.
325
- * @param {String} field Optional field to get from the signature,
326
- * defaults to gpgsig
327
- * @return {extractedSignature}
328
- */
329
- Commit.prototype.getSignature = function(field) {
330
- return Commit.extractSignature(this.repo, this.id(), field);
331
- };
332
-
333
- /**
334
- * Get the tree associated with this commit.
335
- *
336
- * @async
337
- * @return {Tree}
338
- */
339
- Commit.prototype.getTree = function() {
340
- return this.repo.getTree(this.treeId());
341
- };
342
-
343
- /**
344
- * Walk the history from this commit backwards.
345
- *
346
- * An EventEmitter is returned that will emit a "commit" event for each
347
- * commit in the history, and one "end" event when the walk is completed.
348
- * Don't forget to call `start()` on the returned event.
349
- *
350
- * @fires EventEmitter#commit Commit
351
- * @fires EventEmitter#end Array<Commit>
352
- * @fires EventEmitter#error Error
353
- *
354
- * @return {EventEmitter}
355
- * @start start()
356
- */
357
- Commit.prototype.history = function() {
358
- var event = new events.EventEmitter();
359
- var oid = this.id();
360
- var revwalk = this.repo.createRevWalk();
361
-
362
- revwalk.sorting.apply(revwalk, arguments);
363
-
364
- var commits = [];
365
-
366
- event.start = function() {
367
- revwalk.walk(oid, function commitRevWalk(error, commit) {
368
- if (error) {
369
- if (error.errno === NodeGit.Error.CODE.ITEROVER) {
370
- event.emit("end", commits);
371
- return;
372
- } else {
373
- return event.emit("error", error);
374
- }
375
- }
376
-
377
- event.emit("commit", commit);
378
- commits.push(commit);
379
- });
380
- };
381
-
382
- return event;
383
- };
384
-
385
- /**
386
- * Get the specified parent of the commit.
387
- *
388
- * @param {number} the position of the parent, starting from 0
389
- * @async
390
- * @return {Commit} the parent commit at the specified position
391
- */
392
- Commit.prototype.parent = function (id) {
393
- var repository = this.repo;
394
- return _parent.call(this, id).then(function(parent) {
395
- parent.repo = repository;
396
- return parent;
397
- });
398
- };
399
-
400
- /**
401
- * Retrieve the commit's parent shas.
402
- *
403
- * @return {Array<Oid>} array of oids
404
- */
405
- Commit.prototype.parents = function() {
406
- var result = [];
407
-
408
- for (var i = 0; i < this.parentcount(); i++) {
409
- result.push(this.parentId(i));
410
- }
411
-
412
- return result;
413
- };
414
-
415
- /**
416
- * Retrieve the SHA.
417
- * @return {String}
418
- */
419
- Commit.prototype.sha = function() {
420
- return this.id().toString();
421
- };
422
-
423
- /**
424
- * Retrieve the commit time as a unix timestamp.
425
- * @return {Number}
426
- */
427
- Commit.prototype.timeMs = function() {
428
- return this.time() * 1000;
429
- };
430
-
431
- /**
432
- * The sha of this commit
433
- * @return {String}
434
- */
435
- Commit.prototype.toString = function() {
436
- return this.sha();
437
- };
package/lib/config.js DELETED
@@ -1,25 +0,0 @@
1
- var util = require("util");
2
- var NodeGit = require("../");
3
-
4
- var Config = NodeGit.Config;
5
-
6
- // Backwards compatibility.
7
- Config.prototype.getString = function() {
8
- return this.getStringBuf.apply(this, arguments);
9
- };
10
-
11
- NodeGit.Enums.CVAR = {};
12
- var DEPRECATED_CVAR_ENUMS = [
13
- "FALSE",
14
- "TRUE",
15
- "INT32",
16
- "STRING"
17
- ];
18
- DEPRECATED_CVAR_ENUMS.forEach((key) => {
19
- Object.defineProperty(NodeGit.Enums.CVAR, key, {
20
- get: util.deprecate(
21
- () => Config.MAP[key],
22
- `Use NodeGit.Config.MAP.${key} instead of NodeGit.Enums.CVAR.${key}.`
23
- )
24
- });
25
- });
@@ -1,61 +0,0 @@
1
- var NodeGit = require("../");
2
-
3
- var ConvenientHunk = NodeGit.ConvenientHunk;
4
-
5
- var header = ConvenientHunk.prototype.header;
6
- /**
7
- * Diff header string that represents the context of this hunk
8
- * of the diff. Something like `@@ -169,14 +167,12 @@ ...`
9
- * @return {String}
10
- */
11
- ConvenientHunk.prototype.header = header;
12
-
13
- var headerLen = ConvenientHunk.prototype.headerLen;
14
- /**
15
- * The length of the header
16
- * @return {Number}
17
- */
18
- ConvenientHunk.prototype.headerLen = headerLen;
19
-
20
- var lines = ConvenientHunk.prototype.lines;
21
- /**
22
- * The lines in this hunk
23
- * @async
24
- * @return {Array<DiffLine>}
25
- */
26
- ConvenientHunk.prototype.lines = lines;
27
-
28
- var newLines = ConvenientHunk.prototype.newLines;
29
- /**
30
- * The number of new lines in the hunk
31
- * @return {Number}
32
- */
33
- ConvenientHunk.prototype.newLines = newLines;
34
-
35
- var newStart = ConvenientHunk.prototype.newStart;
36
- /**
37
- * The starting offset of the first new line in the file
38
- * @return {Number}
39
- */
40
- ConvenientHunk.prototype.newStart = newStart;
41
-
42
- var oldLines = ConvenientHunk.prototype.oldLines;
43
- /**
44
- * The number of old lines in the hunk
45
- * @return {Number}
46
- */
47
- ConvenientHunk.prototype.oldLines = oldLines;
48
-
49
- var oldStart = ConvenientHunk.prototype.oldStart;
50
- /**
51
- * The starting offset of the first old line in the file
52
- * @return {Number}
53
- */
54
- ConvenientHunk.prototype.oldStart = oldStart;
55
-
56
- var size = ConvenientHunk.prototype.size;
57
- /**
58
- * Number of lines in this hunk
59
- * @return {Number}
60
- */
61
- ConvenientHunk.prototype.size = size;
@@ -1,131 +0,0 @@
1
- var NodeGit = require("../");
2
-
3
- var ConvenientPatch = NodeGit.ConvenientPatch;
4
-
5
- var hunks = ConvenientPatch.prototype.hunks;
6
- /**
7
- * The hunks in this patch
8
- * @async
9
- * @return {Array<ConvenientHunk>} a promise that resolves to an array of
10
- * ConvenientHunks
11
- */
12
- ConvenientPatch.prototype.hunks = hunks;
13
-
14
- var isAdded = ConvenientPatch.prototype.isAdded;
15
- /**
16
- * Is this an added patch?
17
- * @return {Boolean}
18
- */
19
- ConvenientPatch.prototype.isAdded = isAdded;
20
-
21
- var isConflicted = ConvenientPatch.prototype.isConflicted;
22
- /**
23
- * Is this a conflicted patch?
24
- * @return {Boolean}
25
- */
26
- ConvenientPatch.prototype.isConflicted = isConflicted;
27
-
28
- var isCopied = ConvenientPatch.prototype.isCopied;
29
- /**
30
- * Is this a copied patch?
31
- * @return {Boolean}
32
- */
33
- ConvenientPatch.prototype.isCopied = isCopied;
34
-
35
- var isDeleted = ConvenientPatch.prototype.isDeleted;
36
- /**
37
- * Is this a deleted patch?
38
- * @return {Boolean}
39
- */
40
- ConvenientPatch.prototype.isDeleted = isDeleted;
41
-
42
- var isIgnored = ConvenientPatch.prototype.isIgnored;
43
- /**
44
- * Is this an ignored patch?
45
- * @return {Boolean}
46
- */
47
- ConvenientPatch.prototype.isIgnored = isIgnored;
48
-
49
- var isModified = ConvenientPatch.prototype.isModified;
50
- /**
51
- * Is this an modified patch?
52
- * @return {Boolean}
53
- */
54
- ConvenientPatch.prototype.isModified = isModified;
55
-
56
- var isRenamed = ConvenientPatch.prototype.isRenamed;
57
- /**
58
- * Is this a renamed patch?
59
- * @return {Boolean}
60
- */
61
- ConvenientPatch.prototype.isRenamed = isRenamed;
62
-
63
- var isTypeChange = ConvenientPatch.prototype.isTypeChange;
64
- /**
65
- * Is this a type change?
66
- * @return {Boolean}
67
- */
68
- ConvenientPatch.prototype.isTypeChange = isTypeChange;
69
-
70
- var isUnmodified = ConvenientPatch.prototype.isUnmodified;
71
- /**
72
- * Is this an unmodified patch?
73
- * @return {Boolean}
74
- */
75
- ConvenientPatch.prototype.isUnmodified = isUnmodified;
76
-
77
- var isUnreadable = ConvenientPatch.prototype.isUnreadable;
78
- /**
79
- * Is this an undreadable patch?
80
- * @return {Boolean}
81
- */
82
- ConvenientPatch.prototype.isUnreadable = isUnreadable;
83
-
84
- var isUntracked = ConvenientPatch.prototype.isUntracked;
85
- /**
86
- * Is this an untracked patch?
87
- * @return {Boolean}
88
- */
89
- ConvenientPatch.prototype.isUntracked = isUntracked;
90
-
91
- /**
92
- * @typedef lineStats
93
- * @type {Object}
94
- * @property {number} total_context # of contexts in the patch
95
- * @property {number} total_additions # of lines added in the patch
96
- * @property {number} total_deletions # of lines deleted in the patch
97
- */
98
- var lineStats = ConvenientPatch.prototype.lineStats;
99
- /**
100
- * The line statistics of this patch (#contexts, #added, #deleted)
101
- * @return {lineStats}
102
- */
103
- ConvenientPatch.prototype.lineStats = lineStats;
104
-
105
- var newFile = ConvenientPatch.prototype.newFile;
106
- /**
107
- * New attributes of the file
108
- * @return {DiffFile}
109
- */
110
- ConvenientPatch.prototype.newFile = newFile;
111
-
112
- var oldFile = ConvenientPatch.prototype.oldFile;
113
- /**
114
- * Old attributes of the file
115
- * @return {DiffFile}
116
- */
117
- ConvenientPatch.prototype.oldFile = oldFile;
118
-
119
- var size = ConvenientPatch.prototype.size;
120
- /**
121
- * The number of hunks in this patch
122
- * @return {Number}
123
- */
124
- ConvenientPatch.prototype.size = size;
125
-
126
- var status = ConvenientPatch.prototype.status;
127
- /**
128
- * The status of this patch (unmodified, added, deleted)
129
- * @return {Number}
130
- */
131
- ConvenientPatch.prototype.status = status;
package/lib/credential.js DELETED
@@ -1,33 +0,0 @@
1
- var util = require("util");
2
- var NodeGit = require("../");
3
-
4
- var Credential = NodeGit.Credential;
5
-
6
- var deprecatedFn = (method) =>
7
- util.deprecate(
8
- Credential[method].bind(Credential),
9
- `Use NodeGit.Credential.${method} instead of NodeGit.Cred.${method}`
10
- );
11
-
12
- var createCredTypeDeprecationMessage = type =>
13
- `Use NodeGit.Credential.TYPE.${type} instead of NodeGit.Cred.TYPE.${type}`;
14
-
15
- NodeGit.Cred = {
16
- defaultNew: deprecatedFn("defaultNew"),
17
- sshKeyFromAgent: deprecatedFn("sshKeyFromAgent"),
18
- sshKeyNew: deprecatedFn("sshKeyNew"),
19
- usernameNew: deprecatedFn("usernameNew"),
20
- userpassPlaintextNew: deprecatedFn("userpassPlaintextNew"),
21
- TYPE: Object.keys(Credential.TYPE).reduce(
22
- (type, key) => {
23
- Object.defineProperty(type, key, {
24
- get: util.deprecate(
25
- () => Credential.TYPE[type],
26
- createCredTypeDeprecationMessage(type)
27
- )
28
- });
29
- return type;
30
- },
31
- {}
32
- )
33
- };