wbthomason / packer.nvim

A use-package inspired plugin manager for Neovim. Uses native packages, supports Luarocks dependencies, written in Lua, allows for expressive config
MIT License
7.75k stars 261 forks source link

feat(git): support showing diff of range of commits #1034

Closed AckslD closed 1 year ago

AckslD commented 1 year ago

If there is a range of commits, eg 00cba85..116a568 then the diff no longer only shows the diff of the first commit but of the whole range. Currently this shows the diff for each commit and not the total diff from the first to the last but that can be configured by the user with a different command.

@akinsho, I think you initially implemented this so maybe you'd be interested and I'm happy to hear any thoughts.

akinsho commented 1 year ago

@AckslD can you confirm that you've tested this out locally and it works in different scenarios .e.g single and multiple commits?

AckslD commented 1 year ago

@akinsho yes I have

akinsho commented 1 year ago

Cool, thanks for clarifying. I've merged a few PRs in the last few weeks that have had a lot of follow-up bugs and I won't have time to test this very thoroughly, but the change looks good to me

AckslD commented 1 year ago

Thanks for checking! Is there someone else who could review further if you're busy?

akinsho commented 1 year ago

Think Wil is quite busy, not sure but I might have time in the following days. Will try to get through your open PRs

akinsho commented 1 year ago

I guess this can be quite easily tested by just reverted a plugin back a few commits and seeing that the diff shows multiple commits

AckslD commented 1 year ago

Thanks, also no rush so take your time :)

Yeah, I wrote a small bash script which resets three of my plugins and then runs neovim and directly updates all plugins. This was very useful for quickly checking things.

Something like this:

(cd ~/.local/share/nvim/site/pack/packer/opt/nvim-treesitter-refactor && git reset --hard origin/repeat-smart-rename~1)
(cd ~/.local/share/nvim/site/pack/packer/opt/nvim-pytrize.lua && git reset --hard origin/dev~2)
(cd ~/.local/share/nvim/site/pack/packer/opt/nvim-dap && git reset --hard 0.1.0)

nvim +'lua require("packer").update()'
akinsho commented 1 year ago

@AckslD I just tested this out and got some strange results using plenary.nvim, I manually reset it back 3 commits and then hovered over the plugin name after running packer sync and the diff was making reference to https://github.com/nvim-lua/plenary.nvim/commit/31807eef4ed574854b8a53ae40ea3292033a78ea i.e. the commit I was on before the update, rather than showing me a preview of all 3 new commits. With my cursor on each commit separately this worked as expected

AckslD commented 1 year ago

