Comments (8)
Hi @TimUntersberger , I would like to implement list
for stash.
I dug around source code and saw it already implemented here
neogit/lua/neogit/lib/git/stash.lua
Lines 108 to 110 in c0b1d4d
But I'm unsure as to how I'm supposed to link everything together. I'm not even sure if the list
command is for git stash list
. I did some basic preliminary work in this commit AlphabetsAlphabets@c9e8b55
from neogit.
Right on! So, you've got it right that git.stash.list()
will give you the raw data you need. To get it all wired up, you'll need to:
- Add the function to the stash popup actions file like you did in your fork, and pass it into the popup builder like all the other actions. In that action you'll open a new buffer, like we do here: https://github.com/NeogitOrg/neogit/blob/master/lua/neogit/popups/log/actions.lua#L36-L40
- Build a new buffer for the stash list. Take a look in https://github.com/NeogitOrg/neogit/tree/master/lua/neogit/buffers for how thats done. It'll have an
init.lua
andui.lua
file.
That's pretty much it at the high level. Here's a reference of how it looks in Magit, in case you're not familiar.
The reflog buffer has right-aligned virtual text, so you can use that as a reference on how to get the timestamp over there.
If you have any other questions, feel free to ping me here :)
Oh, and I'd recommend basing the work on the nightly
branch. It probably won't be a big deal, since I haven't messed with the stash stuff as far as I recall, but it wouldn't hurt.
from neogit.
@CKolkey thanks so much for the guidance 🙏. I'll get to work on this when I can.
from neogit.
@CKolkey I know you said I can ping you whenever I have questions so I'll do that. I'm only worried it'll get excessive is all 😅 anyways so here's my question.
I'm wondering how I can get the list
method to work when at the stash popup when all the options are displayed. I added actions.list
to the popup builder in stash/init.lua
but it's greyed out.
Right now, it's still greyed out. The reason I'm asking is because I'm not sure how I can test if what I've done so far is correct. I'm unsure of how to test my current progress to see if I'm on the right track.
https://github.com/AlphabetsAlphabets/neogit/blob/master/lua/neogit/popups/stash/actions.lua#L56-L58
Here, I'm wondering what's the purpose of the use
method. I get that I'll need to implement my own StashListBuffer
but do I need to use it together with use
? From what I gathered FuzzyFinderBuffer
is when you want to log a user's keypress for fuzzy finding. I'm thinking I can simply ignore use
and use StashListBuffer
instead.
This is the work I've manage to get done so far AlphabetsAlphabets@ea74fda
from neogit.
Hey hey - to get it to show up in the popup, you need to pass the function into the builder method as the last argument. Check out the others that have a action.*
as the last argument.
You won't need to use the use()
function, thats for CLI related stuff. list()
is opening a new buffer, so check out the other functions that launch a buffer. The fuzzy finder is an example of that, but you can also check out the log popup for examples :)
from neogit.
@CKolkey I've been trying to figure out why there are no changes to the UI despite me modifying the source. My only conclusion is that I missed something you said and I edited the wrong files. Also FYI I'm using rocks.nvim
but I don't think that should be an issue.
https://github.com/AlphabetsAlphabets/neogit/blob/master/lua/neogit/popups/stash/init.lua#L31
In here I added actions.list
to the action
call. But, when I restart Neogit, the option for list
is still greyed out.
I'm not sure if I missed something that you said. In the same file I linked, I deleted the "Transform" section to see if the UI would change but no, it didn't. It is still there.
local p = popup
.builder()
:name("NeogitStashPopup")
:group_heading("Stash")
:action("z", "both", actions.both)
:action("i", "index")
:action("w", "worktree")
:action("x", "keeping index")
:action("P", "push", actions.push)
:new_action_group("Snapshot")
:action("Z", "both")
:action("I", "index")
:action("W", "worktree")
:action("r", "to wip ref")
:new_action_group("Use")
:action("p", "pop", actions.pop)
:action("a", "apply", actions.apply)
:action("d", "drop", actions.drop)
:new_action_group("Inspect")
-- Only way to add functionality is to add `actions.list` to `stash/actions.lua`
:action("l", "List", actions.list)
:action("v", "Show")
:env({ stash = stash })
:build()
I removed the "Transform" section locally. It isn't pushed.
from neogit.
I also did some more work to create the workflow for git stash list
by adding some options to the buffer as well. I can't test it because of the issue mentioned above where changes I make have no effect. The work is done in this commit AlphabetsAlphabets@0556ef5
The reason it's different from how git log
handles it is because git stash list
has options you can provide. As far as I can tell, I haven't been able to find an operation in Neogit that requires you to selection an operation (like stash
) then a type (like list
) then options as well (like --follow
). The user may want git stash list
or git stash list --follow
.
That's why in my commit, I decided to close the popup that is made by Z
and then replacing it with options that git stash list
supports after the hits l
key. Once they have chosen option(s) to apply then a new tab will open which shows them the output of git stash list
filtered by whatever option they specified.
The reason I don't want to create a new tab immediately like for git log
is because as far as I can tell, all of the keybindings valid in the tab after :Neogit
works as well. I don't know how to use features like cherry picking from the tab generated by git log
from neogit.
neogit/lua/neogit/buffers/log_view/init.lua
Lines 48 to 55 in c0b1d4d
But from the lines I linked, the function to cherry pick from the new tab does exist. But may conflict with existing keybindings. This statement is based of the fact that when I was in the new tab, I can press c
and have the commit options appear and v
to have the revert options appear. But the more I think about it, I'm pretty sure that's just because of how LogViewBuffer
is implemented. I'm not very familiar with Lua and this code base is a lot more complex than I thought it would be. Maybe, I can have Neogit create a new tab, then have keybindings specific to StashViewBuffer
that'll apply options like --follow
.
So to summarize
- Close existing popup from
Z
. Then replace with options forgit stash list
then create a new tab. - Immediately list the output from
git stash list
in a new tab and have custom keybindings for that tab to enable flags like--follow
then refresh the buffer with the output filtered based on the options selected.
I'm pretty sure 2 is the better option though. Doesn't require re-inventing the wheel.
One more thing is regarding the complexity, are there any tips you would suggest for getting familiar with the code in general? Other than referencing similar code from files and reading the comments and things like that.
from neogit.
I'm not sure if I missed something that you said. In the same file I linked, I deleted the "Transform" section to see if the UI would change but no, it didn't. It is still there.
I'm not sure how rocks works entirely, but make sure it's using the codebase you're editing. A fast way to find out is to stick aerror("I got called")
at the top of a file, and if there's no error... you're not loading that file.
To your other points, we can always add more options to git stash list
later, for now I'd just get the basic case working. To that point, option 2 would be preferred.
You're right, its because of how the log buffer is implemented, but one of the key things about Magit, and Neogit, is that level of interactivity with everything in the buffers. So, all the popup menus would work the same everywhere, including the stash list. Fortunately, you can more or less just copy that over from the log buffer, since everything using the UI framework represents the data the same way internally. But all of those mapping can be added after you have the UI rendering something, so don't worry about that up front.
😓 I'm afraid I don't really have any tips for dealing with complex codebases besides read, read, read, and find common patterns. grep
ing for stuff is your friend, I use that a lot. And, mostly, practice. The more you practice familiarizing yourself with different codebases, the easier it gets.
from neogit.
Related Issues (20)
- Checked-out branches are not shown when listing branches in operations like merge, worktrees, etc.
- Invoking pull popup results in error HOT 3
- Merge conflict missing files HOT 1
- Allow flags (eg: --verbose commit) to be set globally HOT 6
- nowrap is set at startup on nightly HOT 2
- Some keymaps gets intercepted by neogit nightly HOT 1
- on nightly `:Neogit` fails to open in new git repo HOT 1
- `cwd` is changed to repository root on nightly HOT 4
- Tracking Issue: Status buffer bugs on `nightly` branch HOT 8
- Auto branch naming when fetching a remote branch HOT 3
- Neogit nightly commits are broken HOT 19
- Add support to goto hunk locations from commit view HOT 9
- Pushing should refresh status buffer HOT 1
- Ability to use normal mode when rewording a commit HOT 1
- Status Buffer: Actions that require a hunk/file do not work.
- Cannot discard an untracked file (neogit/lua/neogit/status.lua:1025: attempt to index field 'mode' (a nil value) HOT 2
- Neogit breaks on GPG commit signing password prompt HOT 5
- `b o` fails for github.com (${repository} incorrectly replaced) HOT 10
- Making a new branch should refresh the status buffer HOT 3
- Checkout local branch from popup stopped showing candidates in nightly HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neogit.