Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version pinning functionality #132

Merged
merged 7 commits into from
Jan 30, 2019
Merged

Add version pinning functionality #132

merged 7 commits into from
Jan 30, 2019

Conversation

dongyuzheng
Copy link
Contributor

@dongyuzheng dongyuzheng commented Jan 22, 2019

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

Copy link
Collaborator

@ondrejfuhrer ondrejfuhrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md Outdated Show resolved Hide resolved
lib/bcu.rb Show resolved Hide resolved
@ondrejfuhrer
Copy link
Collaborator

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
Copy link
Contributor Author

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

options.list_pins = true
end

opts.on("--pin APP", "App to pin") do |app|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere we / Homebrew uses CASK, I don't see a reason why we should introduce new naming? I saw that in one of the versions you had used that, any particular reason why you decided to use different naming?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that the code/documentation used app in some places, so I change them to app to be consistent. But I changed it to cask now.

lib/bcu.rb Outdated Show resolved Hide resolved
lib/bcu.rb Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@ondrejfuhrer ondrejfuhrer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍 Now it has to wait for @buo

@buo buo merged commit 345e9c8 into buo:master Jan 30, 2019
@muescha
Copy link
Contributor

muescha commented Feb 11, 2019

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

@ondrejfuhrer
Copy link
Collaborator

@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
Copy link
Contributor

yurikoles commented Feb 11, 2019

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

@muescha
Copy link
Contributor

muescha commented Feb 11, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants