mattly / bork

the Bash-Operated Reconciling Kludge
Other
218 stars 27 forks source link

Restore compatibility with Homebrew 1.0.0 #88

Closed frdmn closed 7 years ago

frdmn commented 7 years ago

This should fix the current issues with the brew type and restore compatibility with Homebrew 1.0.0.

frdmn commented 7 years ago

/cc #83

frdmn commented 7 years ago

Can someone test and confirm this PR/fix? Would love to merge this if it's properly working. The damn brew errors are really annoying right now.

edrex commented 7 years ago

bork do ok brew is failing even when up to date:

bork git/frdmn-bug/homebrew-1.0.0-compatibility  94s
❯ bork do ok brew
outdated: brew

Updated 1 tap (caskroom/cask).
No changes to formulae.
verifying : brew
*  failed
outdated

bork git/frdmn-bug/homebrew-1.0.0-compatibility  15s
❯ bork do ok brew
outdated: brew

Already up-to-date.
verifying : brew
*  failed
outdated

This seems to be skipping the check, as advertised:

❯ bork do ok brew go
ok: brew go
frdmn commented 7 years ago

@edrex Could you please run the following command to see the verbose output:

bash -x bork do ok brew
frdmn commented 7 years ago

Ping @edrex 😬

edrex commented 7 years ago

bork check ok brew is coming back $STATUS_OUTDATED for me because I'm on the stable (default) branch of the repo at $HOMEBREW_REPOSITORY (/usr/local/Homebrew). This isn't the formula repo anymore though; it's just the Homebrew code repo. (Possibly it's $STATUS_OK for you because you're on the master branch.)

$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core is where the core formulae live now, however other taps may be behind even if this one is current so checking this one isn't enough by itself.

It seems like we should avoid sniffing around Homebrew's directories. Running the update on every satisfy ok brew seems like the safest/easiest to maintain thing, but I'm not sure if that is possible with bork's current design since AFAIK:

Maybe status should be made optional, or a new status code should be added STATUS_MAYBE_OUTDATED which behaves the same as STATUS_OUTDATED but doesn't cause an error on the post invocation.

edrex commented 7 years ago

Alternatively, the "stay the course" option would be to continue checking the main homebrew dir, and also iterate over the installed taps and check them as well.

edrex commented 7 years ago

I realized that the check type (which runs a shell command) does a single action each run, which is what we would need. The way it works is to run the command in status and return $STATUS_OK on success or $STATUS_FAILED otherwise. In either case, the ok declaration doesn't try to run install/upgrade. We could do the same thing here, which seems like a nice and simple solution to me.

edrex commented 7 years ago

Proposed change in https://github.com/edrex/bork/commit/f895d71cf9dcae32c17bbd2cf0b9f9bc5d850678, if you want to cherry-pick it. One small downside is it runs an extra brew update after first install, but that will return fast.

edrex commented 7 years ago

i guess the other downside is bork check ok brew actually updates. same as with bork check ok check do_a_thing.

shvenkat commented 7 years ago

https://github.com/edrex/bork/commit/f895d71cf9dcae32c17bbd2cf0b9f9bc5d850678 is the better solution, delegating status checking to brew, rather than duplicating it in bork.

frdmn commented 7 years ago

@edrex your changes work like a charm, I just pushed them into this PR - can someone check?

mattly commented 7 years ago

Thanks for the legwork on this. Sorry I've been MIA lately.

The original goal behind maintaining the status separately was a sort of purity when it comes to, status shouldn't make material changes to a user's system. I consider a git fetch nonmaterial but a git pull material (as it changes the used files on disk), and so strove to avoid that.

In the end, it doesn't matter, especially with brew 1.0 being so insistent about updating itself all the time. Letting brew manage itself is ultimately a pragmatic change.