packer.nvim icon indicating copy to clipboard operation
packer.nvim copied to clipboard

Last plugin update diff

Open pedro757 opened this issue 4 years ago • 8 comments

A really cool feature I don't see in this plugin manager yet is to have the ability to get the last update diff, if I close that floating window I won't know what has been changed in my plugins

image

Other plugin manager like vim-plug do have the ability, with :PlugDIff so I can see what changes are introduced to the plugins even if i close the window or the entire vim process

pedro757 avatar Oct 19 '21 13:10 pedro757

This has been requested previously (https://github.com/wbthomason/packer.nvim/discussions/653 and some other issues). I'm happy to help guide a PR to add this, but I don't have the bandwidth to prioritize implementing it myself right now.

A reasonable starting point might be looking at the git commands that vim-plug uses for PlugDiff, and in particular how it determines what the commit before the last update was. Then, we already have logic in display.lua and git.lua for running git commands and displaying a plugin's diff (either the log of commits or the set of changed lines) in the results window. Once we know which two commits we need to compare, we should be able to mostly reuse this logic to display a diff after the results window has closed.

wbthomason avatar Oct 19 '21 22:10 wbthomason

@gegoune has also been interested in this feature

wbthomason avatar Oct 19 '21 22:10 wbthomason

I checked vim-plug :PlugDiff It runs this command for every plugin directory:

git log --graph --color=never --pretty=format:%x01%h%x01%d%x01%s%x01%cr HEAD@{1}..

I just went into a plugin directory in ~/.local/share/nvim/site/pack/packer/start/ and ran that command, it works, it prints the last pulled commits, Try it!, The command change a bit when using different branches

What do you think? @wbthomason @gegoune

pedro757 avatar Nov 08 '21 19:11 pedro757

I thought I would try to look into this and submit a PR. But I was thinking about doing it a bit differently so wanted to check what @wbthomason and others think first.

Rather than showing diffs after update I thought we can (optionally) show them before, by first doing a fetch and a diff between local and remote. The user can then choose to continue or not. This would have a similar behaviour to eg yay (AUR helper).

Any thoughts?

AckslD avatar Jul 04 '22 07:07 AckslD

@AckslD that sounds really cool and like something that packer has been sorely missing. This way, users can opt into changes before potentially allowing breaking changes through. Not sure what @wbthomason will think, but this sounds cool.

Would also be good to be able to refer back to any of the most recent updates changes, which I think was the original request in this issue

akinsho avatar Jul 04 '22 08:07 akinsho

Cool, I'll try something out and let you know when I have a (draft) PR ready :)

Would also be good to be able to refer back to any of the most recent updates changes, which I think was the original request in this issue

Sounds good, I guess that can in principle be an independent feature?

AckslD avatar Jul 04 '22 11:07 AckslD

@AckslD agreed that it's probably a separate feature but to be clear it seems that that is what this particular issue is about. I think what you are suggesting whilst desirable is actually separate to this issue but welcome feature IMO than what the OP is describing.

akinsho avatar Jul 04 '22 13:07 akinsho

Yes agreed :)

AckslD avatar Jul 04 '22 15:07 AckslD