-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Add internal command to calculate appcast checkpoint. #1894
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 internal command to calculate appcast checkpoint. #1894
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d say these can be removed. If this exists to give the same result the non-internal command does, but the non-internal command will ceased to be used in favour of this internal one, then there’s nothing to replicate. This will be the canonical and only recommended way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought I'd leave this in for now as to not mess up existing values. But I guess this doesn't make any difference since they aren't officially used for anything yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed it also needs the delete("\n") step before gsub.
There’s no harm in messing with current values, since those will be outdated anyway, for missing the delete step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't delete("\n") only needed because sed only handles one line at a time? Do we need it then, when we aren't going to use sed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that some casks have <pubDate> and </pubDate> on different lines, so it doesn’t actually get removed. By removing all newlines, we make sure <pubDate>[^<]*</pubDate> always works.
I guess we can just setup the regex to work multi-line, yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right, I forgot gsub still needs the m option to be multi-line.
|
Might it be worth adding mandatory flags to this? Something like |
3682bb2 to
e69efd7
Compare
|
@reitermarkus Instead of adding mandatory flags, it seemed sensible to make it just print the current appcast when no flags given, or calculate it when given Was going to submit it as a PR to your fork, but GitHub was erroring and not cooperating, so it was easier to add the commit directly: 949d3de. Looks good to me as is, unless you want to change something/disagree. |
|
While editing the documentation, just recalled something else. We can’t just take casks as arguments, we also need to take URLs (so users can calculate it the first time, when building the cask). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does cask_tokens_from(args) not work here, or was this overlooked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was overlooked. It does indeed work, but I was basing myself on _stanza and didn’t even notice. Will fix it and add to #1896 as well.
372751a to
c34dbfa
Compare
c34dbfa to
c728e71
Compare
c728e71 to
38d4a1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work the same both with or without --calculate. Just pointing it out in case you intended to do it any other way. It’s fine by me as it is since the only sensical thing to do with a URL is calculate, anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only sensical thing to do with a URL is calculate
Exactly, you can't not calculate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a note about it working on URLs as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's maybe add this to the man page instead, otherwise the line is getting kinda long.
38d4a1d to
2d5b659
Compare
|
@vitorgalvao, I added a manpage entry and shortened the help text a bit. |
|
I’d say it’s ready to merge as soon as all checks pass. |
|
So - does this use a different method of calculating the hash of the app cast? For example, if I run (after updating) $ brew cask _appcast_checkpoint marked
caf003f39ca2a87922e2d1f6afe17df55bd6bb6f36dcfd16b52e257cf629f5e0
$ brew cask _appcast_checkpoint --calculate marked
f315ff8dfb5cbd0e1da1ef302c6edbcb738d083237ebc4b977e78a1c6ce97fd3However - the hash (using cURL) was previously calculated thusly: $ curl --compressed --location --user-agent 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36' "https://updates.marked2app.com/marked.xml" | /usr/bin/sed 's|<pubDate>[^<]*</pubDate>||g' | shasum --algorithm 256
caf003f39ca2a87922e2d1f6afe17df55bd6bb6f36dcfd16b52e257cf629f5e0Which is the current (in the cask file) hash. I'm fine if the internal call changes the way that the hash is calculated - but is there a separate task to update all current casks with their new hashes? |
Yes. The change was necessary anyway as the old method wasn’t reliable on all cases.
No. That is unnecessary. Only now that this is finalised will I start working on remaking the scripts to fix casks based on appcast checkpoints. Those will end up being fixed organically. |
brew testswith your changes locally?@vitorgalvao, I think (finally) implementing this is better than adding yet another workaround (
tr "\n").Closes Homebrew/homebrew-cask#24811, Homebrew/homebrew-cask#28966 and #1876.