@@ -9,6 +9,7 @@ var _connect = Remote.prototype.connect;
99var _download = Remote . prototype . download ;
1010var _fetch = Remote . prototype . fetch ;
1111var _push = Remote . prototype . push ;
12+ var _upload = Remote . prototype . upload ;
1213
1314/**
1415 * Retrieves the remote by name
@@ -54,24 +55,61 @@ Remote.prototype.connect = function(
5455 * @return {Number } error code
5556 */
5657Remote . prototype . download = function ( refspecs , opts ) {
58+ return _download
59+ . call ( this , refspecs , normalizeFetchOptions ( opts ) ) ;
60+ } ;
61+
62+ /**
63+ * Connects to a remote
64+ *
65+ * @async
66+ * @param {Array } refSpecs The ref specs that should be pushed
67+ * @param {FetchOptions } opts The fetch options for download, contains callbacks
68+ * @param {String } message The message to use for the update reflog messages
69+ * @param {Function } callback
70+ * @return {Number } error code
71+ */
72+ Remote . prototype . fetch = function ( refspecs , opts , reflog_message ) {
73+ return _fetch
74+ . call ( this , refspecs , normalizeFetchOptions ( opts ) , reflog_message ) ;
75+ } ;
76+
77+ /**
78+ * Pushes to a remote
79+ *
80+ * @async
81+ * @param {Array } refSpecs The ref specs that should be pushed
82+ * @param {PushOptions } options Options for the checkout
83+ * @param {Function } callback
84+ * @return {Number } error code
85+ */
86+ Remote . prototype . push = function ( refSpecs , opts ) {
5787 var callbacks ;
88+ var proxyOpts ;
5889
5990 if ( opts ) {
6091 opts = shallowClone ( opts ) ;
6192 callbacks = opts . callbacks ;
93+ proxyOpts = opts . proxyOpts ;
6294 delete opts . callbacks ;
95+ delete opts . proxyOpts ;
6396 } else {
6497 opts = { } ;
6598 }
6699
67- opts = normalizeOptions ( opts , NodeGit . FetchOptions ) ;
100+ opts = normalizeOptions ( opts , NodeGit . PushOptions ) ;
68101
69102 if ( callbacks ) {
70103 opts . callbacks =
71104 normalizeOptions ( callbacks , NodeGit . RemoteCallbacks ) ;
72105 }
73106
74- return _download . call ( this , refspecs , opts ) ;
107+ if ( proxyOpts ) {
108+ opts . proxyOpts =
109+ normalizeOptions ( proxyOpts , NodeGit . ProxyOptions ) ;
110+ }
111+
112+ return _push . call ( this , refSpecs , opts ) ;
75113} ;
76114
77115/**
@@ -85,7 +123,8 @@ Remote.prototype.download = function(refspecs, opts) {
85123 * @return {Number } error code
86124 */
87125Remote . prototype . fetch = function ( refspecs , opts , reflog_message ) {
88- return _fetch . call ( this , refspecs , normalizeFetchOptions ( opts ) , reflog_message ) ;
126+ return _fetch
127+ . call ( this , refspecs , normalizeFetchOptions ( opts ) , reflog_message ) ;
89128} ;
90129
91130/**
@@ -97,12 +136,16 @@ Remote.prototype.fetch = function(refspecs, opts, reflog_message) {
97136 * @param {Function } callback
98137 * @return {Number } error code
99138 */
100- Remote . prototype . push = function ( refSpecs , opts ) {
139+ Remote . prototype . upload = function ( refSpecs , opts ) {
101140 var callbacks ;
141+ var proxyOpts ;
142+
102143 if ( opts ) {
103144 opts = shallowClone ( opts ) ;
104145 callbacks = opts . callbacks ;
146+ proxyOpts = opts . proxyOpts ;
105147 delete opts . callbacks ;
148+ delete opts . proxyOpts ;
106149 } else {
107150 opts = { } ;
108151 }
@@ -114,5 +157,10 @@ Remote.prototype.push = function(refSpecs, opts) {
114157 normalizeOptions ( callbacks , NodeGit . RemoteCallbacks ) ;
115158 }
116159
117- return _push . call ( this , refSpecs , opts ) ;
160+ if ( proxyOpts ) {
161+ opts . proxyOpts =
162+ normalizeOptions ( proxyOpts , NodeGit . ProxyOptions ) ;
163+ }
164+
165+ return _upload . call ( this , refSpecs , opts ) ;
118166} ;
0 commit comments