From c2520f490956c8757cb426ac243a142bbb4fed9e Mon Sep 17 00:00:00 2001 From: Daniel Hengeveld Date: Thu, 22 Oct 2015 15:42:42 +0200 Subject: [PATCH] Remove confirmation from git-repo-async to match git-repo cf https://github.com/atom/atom/commit/f9a269ed995c4151678aef787573fe44657e d6dd --- src/git-repository-async.js | 41 +++++++++++-------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/git-repository-async.js b/src/git-repository-async.js index 41ca6d05e..2f45a016a 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -90,36 +90,19 @@ module.exports = class GitRepositoryAsync { } checkoutHeadForEditor (editor) { - var filePath = editor.getPath() - if (!filePath) { - return Promise.reject('editor.filePath() is empty') - } - - var fileName = path.basename(filePath) - var checkoutHead = () => { - if (editor.buffer.isModified()) { - editor.buffer.reload() - } - return this.checkoutHead(filePath) - } - - var confirmCheckout = function () { - // This is bad tho - return Promise.resolve(atom.confirm({ - message: 'Confirm Checkout HEAD Revision', - detailedMessage: `Are you sure you want to discard all changes to "${fileName}" since the last Git commit?`, - buttons: { - OK: checkoutHead, - Cancel: null + return new Promise(function (resolve, reject) { + var filePath = editor.getPath() + if (filePath) { + if (editor.buffer.isModified()) { + editor.buffer.reload() } - })) - } - - if (atom.config.get('editor.confirmCheckoutHeadRevision')) { - return confirmCheckout() - } else { - return checkoutHead() - } + resolve(filePath) + } else { + reject() + } + }).then((filePath) => { + return this.checkoutHead(filePath) + }) } // Returns a Promise that resolves to the status bit of a given path if it has