pj-nodegit 0.18.4 → 0.18.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/lib/README.md +3 -0
  2. package/lib/attr.js +20 -0
  3. package/lib/blame.js +20 -0
  4. package/lib/blob.js +73 -0
  5. package/lib/branch.js +19 -0
  6. package/lib/buf.js +11 -0
  7. package/lib/checkout.js +51 -0
  8. package/lib/cherrypick.js +73 -0
  9. package/lib/clone.js +33 -0
  10. package/lib/commit.js +437 -0
  11. package/lib/config.js +25 -0
  12. package/lib/convenient_hunks.js +61 -0
  13. package/lib/convenient_patch.js +131 -0
  14. package/lib/credential.js +33 -0
  15. package/lib/diff.js +113 -0
  16. package/lib/diff_file.js +38 -0
  17. package/lib/diff_line.js +32 -0
  18. package/lib/enums.js +689 -0
  19. package/lib/error.js +17 -0
  20. package/lib/filter_registry.js +25 -0
  21. package/lib/index.js +103 -0
  22. package/lib/libgit2.js +6 -0
  23. package/lib/merge.js +72 -0
  24. package/lib/nodegit.js +1333 -0
  25. package/lib/note.js +17 -0
  26. package/lib/object.js +45 -0
  27. package/lib/odb_object.js +9 -0
  28. package/lib/oid.js +23 -0
  29. package/lib/rebase.js +142 -0
  30. package/lib/reference.js +213 -0
  31. package/lib/remote.js +270 -0
  32. package/lib/repository.js +1982 -0
  33. package/lib/reset.js +76 -0
  34. package/lib/revert.js +77 -0
  35. package/lib/revwalk.js +142 -0
  36. package/lib/signature.js +38 -0
  37. package/lib/stash.js +62 -0
  38. package/lib/status.js +18 -0
  39. package/lib/status_file.js +106 -0
  40. package/lib/status_list.js +12 -0
  41. package/lib/submodule.js +51 -0
  42. package/lib/tag.js +135 -0
  43. package/lib/tree.js +175 -0
  44. package/lib/tree_entry.js +99 -0
  45. package/lib/utils/lookup_wrapper.js +39 -0
  46. package/lib/utils/normalize_fetch_options.js +43 -0
  47. package/lib/utils/normalize_options.js +29 -0
  48. package/lib/utils/shallow_clone.js +14 -0
  49. package/package.json +1 -1
