-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for git stash list
#1280
Open
AlphabetsAlphabets
wants to merge
20
commits into
NeogitOrg:master
Choose a base branch
from
AlphabetsAlphabets:fork-master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
04fbcd4
wip(base): Building foundation for git stash list
AlphabetsAlphabets 17739b3
feat(stash): Link everything together
AlphabetsAlphabets df55c43
fix(stash_list_view): `M.open` to `M:open`
AlphabetsAlphabets 992cd3a
feat(config): Default from "split" to "tab"
AlphabetsAlphabets 6c00308
feat(stash): Cleaned up `M.list`
AlphabetsAlphabets c1ce446
feat(M.stash): Removed `after` argument
AlphabetsAlphabets b185356
wip(M.Stash): Building ui
AlphabetsAlphabets 12124b5
feat(buffer): change name of buffer
AlphabetsAlphabets 4ee97c0
wip(M.Stash): structure of UI elements
AlphabetsAlphabets 3b7fa9c
feat(M.stash): Moved to more appropriate location
AlphabetsAlphabets ff7c87b
fix(M.stash): Removed erroneous local
AlphabetsAlphabets a76789c
fix(cli calls): Removed CLI calls.
AlphabetsAlphabets b99080a
fix(draw): Updated drawing code
AlphabetsAlphabets 4098f2e
feat(return): Updated return to have info for stash list
AlphabetsAlphabets 1ef03c0
feat(clean): Removed unused variables and renamed variables
AlphabetsAlphabets 35c221e
feat(concat): Used format instead of `..` to concat strings
AlphabetsAlphabets 3d6c898
wip(view_stash): Passing oid to CommitViewBuffer
AlphabetsAlphabets 76bc6bb
feat(whitespace): Removed erroenous whitespace causing
AlphabetsAlphabets bd37ec2
Merge branch 'NeogitOrg:master' into fork-master
AlphabetsAlphabets 812a8c4
Merge branch 'master' into fork-master
AlphabetsAlphabets File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,60 @@ | ||
local Buffer = require("neogit.lib.buffer") | ||
local config = require("neogit.config") | ||
local CommitViewBuffer = require("neogit.buffers.commit_view") | ||
|
||
local git = require("neogit.lib.git") | ||
local ui = require("neogit.buffers.stash_list_view.ui") | ||
|
||
---@class StashListBuffer | ||
---@field stashes StashEntry[] | ||
local M = {} | ||
M.__index = M | ||
|
||
--- Gets all current stashes | ||
function M.new(stashes) | ||
local instance = { | ||
stashes = stashes, | ||
} | ||
|
||
setmetatable(instance, M) | ||
return instance | ||
end | ||
|
||
function M:close() | ||
self.buffer:close() | ||
self.buffer = nil | ||
end | ||
|
||
--- Creates a buffer populated with output of `git stash list` | ||
--- and supports related operations. | ||
function M:open() | ||
self.buffer = Buffer.create { | ||
name = "NeogitStashView", | ||
filetype = "NeogitStashView", | ||
kind = config.values.stash.kind, | ||
context_higlight = true, | ||
-- Define the available mappings here. `git stash list` has the same options | ||
-- as `git log` refer to git-log(1) for more info. | ||
mappings = { | ||
n = { | ||
["q"] = function() | ||
self:close() | ||
end, | ||
["<esc>"] = function() | ||
self:close() | ||
end, | ||
["<enter>"] = function() | ||
CommitViewBuffer.new(git.rev_parse.oid(self.buffer.ui:get_commit_under_cursor())):open("tab") | ||
end, | ||
} | ||
}, | ||
after = function() | ||
vim.cmd([[setlocal nowrap]]) | ||
end, | ||
render = function() | ||
return ui.View(self.stashes) | ||
end, | ||
} | ||
end | ||
|
||
return M |
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,36 @@ | ||
local Ui = require("neogit.lib.ui") | ||
local Component = require("neogit.lib.ui.component") | ||
local util = require("neogit.lib.util") | ||
|
||
local text = Ui.text | ||
local col = Ui.col | ||
local row = Ui.row | ||
|
||
local M = {} | ||
|
||
---Parses output of `git stash list` and splits elements into table | ||
M.Stash = Component.new(function(stash) | ||
local label = table.concat({"stash@{", stash.idx, "}" }, "") | ||
return col({ | ||
row({ | ||
text.highlight("Comment")(label), | ||
text(" "), | ||
text(stash.message), | ||
}, { | ||
virtual_text = { | ||
{ " ", "Constant" }, | ||
{ stash.rel_date, "Special" }, | ||
}, | ||
}), | ||
}, { oid = label }) | ||
end) | ||
|
||
---@param stashes StashEntry[] | ||
---@return table | ||
function M.View(stashes) | ||
return util.map(stashes, function(stash) | ||
return M.Stash(stash) | ||
end) | ||
end | ||
|
||
return M |
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.