diff --git a/doc/notes.txt b/doc/notes.txt index e7314257..1754edd8 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -155,7 +155,6 @@ TODO: - local/ files in repository? - build ca65 projects w/ no crt0? https://github.com/pinobatch/thwaite-nes/blob/master/makefile - switching platform of a repo? - - should have a preview of commit WEB WORKER FORMAT diff --git a/src/ui.ts b/src/ui.ts index e6277f27..8ec88b0d 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -307,7 +307,7 @@ function _createNewFile(e) { getSkeletonFile(path).then( (result) => { return store.setItem(path, result || "\n"); }).then(() => { - reloadProject("local/" + filename); + reloadProject(path); }); } } @@ -509,6 +509,35 @@ function _pullProjectFromGithub(e) { }); } +function confirmCommit(sess) : Promise { + return new Promise( (resolve, reject) => { + var files = sess.commit.files; + console.log(files); + // anything changed? + if (files.length == 0) { + setWaitDialog(false); + bootbox.alert("No files changed."); + } + // build commit confirm message + var msg = ""; + for (var f of files) { + msg += f.filename + ": " + f.status; + if (f.additions || f.deletions || f.changes) { + msg += " (" + f.additions + " additions, " + f.deletions + " deletions, " + f.changes + " changes)"; + } + msg += "
"; + } + // show dialog, continue when yes + bootbox.confirm(msg, (ok) => { + if (ok) { + resolve(sess); + } else { + setWaitDialog(false); + } + }); + }); +} + function pushChangesToGithub(message:string) { var ghurl = getBoundGithubURL(); if (!ghurl) return; @@ -526,6 +555,8 @@ function pushChangesToGithub(message:string) { return getGithubService().login().then( () => { setWaitProgress(0.5); return getGithubService().commit(ghurl, message, files); + }).then( (sess) => { + return confirmCommit(sess); }).then( (sess) => { return getGithubService().push(sess); }).then( (sess) => { diff --git a/test/cli/testgithub.js b/test/cli/testgithub.js index 3c254468..eb587216 100644 --- a/test/cli/testgithub.js +++ b/test/cli/testgithub.js @@ -107,13 +107,14 @@ describe('Store', function() { for (var i=0; i<256; i++) binfile[i] = i; var files = [ - {path:'text.txt', data:'hello world ' + Math.random()}, + {path:'text.txt', data:'hello world'}, {path:'data.bin', data:binfile} ]; gh.commit('https://github.com/pzpinfo/testrepo3', 'test commit', files).then( (sess) => { return gh.push(sess); }).then( (sess) => { console.log(sess.commit); + assert.equal(0, sess.commit.files.length); done(); }); });