@akinsho hmm, do you have any custom git settings? For me I get

 ✓ Updated nvim-lua/plenary.nvim: 31807ee..a3dafaa
  URL: https://github.com/nvim-lua/plenary.nvim
  Commits:
    a3dafaa feat: add svelte and astro filetype (#398) (5 days ago)
    9e6a153 docs: add instructions on how to run tests (#397) (5 days ago)
    92e6605 docs: minor changes to README.md (#399) (5 days ago)

after reseting three commits back and updating. Then if I press d on the first line I get:

commit a3dafaa937921a4eb2ae65820c3479ab561e9ba3
Author: Joohoon Cha <joocha0713@gmail.com>
Date:   Fri Aug 26 04:54:28 2022 -0700

    feat: add svelte and astro filetype (#398)

diff --git a/data/plenary/filetypes/builtin.lua b/data/plenary/filetypes/builtin.lua
index 57ef560..a8aaaa3 100644
--- a/data/plenary/filetypes/builtin.lua
+++ b/data/plenary/filetypes/builtin.lua
@@ -20,32 +20,34 @@ end
 return {
   extension = {
     ['_coffee'] = 'coffee',
-    ['coffee'] = 'coffee',
+    ['astro'] = 'astro',
     ['cljd'] = 'clojure',
+    ['coffee'] = 'coffee',
     ['dart'] = 'dart',
+    ['erb'] = 'eruby',
     ['ex'] = 'elixir',
     ['exs'] = 'elixir',
-    ['erb'] = 'eruby',
-    ['tres'] = 'gdresource',
-    ['tscn'] = 'gdresource',
-    ['gd'] = 'gdscript',
     ['fnl'] = 'fennel',
+    ['gd'] = 'gdscript',
     ['gql'] = 'graphql',
-    ['graphql'] = 'graphql',
     ['gradle'] = 'groovy',
+    ['graphql'] = 'graphql',
     ['hbs'] = 'handlebars',
     ['hdbs'] = 'handlebars',
     ['janet'] = 'janet',
-    ['jsx'] = 'javascriptreact',
     ['jl'] = 'julia',
+    ['jsx'] = 'javascriptreact',
     ['kt'] = 'kotlin',
     ['nix'] = 'nix',
+    ['plist'] = 'xml',
     ['purs'] = 'purescript',
-    ['rkt'] = 'racket',
     ['res'] = 'rescript',
     ['resi'] = 'rescript',
+    ['rkt'] = 'racket',
+    ['svelte'] = 'svelte',
+    ['tres'] = 'gdresource',
+    ['tscn'] = 'gdresource',
     ['tsx'] = 'typescriptreact',
-    ['plist'] = 'xml',
   },
   file_name = {
     ['cakefile'] = 'coffee',
commit 9e6a153d9a6438a8bafb63ed41c47445eecc4174
Author: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
Date:   Fri Aug 26 21:54:13 2022 +1000

    docs: add instructions on how to run tests (#397)

diff --git a/TESTS_README.md b/TESTS_README.md
index e5db67a..1103ca2 100644
--- a/TESTS_README.md
+++ b/TESTS_README.md
@@ -32,6 +32,15 @@ end)

 The test **some test** checks that a functions output is as expected based on the input. The second test **some other test** checks that the variable **bounter** is reset for each test (as defined in the before_each block).

+# Running tests
+
+Run the test using `:PlenaryBustedTest <file>`. 
+
+```vimscript
+" Run the test in the current buffer
+:PlenaryBustedTest %
+```
+
 # mocking with luassert

 Plenary.nvim comes bundled with [luassert](https://github.com/Olivine-Labs/luassert) a library that's built to extend the built-int assertions... but it also comes with stubs, mocks and spies!
commit 92e660587d2f8f04937fb5348c1bb79cd28a2572
Author: Ahmed <48479476+XenoBino@users.noreply.github.com>
Date:   Fri Aug 26 14:53:41 2022 +0300

    docs: minor changes to README.md (#399)

    * doc: Added installation using packer to README.md

    * doc: Added neo-tree.nvim to README.md

diff --git a/README.md b/README.md
index a28dbf8..6e964b0 100644
--- a/README.md
+++ b/README.md
@@ -12,10 +12,18 @@ At the moment, it is very much in pre-alpha :smile: Expect changes to the way so

 ## Installation

+Using [plug](https://github.com/junegunn/vim-plug):
+
 ```vim
 Plug 'nvim-lua/plenary.nvim'

+Using packer: + + +use "nvim-lua/plenary.nvim" + +

Modules

akinsho commented 1 year ago

Hmm just tried again and it worked like I expect 🤔 not sure why the unusual result the first time except the difference was that the first time there were other plugin updates above and below and some issue installing a treesitter parser. I'll try and reset a few different plugins and see how it behaves

AckslD commented 1 year ago

Awesome, thanks @akinsho :rocket:

ur4ltz commented 1 year ago

Need add blank line before 'commit xxxxxx', this restored syntax highlight!

AckslD commented 1 year ago

Hi @ur4ltz, could you clarify. Do you mean a blank line between each commit in the diff buffer?

ur4ltz commented 1 year ago

Hi! @AckslD Yes!

AckslD commented 1 year ago

Ah yes I see, should be fixed by #1040