package/lib/remote.js ADDED
@@ -0,0 +1,270 @@
1
+ var util = require("util");
2
+ var NodeGit = require("../");
3
+ var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
4
+ var normalizeOptions = NodeGit.Utils.normalizeOptions;
5
+ var lookupWrapper = NodeGit.Utils.lookupWrapper;
6
+ var shallowClone = NodeGit.Utils.shallowClone;
7
+
8
+ var Remote = NodeGit.Remote;
9
+ var _connect = Remote.prototype.connect;
10
+ var _createWithOpts = Remote.createWithOpts;
11
+ var _disconnect = Remote.prototype.disconnect;
12
+ var _download = Remote.prototype.download;
13
+ var _fetch = Remote.prototype.fetch;
14
+ var _push = Remote.prototype.push;
15
+ var _updateTips = Remote.prototype.updateTips;
16
+ var _upload = Remote.prototype.upload;
17
+
18
+ /**
19
+ * Retrieves the remote by name
20
+ * @async
21
+ * @param {Repository} repo The repo that the remote lives in
22
+ * @param {String|Remote} name The remote to lookup
23
+ * @param {Function} callback
24
+ * @return {Remote}
25
+ */
26
+ Remote.lookup = lookupWrapper(Remote);
27
+
28
+ /**
29
+ * Connects to a remote
30
+ *
31
+ * @async
32
+ * @param {Enums.DIRECTION} direction The direction for the connection
33
+ * @param {RemoteCallbacks} callbacks The callback functions for the connection
34
+ * @param {ProxyOptions} proxyOpts Proxy settings
35
+ * @param {Array<string>} customHeaders extra HTTP headers to use
36
+ * @param {Function} callback
37
+ * @return {Number} error code
38
+ */
39
+ Remote.prototype.connect = function(
40
+ direction,
41
+ callbacks,
42
+ proxyOpts,
43
+ customHeaders
44
+ ) {
45
+ callbacks = normalizeOptions(callbacks || {}, NodeGit.RemoteCallbacks);
46
+ proxyOpts = normalizeOptions(proxyOpts || {}, NodeGit.ProxyOptions);
47
+ customHeaders = customHeaders || [];
48
+
49
+ return _connect.call(this, direction, callbacks, proxyOpts, customHeaders)
50
+ .then(() => {
51
+ // Save options on the remote object. If we don't do this,
52
+ // the options may be cleaned up and cause a segfault
53
+ // when Remote.prototype.connect is called.
54
+ Object.defineProperties(this, {
55
+ callbacks: {
56
+ configurable: true,
57
+ value: callbacks,
58
+ writable: false
59
+ },
60
+ proxyOpts: {
61
+ configurable: true,
62
+ value: proxyOpts,
63
+ writable: false
64
+ },
65
+ customHeaders: {
66
+ configurable: true,
67
+ value: customHeaders,
68
+ writable: false
69
+ }
70
+ });
71
+ });
72
+ };
73
+
74
+ Remote.createWithOpts = function(url, options) {
75
+ return _createWithOpts(url, normalizeOptions(
76
+ options, NodeGit.RemoteCreateOptions));
77
+ };
78
+
79
+ Remote.prototype.disconnect = function() {
80
+ return _disconnect.call(this)
81
+ .then(() => {
82
+ // Release the options
83
+ Object.defineProperties(this, {
84
+ callbacks: {
85
+ configurable: true,
86
+ value: undefined,
87
+ writable: false
88
+ },
89
+ proxyOpts: {
90
+ configurable: true,
91
+ value: undefined,
92
+ writable: false
93
+ },
94
+ customHeaders: {
95
+ configurable: true,
96
+ value: undefined,
97
+ writable: false
98
+ }
99
+ });
100
+ });
101
+ };
102
+
103
+ /**
104
+ * Connects to a remote
105
+ *
106
+ * @async
107
+ * @param {Array} refSpecs The ref specs that should be pushed
108
+ * @param {FetchOptions} opts The fetch options for download, contains callbacks
109
+ * @param {Function} callback
110
+ * @return {Number} error code
111
+ */
112
+ Remote.prototype.download = function(refspecs, opts) {
113
+ return _download
114
+ .call(this, refspecs, normalizeFetchOptions(opts));
115
+ };
116
+
117
+ /**
118
+ * Connects to a remote
119
+ *
120
+ * @async
121
+ * @param {Array} refSpecs The ref specs that should be pushed
122
+ * @param {FetchOptions} opts The fetch options for download, contains callbacks
123
+ * @param {String} message The message to use for the update reflog messages
124
+ * @param {Function} callback
125
+ * @return {Number} error code
126
+ */
127
+ Remote.prototype.fetch = function(refspecs, opts, reflog_message) {
128
+ return _fetch
129
+ .call(this, refspecs, normalizeFetchOptions(opts), reflog_message);
130
+ };
131
+
132
+ /**
133
+ * Pushes to a remote
134
+ *
135
+ * @async
136
+ * @param {Array} refSpecs The ref specs that should be pushed
137
+ * @param {PushOptions} options Options for the checkout
138
+ * @param {Function} callback
139
+ * @return {Number} error code
140
+ */
141
+ Remote.prototype.push = function(refSpecs, opts) {
142
+ var callbacks;
143
+ var proxyOpts;
144
+
145
+ if (opts) {
146
+ opts = shallowClone(opts);
147
+ callbacks = opts.callbacks;
148
+ proxyOpts = opts.proxyOpts;
149
+ delete opts.callbacks;
150
+ delete opts.proxyOpts;
151
+ } else {
152
+ opts = {};
153
+ }
154
+
155
+ opts = normalizeOptions(opts, NodeGit.PushOptions);
156
+
157
+ if (callbacks) {
158
+ opts.callbacks =
159
+ normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
160
+ }
161
+
162
+ if (proxyOpts) {
163
+ opts.proxyOpts =
164
+ normalizeOptions(proxyOpts, NodeGit.ProxyOptions);
165
+ }
166
+
167
+ return _push.call(this, refSpecs, opts);
168
+ };
169
+
170
+ /**
171
+ * Lists advertised references from a remote. You must connect to the remote
172
+ * before using referenceList.
173
+ *
174
+ * @async
175
+ * @return {Promise<Array<RemoteHead>>} a list of the remote heads the remote
176
+ * had available at the last established
177
+ * connection.
178
+ *
179
+ */
180
+ Remote.prototype.referenceList = Remote.prototype.referenceList;
181
+
182
+ /**
183
+ * Update the tips to the new state
184
+ * @param {RemoteCallbacks} callbacks The callback functions for the connection
185
+ * @param {boolean} updateFetchhead whether to write to FETCH_HEAD. Pass true
186
+ * to behave like git.
187
+ * @param {boolean} downloadTags what the behaviour for downloading tags is
188
+ * for this fetch. This is ignored for push.
189
+ * This must be the same value passed to
190
+ * Remote.prototype.download
191
+ * @param {string} reflogMessage The message to insert into the reflogs. If
192
+ * null and fetching, the default is "fetch ",
193
+ * where is the name of the remote (or its url,
194
+ * for in-memory remotes). This parameter is
195
+ * ignored when pushing.
196
+ */
197
+ Remote.prototype.updateTips = function(
198
+ callbacks,
199
+ updateFetchhead,
200
+ downloadTags,
201
+ reflogMessage
202
+ ) {
203
+ if (callbacks) {
204
+ callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
205
+ }
206
+
207
+ return _updateTips.call(
208
+ this,
209
+ callbacks,
210
+ updateFetchhead,
211
+ downloadTags,
212
+ reflogMessage
213
+ );
214
+ };
215
+
216
+ /**
217
+ * Pushes to a remote
218
+ *
219
+ * @async
220
+ * @param {Array} refSpecs The ref specs that should be pushed
221
+ * @param {PushOptions} options Options for the checkout
222
+ * @param {Function} callback
223
+ * @return {Number} error code
224
+ */
225
+ Remote.prototype.upload = function(refSpecs, opts) {
226
+ var callbacks;
227
+ var proxyOpts;
228
+
229
+ if (opts) {
230
+ opts = shallowClone(opts);
231
+ callbacks = opts.callbacks;
232
+ proxyOpts = opts.proxyOpts;
233
+ delete opts.callbacks;
234
+ delete opts.proxyOpts;
235
+ } else {
236
+ opts = {};
237
+ }
238
+
239
+ opts = normalizeOptions(opts, NodeGit.PushOptions);
240
+
241
+ if (callbacks) {
242
+ opts.callbacks =
243
+ normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
244
+ }
245
+
246
+ if (proxyOpts) {
247
+ opts.proxyOpts =
248
+ normalizeOptions(proxyOpts, NodeGit.ProxyOptions);
249
+ }
250
+
251
+ return _upload.call(this, refSpecs, opts);
252
+ };
253
+
254
+ NodeGit.Remote.COMPLETION_TYPE = {};
255
+ var DEPRECATED_STATES = {
256
+ COMPLETION_DOWNLOAD: "DOWNLOAD",
257
+ COMPLETION_INDEXING: "INDEXING",
258
+ COMPLETION_ERROR: "ERROR"
259
+ };
260
+
261
+ Object.keys(DEPRECATED_STATES).forEach((key) => {
262
+ const newKey = DEPRECATED_STATES[key];
263
+ Object.defineProperty(NodeGit.Remote.COMPLETION_TYPE, key, {
264
+ get: util.deprecate(
265
+ () => NodeGit.Remote.COMPLETION[newKey],
266
+ `Use NodeGit.Remote.COMPLETION.${newKey} instead of ` +
267
+ `NodeGit.Remote.COMPLETION_TYPE.${key}.`
268
+ )
269
+ });
270
+ });