buo / homebrew-cask-upgrade

A command line tool for upgrading every outdated app installed by Homebrew Cask
MIT License
2.4k stars 90 forks source link

Add version pinning functionality #132

Closed dongyuzheng closed 5 years ago

dongyuzheng commented 5 years ago

Why

I found myself needing this when I didn't want to update java8.

This PR resolves #108, resolves #93, resolves #90, resolves #72

Not included in this PR

Currently you can pin casks that are not installed. So you can pin asdasfsadasd

Usage

gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --help
...

OPTIONS:
...
    If --pinned is passed, print all pinned apps

    If --pin CASK is passed, pin the current app version

    If --unpin CASK is passed, unpin the current app version

Example usage

gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --pinned
java8
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --pin firefox
Pinned: firefox
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --pin firefox
Already pinned: firefox
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --pinned
java8
firefox
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --unpin firefox
Unpinned: firefox
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --unpin firefox
Not pinned: firefox
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --pinned
java8
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu
==> Options
Include auto-update (-a): false
Include latest (-f): false
==> Updating Homebrew
Already up-to-date.
==> Finding outdated apps
       Cask                    Current                  Latest                A/U    Result
...
 8/19  java8                   1.8.0_192-b12,750e1c...  8.202.03,07_nov_2018       [ PINNED ]
...
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu --unpin java8
Unpinned: java8
gary@v1020-wn-17-117:~/pg/homebrew-cask-upgrade (master)$ brew cu
==> Options
Include auto-update (-a): false
Include latest (-f): false
==> Updating Homebrew
Already up-to-date.
==> Finding outdated apps
       Cask                    Current                  Latest                A/U    Result
...
 8/19  java8                   1.8.0_192-b12,750e1c...  8.202.03,07_nov_2018       [OUTDATED]
...
==> Found outdated apps
     Cask   Current                                         Latest                A/U    Result
1/1  java8  1.8.0_192-b12,750e1c8617c5452694857ad95c3ee230  8.202.03,07_nov_2018       [OUTDATED]

Do you want to upgrade 1 app [y/N]? ^C
ondrejfuhrer commented 5 years ago

Hey @dongyuzheng , thanks a lot for your contribution! It's nice that someone found a time to do that. Please do me a favour and change the description here so that instead of lust listing those issues change it to Resolves: #... so that when the PR is merged, those issues are automatically closed.

Thanks! 👍

dongyuzheng commented 5 years ago

Hi @ondrejfuhrer, does my latest commit give desired output for your case?

muescha commented 5 years ago

i think the pinned file should be better in the ~/ folder. for example as ~/.brew-cu-pinned

ondrejfuhrer commented 5 years ago

@muescha Not sure if that would make any difference. Not even the Homebrew core is using a home folder for that and they are pinning it within Homebrew structure, so I don't see any important reason why would you do that.

Also if you would remove the tap it would leave those files on the home folder which is not very clean.

yurikoles commented 5 years ago

I think @ondrejfuhrer is right, there is --appdir option, but it still uses global Caskroom for apps.

muescha commented 5 years ago

ok - you are right, it should be the same as the homebrew core behaviour