forked from NeogitOrg/neogit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(NeogitOrg#23): keep commit message around if commit fails
Since the commit can fail for various reasons, we keep the commit message file after the user closes the buffer and only remove it after the commit was successful. Upon opening the commit buffer, we read the commit file's contents, if it exists, and present it as the suggested commit message
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
local uv = vim.loop | ||
local a = require('neogit.async') | ||
|
||
local wrapper = setmetatable({}, { | ||
__index = function (tbl, action) | ||
if uv[action] then | ||
return a.wrap(uv[action]) | ||
end | ||
|
||
return nil | ||
end | ||
}) | ||
|
||
wrapper.read_file = a.sync(function (file) | ||
local err, fd = a.wait(wrapper.fs_open(file, 'r', 438)) | ||
if err then return nil end | ||
local _, stat = a.wait(wrapper.fs_fstat(fd)) | ||
local _, data = a.wait(wrapper.fs_read(fd, stat.size, 0)) | ||
a.wait(wrapper.fs_close(fd)) | ||
return data | ||
end) | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters