foriequal0 / git-trim

Automatically trims your branches whose tracking remote refs are merged or stray
MIT License
492 stars 14 forks source link

Push delete hub-style checked-out branches #66

Closed foriequal0 closed 4 years ago

foriequal0 commented 4 years ago

TODO:

Resolves: https://github.com/foriequal0/git-trim/issues/55

doronbehar commented 4 years ago

I'd like to test this with --dry-run. I think the following output was wasn't present before this PR:

Kept back:
  merged remotes:
    doronbehar, refs/heads/update-castget       filtered out
    doronbehar, refs/heads/update-cpp-utilities filtered out
    doronbehar, refs/heads/update-cups  filtered out
    doronbehar, refs/heads/update-firmware      filtered out
    doronbehar, refs/heads/update-fribidi       filtered out
    doronbehar, refs/heads/update-gaia  filtered out
    doronbehar, refs/heads/update-gotify-server filtered out
    doronbehar, refs/heads/update-hub   filtered out
    doronbehar, refs/heads/update-imapfilter    filtered out
    doronbehar, refs/heads/update-khard filtered out
    doronbehar, refs/heads/update-lua_pulseaudio        filtered out
    doronbehar, refs/heads/update-luarocks      filtered out
    doronbehar, refs/heads/update-neovim-remote filtered out
    doronbehar, refs/heads/update-newsboat      filtered out
    doronbehar, refs/heads/update-nvim-client   filtered out
    doronbehar, refs/heads/update-onedrive      filtered out
    doronbehar, refs/heads/update-pdfcpu        filtered out
    doronbehar, refs/heads/update-pynvim        filtered out
    doronbehar, refs/heads/update-qtutilities   filtered out
    doronbehar, refs/heads/update-sccache       filtered out
    doronbehar, refs/heads/update-sequoia       filtered out
    doronbehar, refs/heads/update-sundials      filtered out
    doronbehar, refs/heads/update-syncthingtray filtered out
    doronbehar, refs/heads/update-tinc  filtered out
    doronbehar, refs/heads/update-tmux  filtered out
    doronbehar, refs/heads/update-urwid filtered out
    doronbehar, refs/heads/update-wmc-mpris     filtered out

For my scenario, where almost all of the update- branches were merged, does this message mean these branches will be deleted on the doronbehar remote?

foriequal0 commented 4 years ago

I've changed the default value of trim.delete filter to merged:origin from merged. It only tries to delete remote branches whose remote name is origin. merged doesn't care about it. It was for the safety. Otherwise git-trim would try to git push --delete on every hub pr checkout #'d someone other's remote repos. I think that's why they are filtered out. Would you try with git trim --dry-run --delete merged or git trim --dry-run --delete merged:origin,merged:doronbehar? You can set git config --global trim.delete merged:origin,merged:doronbehar to make it as a global defualt. I need to change the filtered out message to some other less cryptic messages. How about out of delete filter scope? filter scoping is documented on README.md

doronbehar commented 4 years ago

Now it wasn't filtered out:

Delete merged remote refs:
  - doronbehar, refs/heads/update-castget
  - doronbehar, refs/heads/update-cpp-utilities
  - doronbehar, refs/heads/update-cups
  - doronbehar, refs/heads/update-firmware
  - doronbehar, refs/heads/update-fribidi
  - doronbehar, refs/heads/update-gaia
  - doronbehar, refs/heads/update-gotify-server
  - doronbehar, refs/heads/update-hub
  - doronbehar, refs/heads/update-imapfilter
  - doronbehar, refs/heads/update-khard
  - doronbehar, refs/heads/update-lua_pulseaudio
  - doronbehar, refs/heads/update-luarocks
  - doronbehar, refs/heads/update-neovim-remote
  - doronbehar, refs/heads/update-newsboat
  - doronbehar, refs/heads/update-nvim-client
  - doronbehar, refs/heads/update-onedrive
  - doronbehar, refs/heads/update-pdfcpu
  - doronbehar, refs/heads/update-pynvim
  - doronbehar, refs/heads/update-qtutilities
  - doronbehar, refs/heads/update-sccache
  - doronbehar, refs/heads/update-sequoia
  - doronbehar, refs/heads/update-sundials
  - doronbehar, refs/heads/update-syncthingtray
  - doronbehar, refs/heads/update-tinc
  - doronbehar, refs/heads/update-tmux
  - doronbehar, refs/heads/update-urwid
  - doronbehar, refs/heads/update-wmc-mpris
foriequal0 commented 4 years ago

They will be git push delete'd if you run it without --dry-run. Would you mind if I merge this PR?

doronbehar commented 4 years ago

Yes I think you can merge, it seems to be working I guess. Pardon me for not willing to test it without --dry-run, I just need some time to figure out my workflow now when I have git trim in my $PATH :).

foriequal0 commented 4 years ago

That's totally fine. Thank you for reviewing this with me!

doronbehar commented 4 years ago

My pleasure :).