Skip to content

Instantly share code, notes, and snippets.

@marcsolanadal
Created December 3, 2015 12:47
Show Gist options
  • Save marcsolanadal/b50a30d6061aaa99b872 to your computer and use it in GitHub Desktop.
Save marcsolanadal/b50a30d6061aaa99b872 to your computer and use it in GitHub Desktop.
/**
* Creates a new git repo on Stash using their API
*
* @method createStashRepo
* @param {string} repoName Name of the repo to create
* @returns {promise}
*/
createStashRepo: function (repoName) {
var repoOptions = {
"name": repoName,
"scmId": "git"
};
var defer = q.defer();
console.log('Creating repo with name ' + repoName);
restler.postJson(settings.git.urlApi, repoOptions, this.authHeader)
.on('success', function (res) {
//defer.resolve(res.cloneUrl);
// get the ssh url
var index = _.findIndex(res.links.clone, {'name': 'ssh'}),
href = res.links.clone[index].href;
// TODO: Remove when Stash ssh access solved
href = href.replace('git.atsistemas.com', '192.168.1.220');
defer.resolve(href);
})
.on('fail', defer.reject);
return defer.promise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment