diff options
| author | Gubolin <gubolin@fantasymail.de> | 2014-09-12 14:42:43 +0200 |
|---|---|---|
| committer | Gubolin <gubolin@fantasymail.de> | 2014-09-12 14:42:43 +0200 |
| commit | b0276ea5bb8feb2c8d095574b9ed29bb6bbefe5c (patch) | |
| tree | 715ca00547833871d5e756227d0d802a48e8469a /github.js | |
| parent | 62f7c7afde5b7ea924b97c225fb5655c01d70d52 (diff) | |
| download | snap-b0276ea5bb8feb2c8d095574b9ed29bb6bbefe5c.tar.gz snap-b0276ea5bb8feb2c8d095574b9ed29bb6bbefe5c.zip | |
update octokit, fix a first-commit bug
Diffstat (limited to 'github.js')
| -rw-r--r-- | github.js | 52 |
1 files changed, 28 insertions, 24 deletions
@@ -27,8 +27,7 @@ // Global settings ///////////////////////////////////////////////////// -/*global modules, IDE_Morph, SnapSerializer, nop, -localize*/ +/*global modules, localize*/ modules.github = '2014-July-31'; @@ -40,7 +39,7 @@ var GitHub = new GitHubBackend(); // GitHubBackend ///////////////////////////////////////////////////////////// -function GitHubBackend(url) { +function GitHubBackend() { this.gh = null; this.username = null; this.password = null; // TODO saved as plain text @@ -163,40 +162,45 @@ GitHubBackend.prototype.saveProject = function (commitMessage, ide, callBack, er } }); + function pushChanges () { + if (myself.gh !== null) { + var repo = myself.gh.getRepo(myself.username, ide.projectName); + var branch = repo.getBranch(); // master (default) + var message = commitMessage; + + var contents = { + 'snap.xml': data, + 'README.md': ide.projectNotes + }; + + branch.writeMany(contents, message).then( + function () { + callBack.call(); + }, + function (error) { + errorCall.call(this, error, 'GitHub'); + } + ); + } + } + if (exists === false){ myself.gh.getUser().createRepo(repoName, { // these should be discussed - 'description': 'Snap! Project - http://snap.berkeley.edu/snapsource/snap.html#github:Username=' + myself.username + '&projectName=' + repoName, + 'description': 'Snap! Project - http://gubolin.github.io/snap/index.html#github:Username=' + myself.username + '&projectName=' + repoName, 'has_wiki': 'false', 'has_downloads': 'false', 'auto_init': true, 'license_template': 'mit' // discuss }).then( - function () {}, + pushChanges, function (error) { errorCall.call(this, error, 'GitHub'); } ); + } else { + pushChanges(); } - if (myself.gh !== null) { - var repo = myself.gh.getRepo(myself.username, ide.projectName); - var branch = repo.getBranch(); // master (default) - var message = commitMessage; - - var contents = { - 'snap.xml': data, - 'README.md': ide.projectNotes - }; - - branch.writeMany(contents, message).then( - function () { - callBack.call(); - }, - function (error) { - errorCall.call(this, error, 'GitHub'); - } - ); - } }, function (error) { errorCall.call(null, error, 'GitHub'); |
