11var NodeGit = require ( "../" ) ;
2+ var normalizeFetchOptions = NodeGit . Utils . normalizeFetchOptions ;
23var normalizeOptions = NodeGit . Utils . normalizeOptions ;
34var lookupWrapper = NodeGit . Utils . lookupWrapper ;
45var shallowClone = NodeGit . Utils . shallowClone ;
@@ -8,6 +9,7 @@ var _connect = Remote.prototype.connect;
89var _download = Remote . prototype . download ;
910var _fetch = Remote . prototype . fetch ;
1011var _push = Remote . prototype . push ;
12+ var _upload = Remote . prototype . upload ;
1113
1214/**
1315 * Retrieves the remote by name
@@ -53,24 +55,8 @@ Remote.prototype.connect = function(
5355 * @return {Number } error code
5456 */
5557Remote . prototype . download = function ( refspecs , opts ) {
56- var callbacks ;
57-
58- if ( opts ) {
59- opts = shallowClone ( opts ) ;
60- callbacks = opts . callbacks ;
61- delete opts . callbacks ;
62- } else {
63- opts = { } ;
64- }
65-
66- opts = normalizeOptions ( opts , NodeGit . FetchOptions ) ;
67-
68- if ( callbacks ) {
69- opts . callbacks =
70- normalizeOptions ( callbacks , NodeGit . RemoteCallbacks ) ;
71- }
72-
73- return _download . call ( this , refspecs , opts ) ;
58+ return _download
59+ . call ( this , refspecs , normalizeFetchOptions ( opts ) ) ;
7460} ;
7561
7662/**
@@ -84,24 +70,61 @@ Remote.prototype.download = function(refspecs, opts) {
8470 * @return {Number } error code
8571 */
8672Remote . 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 ) {
8787 var callbacks ;
88+ var proxyOpts ;
8889
8990 if ( opts ) {
9091 opts = shallowClone ( opts ) ;
9192 callbacks = opts . callbacks ;
93+ proxyOpts = opts . proxyOpts ;
9294 delete opts . callbacks ;
95+ delete opts . proxyOpts ;
9396 } else {
9497 opts = { } ;
9598 }
9699
97- opts = normalizeOptions ( opts , NodeGit . FetchOptions ) ;
100+ opts = normalizeOptions ( opts , NodeGit . PushOptions ) ;
98101
99102 if ( callbacks ) {
100103 opts . callbacks =
101104 normalizeOptions ( callbacks , NodeGit . RemoteCallbacks ) ;
102105 }
103106
104- return _fetch . call ( this , refspecs , opts , reflog_message ) ;
107+ if ( proxyOpts ) {
108+ opts . proxyOpts =
109+ normalizeOptions ( proxyOpts , NodeGit . ProxyOptions ) ;
110+ }
111+
112+ return _push . call ( this , refSpecs , opts ) ;
113+ } ;
114+
115+ /**
116+ * Connects to a remote
117+ *
118+ * @async
119+ * @param {Array } refSpecs The ref specs that should be pushed
120+ * @param {FetchOptions } opts The fetch options for download, contains callbacks
121+ * @param {String } message The message to use for the update reflog messages
122+ * @param {Function } callback
123+ * @return {Number } error code
124+ */
125+ Remote . prototype . fetch = function ( refspecs , opts , reflog_message ) {
126+ return _fetch
127+ . call ( this , refspecs , normalizeFetchOptions ( opts ) , reflog_message ) ;
105128} ;
106129
107130/**
@@ -113,12 +136,16 @@ Remote.prototype.fetch = function(refspecs, opts, reflog_message) {
113136 * @param {Function } callback
114137 * @return {Number } error code
115138 */
116- Remote . prototype . push = function ( refSpecs , opts ) {
139+ Remote . prototype . upload = function ( refSpecs , opts ) {
117140 var callbacks ;
141+ var proxyOpts ;
142+
118143 if ( opts ) {
119144 opts = shallowClone ( opts ) ;
120145 callbacks = opts . callbacks ;
146+ proxyOpts = opts . proxyOpts ;
121147 delete opts . callbacks ;
148+ delete opts . proxyOpts ;
122149 } else {
123150 opts = { } ;
124151 }
@@ -130,5 +157,10 @@ Remote.prototype.push = function(refSpecs, opts) {
130157 normalizeOptions ( callbacks , NodeGit . RemoteCallbacks ) ;
131158 }
132159
133- 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 ) ;
134166} ;
0 commit comments