Add confirmation dialog to checkoutHead

There have been a few reports of files mysteriously going back to the
last version in the tree. My theory is that it is because of people
fat-fingering the Undo command because the default keyboard mapping is
too similar. This will at least prevent most accidental data loss.
This commit is contained in:
Lee Dohm
2014-08-03 14:39:38 -07:00
parent 8dffb45fd7
commit 8e649e3008

View File

@@ -436,8 +436,14 @@ class Editor extends Model
saveAs: (filePath) -> @buffer.saveAs(filePath)
checkoutHead: ->
if filePath = @getPath()
atom.project.getRepo()?.checkoutHead(filePath)
if (filePath = @getPath()) and (repo = atom.project.getRepo())
atom.confirm
message: "Are you sure you want to revert this file to the last Git commit?"
detailedMessage: "You are reverting: #{filePath}"
buttons:
"Revert": ->
repo.checkoutHead(filePath)
"Cancel": null
# Copies the current file path to the native clipboard.
copyPathToClipboard: ->