-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Fix SVN downloads of versioned formula by munging directory names #4358
Fix SVN downloads of versioned formula by munging directory names #4358
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.
Nice work!
@@ -665,6 +665,11 @@ def initialize(name, resource) | |||
@url = @url.sub("svn+http://", "") | |||
end | |||
|
|||
def cache_filename | |||
# "@" is a special character for Subversion. Keep it out of the cache dir name. | |||
"#{name.gsub("@", "_AT_")}--#{cache_tag}" |
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.
Do you think we need the _
? I also wonder about using -
instead.
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.
Switched to -
. I like having some separator there for readability.
Library/Homebrew/resource.rb
Outdated
@@ -67,7 +67,8 @@ def escaped_name | |||
end | |||
|
|||
def download_name | |||
name.nil? ? owner.name : "#{owner.name}--#{escaped_name}" | |||
# Must not have "@" in download_name because it's a special character to Subversion | |||
(name.nil? ? owner.name : "#{owner.name}--#{escaped_name}").gsub("@", "_AT_") |
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.
if name
would be a bit nicer (I know it's not your code). Would be good to reuse the gsub
; perhaps a shared resource function?
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.
Refactored it to use an if name
.
Ping! Any outstanding changes still needed on this? Would be nice to get this merged, since I'm actively encountering this error in a project. |
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.
Sorry I had an unsubmitted review and am on vacation with spotty internet.
@@ -665,6 +665,11 @@ def initialize(name, resource) | |||
@url = @url.sub("svn+http://", "") | |||
end | |||
|
|||
def cache_filename | |||
# "@" is a special character for Subversion. Keep it out of the cache dir name. | |||
"#{name.gsub("@", "-AT-")}--#{cache_tag}" |
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.
Can the .gsub("@", "-AT-")
go into a function somewhere rather than duplicating below? Note that below the duplication is not correct too 😉
No worries. Enjoy your vacation; this stuff can wait! When you have time, I've pushed an amendment with a refactor that addresses your latest comments, consolidating the |
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.
Brew style is failing
@@ -665,6 +665,11 @@ def initialize(name, resource) | |||
@url = @url.sub("svn+http://", "") | |||
end | |||
|
|||
def cache_filename | |||
# "@" is a special character for Subversion. Keep it out of the cache dir name. |
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.
Feels like this comment should be for safe download name
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.
Moved comment to safe_download_name
.
Library/Homebrew/resource.rb
Outdated
Resource.safe_download_name( | ||
if name | ||
"#{owner.name}--#{escaped_name}" | ||
else |
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.
Feels weird having an if inside a function call. I’d assign a new variable outside 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.
Rewrote it to use a temporary variable. Moved & merged comment to safe_download_name
.
Amended to address comments; |
@@ -727,6 +727,7 @@ def build | |||
|
|||
formula.update_head_version | |||
|
|||
puts "Testing formula prefix for emptiness: formula.prefix='#{formula.prefix}'" |
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.
Oops
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.
Oops. Fixed.
Sorry for all the hassle here.
Thanks @apjanke! |
Yay, thank you! And you're welcome! |
Homebrew/brew#4358 fixes downloads of versioned formulae from SVN repos, and is in master Homebrew now. No need for our special patch branch any more.
This seems to have changed the URLs that Before revert:
After revert:
CC @apjanke |
Darn it! Do the file upload names to Bintray matter? If so, best revert this PR, and I'll have to come up with a more detailed PR that tracks both original filenames and local filenames separately. |
I’d suggest tracking or calculating the original url filename in mirror as that’ll be the only place this matters. |
should work if the change is intentional. Personally, I'm really unconvinced that having the @ formula names in the cache files be munged just for the sake of svn was a desirable change. Hunting for [email protected] is a lot nicer than Also does this invalidate cleanup? Is it still going to know how to cleanup the tarballs with the old names or did they all just get stranded forever? |
I didn’t review this sufficiently. I was under the impression from the PR description that this only affected SVN resources. I think it should be reverted and scoped just to them, unfortunately. |
Okay, sorry. I will re-submit a new PR scoped only to SVN downloads when I'm able to figure out how to properly unit test it. |
brew style
with your changes locally?brew tests
with your changes locally?The SubversionDownloadStrategy is broken for versioned formulae, because it includes an "@" in the resulting directory names, and "@" is a special character to Subversion. This PR fixes it by munging the cache and staging directory names to use "_AT_" instead of "@", avoiding the special character.
There's currently no test for the SubversionDownloadStrategy, and it doesn't look like download strategies are tested in the context of a
stage
operation. Suggestions welcome as to how to do a decent test on this.Details
To reproduce, create a versioned formula that uses an SVN download as its main download, for example,
netpbm
. Do abrew install -s
on it, and it'll error during the fetch step.References