Giter Site home page Giter Site logo

Comments (20)

junegunn avatar junegunn commented on August 19, 2024

Hi, thanks for the suggestion. This could be an interesting addition to vim-plug.

Actually with git reflogs, this can be implemented outside of vim-plug, try this.

function! PlugDiff()
  new
  syn match title /^[^ ].*/
  syn match date /([^)]*)$/
  hi def link title Title
  hi def link date Comment
  for [k, v] in items(g:plugs)
    execute 'cd '.substitute(v.dir, ' ', '\\ ', 'g')
    let diff = system('git log --graph --pretty=format:"%h %s (%cr)" "HEAD@{0}...HEAD@{1}"')
    if !empty(diff)
      call append(line('$') - 1, k)
      call append(line('$') - 1, map(split(diff, '\n'), '"  ". v:val'))
      put =
    endif
    cd -
  endfor
endfunction

I haven't decided how I'm going to include this feature in vim-plug. Should I add :PlugDiff command ? Or should I show it only after PlugUpdate call like Vundle does. What do you think?

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

That looks really cool! I guess both having a separate PlugDiff command and having an option to display the diff after an update are useful. But I think the main use case is to do an update and then see what's new (that's how I did it with Vundle).

Just a minor comment on the current function: would be nice to strip the white space at the end of the lines, it's highlighted in my configuration.

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

Okay, two things:

  1. Add :PlugDiff command
  2. Make pressing D in PlugUpdate window invoke PlugDiff

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

Sounds great!

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

Could you update and check if it works as expected?

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

Thanks for the updates! I've tried the new version: PlugDiff works as expected (shows the unmerged changes). I would rename "Updated changes" to one of "Upstream changes", or "Unmerged changes", or "Remote changes".

However, pressing D after running PlugUpdate doesn't exactly do what's expected, as looks like it shows the diff after the changes have been merged, therefore, it's empty ("No update", which I think would sound better if it was "No updates"). One way to fix it would be running PlugDiff first when PlugUpdate is invoked, storing the output, then applying the actual updates, and then displaying the stored PlugDiff output if D is pressed.

What do you think of changing D to d, as it's a bit easier to type?

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

Actually they are the "merged" changes from the last pull made by PlugUpdate. (Maybe the name is misleading? It doesn't work like git diff) PlugUpdate again will naturally empty PlugDiff output.

cd ~/.vim/plugged/*
git reset --hard HEAD^^
vim +PlugUpdate
# Then hit D -> PlugUpdate -> D

Regarding D, I chose uppercase D because I prefer having a shortcut key that is hard to hit accidentally, not to confuse users unaware of the feature.

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

I'm not sure what happened last time, but now I tried it again and it worked fine :) The only thing is that it didn't reset PlugDiff after update. What I mean is:

cd ~/.vim/plugged/*
git reset --hard HEAD^^
vim +PlugUpdate
# D (shows the merged commits) -> q
# PlugDiff (shows the same commits, but at this point should show "No updates")

Another minor problem is that the diff buffer doesn't wrap lines and in a vertical split the ends of long lines get hidden.

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

PlugDiff (shows the same commits, but at this point should show "No updates")

No, it's intentional and I think it's better to be able to review the changes multiple times than to be able to see it just once after update. The README page currently states that PlugDiff is for "See(ing) the updated changes from the previous PlugUpdate". (Another PlugUpdate will reset the message.)

I'm disabling line wrapping in the split. I just thought it looked better in the presence of long messages, and haven't given enough thought about that.

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

Ah, now I understand your intention and I agree it's nice to be able to review the changes multiple times. To make it clearer then I would suggest to rename "Updated changes" to something like "Last update".

However, there is still a problem and I think that's what confused me. If you do git reset on a plugin and PlugUpdate, then PlugDiff correctly shows the commits merged by the last update. If now you git reset another plugin, then run PlugDiff again without running PlugUpdate first, it shows both the already merged commits of the first plugin and not yet merged commits of the second plugin.

What do you think of having two separate commands: one which shows the changes merged by the last update (PlugDiff) and another that allows you to preview the upcoming changes before doing an update?

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

That's because git reset has updated reflog of the repository (Check out the output of git reflog). The reason the current implementation of :PlugDiff can be so simple is that it assumes that the managed repositories are only updated by :PlugUpdate and not directly touched by user. So it just shows the commits between HEAD and the previous reflog. In order to make :PlugDiff precise, we have to scan through the list of reflogs and find the exact points of the pulls. But I personally don't think it's really worth it.

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

(And I didn't want to introduce some shell scripting for doing that because it also has to work on Windows)

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

Ok, I agree it's not worth it. What do you think about renaming "Updated changes" to something like "Last update"?

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

Okay, just a sec.

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

Updated. I'm not a native speaker of English, so I'm open to suggestions on messages. Thanks!

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

Awesome, thanks a lot! I'm not a native English speaker as well :)

from vim-plug.

lithammer avatar lithammer commented on August 19, 2024

I realize this has already been merged, but how about adding something along the lines of "Press 'D' to see changes" after PlugUpdate is done, just as a hint? I'm thinking at the end of s:finish() might be a suitable place. Just a simple a simple echo "Press..." would suffice.

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

@Renstrom Ah yeah, echo would be nice. I'll let you know when I update the code.

from vim-plug.

junegunn avatar junegunn commented on August 19, 2024

@Renstrom @beloglazov I've updated the code to echo the message on PlugUpdate. Additionally, now you can see the content of a commit by pressing enter key on each line of PlugDiff output.

from vim-plug.

beloglazov avatar beloglazov commented on August 19, 2024

Works nicely, thanks!

from vim-plug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.