var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var lookupWrapper = require("./util/lookupWrapper");

var Remote = NodeGit.Remote;
var setCallbacks = Remote.prototype.setCallbacks;

/**
 * Retrieves the remote by name
 * @async
 * @param {Repository} repo The repo that the remote lives in
 * @param {String|Remote} name The remote to lookup
 * @param {Function} callback
 * @return {Remote}
 */
Remote.lookup = lookupWrapper(Remote);

Remote.prototype.setCallbacks = function(callbacks) {
  callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);

  return setCallbacks.call(this, callbacks);
};

module.exports = Remote;

var NodeGit = require("../");
var normalizeOptions = require("./util/normalize_options");
var lookupWrapper = require("./util/lookupWrapper");

var Remote = NodeGit.Remote;
var setCallbacks = Remote.prototype.setCallbacks;
var push = Remote.push;

/**
 * Retrieves the remote by name
 * @async
 * @param {Repository} repo The repo that the remote lives in
 * @param {String|Remote} name The remote to lookup
 * @param {Function} callback
 * @return {Remote}
 */
Remote.lookup = lookupWrapper(Remote);

Remote.prototype.setCallbacks = function(callbacks) {
  callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);

  return setCallbacks.call(this, callbacks);
};

/**
 * Pushes to a remote
 *
 * @async
 * @param {Array} refSpecs The ref specs that should be pushed
 * @param {PushOptions} options Options for the checkout
 * @param {Signature} signature The identity to use for the reflog of the
 * updated references
 * @param {String} message The message to use for the update reflog messages
 * @return {Number} error code
 */
Remote.push = function(refSpecs, options, signature, message) {
  options = normalizeOptions(options, NodeGit.PushOptions);

  return push.call(this, refSpecs, options, signature, message);
};

module.exports = Remote;

Normalize the remote push options