lib/repo.js
function repoSha (options, callback) {
  var user = options.user
  var repo = options.repo
  var path = options.path || null
  var branch = options.branch || 'master'
  var token = options.token || null

  if (!user || !repo || !path) {
    return callback(new Error('must specify user, repo, path'))
  }

  var url = '/repos/' + user + '/' + repo + '/contents/' + path

  request({
    url: url,
    qs: {
      access_token: token,
      ref: branch
    }
  }, function (err, json) {
    if (err) return callback(err)
    if (json.message) return callback(new Error(json.message))
    if (json.sha) return callback(null, json.sha)
    callback(new Error('could not get sha for ' + url))
  })
}
function repoSha (options, callback) {
  var user = options.user
  var repo = options.repo
  var path = options.path || null
  var branch = options.branch || 'master'
  var token = options.token || null

  if (!user || !repo || !path) {
    return callback(new Error('must specify user, repo, path'))
  }

  var url = '/repos/' + user + '/' + repo + '/contents/' + path

  request({
    url: url,
    qs: {
      access_token: token,
      ref: branch
    }
  }, function (err, json) {
    if (err) return callback(err)
    if (json.message) return callback(new Error(json.message))
    if (json.sha) return callback(null, json.sha)
    callback(new Error('could not get sha for ' + url))
  })
}
function repoSha ( options , callback ) { var user = options . user var repo = options . repo var path = options . path || null var branch = options . branch || 'master' var token = options . token || null if ( ! user || ! repo || ! path ) { return callback ( new Error ( 'must specify user, repo, path' ) ) } var url = '/repos/' + user + '/' + repo + '/contents/' + path request ( { url : url , qs : { access_token : token , ref : branch } } , function ( err , json ) { if ( err ) return callback ( err ) if ( json . message ) return callback ( new Error ( json . message ) ) if ( json . sha ) return callback ( null , json . sha ) callback ( new Error ( 'could not get sha for ' + url ) ) } ) }
get the SHA of a file in a github repository

@param  {object}   options - user, repo, path (optional), branch (optional), token (optional)
@param  {Function} callback - err, sha
get the SHA of a file in a github repository