Skip to content

Commit

Permalink
Add repo.checkoutFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian Schüßler committed Jun 19, 2014
1 parent 3ec8ed9 commit b1d4cdf
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/repo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = class Repo
#
# # Skip some (for pagination):
# repo.commits "master", 30, 30, (err, commits) ->
#
#
# # Do not limit commits amount
# repo.commits "master", -1, (err, commits) ->
#
Expand All @@ -93,21 +93,21 @@ module.exports = class Repo
Commit.find_all this, start, options, callback


# Internal: Returns current commit id
#
# Internal: Returns current commit id
#
# callback - Receives `(err, id)`.
#
#
current_commit_id: (callback) ->
@git "rev-parse HEAD", {}, []
, (err, stdout, stderr) =>
return callback err if err
return callback null, _.first stdout.split "\n"


# Public:
#
# Public:
#
# callback - Receives `(err, commit)`
#
#
current_commit: (callback) ->
@current_commit_id (err, commit_id) =>
return callback err if err
Expand Down Expand Up @@ -241,7 +241,7 @@ module.exports = class Repo
status: (callback) ->
return Status(this, callback)

# Public: Show information about files in the index and the
# Public: Show information about files in the index and the
# working tree.
#
# options - An Object of command line arguments to pass to
Expand Down Expand Up @@ -333,6 +333,19 @@ module.exports = class Repo
checkout: (treeish, callback) ->
@git "checkout", {}, treeish, callback

# Public: Checkout file(s) to the index
#
# files - Array of String paths; or a String path. If you want to
# checkout all files pass '.'.
# options - Object (optional).
# "force" - Boolean
# callback - Receives `(err)`.
#
checkoutFile: (files, options, callback) ->
[options, callback] = [callback, options] if !callback
options ?= {}
files = [files] if _.isString files
@git "checkout", options, _.flatten['--', files], callback

# Public: Commit some code.
#
Expand All @@ -357,13 +370,13 @@ module.exports = class Repo
# options - Object (optional).
# "all" - Boolean
# callback - Receives `(err)`.
#
#
add: (files, options, callback) ->
[options, callback] = [callback, options] if !callback
options ?= {}
files = [files] if _.isString files
@git "add", options, files, callback

# Public: Remove files from the index.
#
# files - Array of String paths; or a String path.
Expand Down Expand Up @@ -411,7 +424,7 @@ module.exports = class Repo
return callback null
else
return callback null

# Public: Pull the remotes from the master.
#
# Arguments: ([[remote_name, ]branch_name, ]callback)
Expand All @@ -432,9 +445,9 @@ module.exports = class Repo
@git "pull", {}, [remote, branch], (err, stdout, stderr) =>
return callback stderr if err
return callback null

# Internal: Parse the list of files from `git ls-files`
#
#
# Return Files[]
parse_lsFiles: (text,options) ->
files = []
Expand Down

0 comments on commit b1d4cdf

Please sign in to comment.