FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remote needs to REALLY persist the callback/proxyOpts/headers · dbroadhurst/nodegit@d5ad62c · GitHub

Repository navigation

Commit d5ad62c

Browse files
Remote needs to REALLY persist the callback/proxyOpts/headers
1 parent 69b010a commit d5ad62c

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

‎lib/remote.js‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var shallowClone = NodeGit.Utils.shallowClone;
88
var Remote = NodeGit.Remote;
99
var _connect = Remote.prototype.connect;
1010
var _createWithOpts = Remote.createWithOpts;
11+
var _disconnect = Remote.prototype.disconnect;
1112
var _download = Remote.prototype.download;
1213
var _fetch = Remote.prototype.fetch;
1314
var _push = Remote.prototype.push;
@@ -45,14 +46,60 @@ Remote.prototype.connect = function(
4546
proxyOpts = normalizeOptions(proxyOpts || {}, NodeGit.ProxyOptions);
4647
customHeaders = customHeaders || [];
4748

48-
return _connect.call(this, direction, callbacks, proxyOpts, customHeaders);
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+
});
4972
};
5073

5174
Remote.createWithOpts = function(url, options) {
5275
return _createWithOpts(url, normalizeOptions(
5376
options, NodeGit.RemoteCreateOptions));
5477
};
5578

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+
56103
/**
57104
* Connects to a remote
58105
*

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL