From 06bacc9217f8a4e8d786ada582413b62d5c3ec41 Mon Sep 17 00:00:00 2001 From: Andrew Crites Date: Wed, 30 Jul 2014 11:44:28 -0400 Subject: [PATCH] Allow options to be specified for fetch, push, and merge operations This minimally allows for force fetch and push --- README.md | 7 +++++-- src/repo.coffee | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cc6ebd0..46d725a 100644 --- a/README.md +++ b/README.md @@ -118,15 +118,18 @@ Equivalent to `git remote add `. ### `Repo#remote_remove(name, callback)` Remove a remote. -### `Repo#remote_fetch(name, callback)` +### `Repo#remote_fetch(name, [options, ]callback)` `git fetch ` -### `Repo#remote_push(name, [branch, ]callback)` +### `Repo#remote_push(name, [branch, options, ]callback)` `git push ` with branch parameter specified: `git push ` +### `Repo#merge(name, [options, ]callback)` +`git merge ` + ### `Repo#status(callback)` Uses `--porcelain` to parse repository status in a way that is agnostic of system language. The callback receives `(err, status)`. See below for a definition of what `status` is. diff --git a/src/repo.coffee b/src/repo.coffee index 983a490..d916d8c 100644 --- a/src/repo.coffee +++ b/src/repo.coffee @@ -202,8 +202,10 @@ module.exports = class Repo # name - String name of the remote # callback - Receives `(err)`. # - remote_fetch: (name, callback) -> - @git "fetch", {}, name + remote_fetch: (name, options, callback) -> + [options, callback] = [callback, options] if !callback + + @git "fetch", options, name , (err, stdout, stderr) -> callback err @@ -213,14 +215,18 @@ module.exports = class Repo # branch - (optional) Branch to push # callback - Receives `(err)`. # - remote_push: (name, branch, callback) -> - if !callback + remote_push: (name, branch, options, callback) -> + if !options && !callback callback = branch args = name + options = {} else + if !callback + callback = options + options = {} args = [name, branch] - @git "push", {}, args + @git "push", options, args , (err, stdout, stderr) -> callback err @@ -229,8 +235,10 @@ module.exports = class Repo # name - String name of the source # callback - Receives `(err)`. # - merge: (name, callback) -> - @git "merge", {}, name + merge: (name, options, callback) -> + [options, callback] = [callback, options] if !callback + + @git "merge", options, name , (err, stdout, stderr) -> callback err