-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
fetch/build formula from source when modified #41397
Conversation
Oh, forgot to add the override flag @DylanLacey mentioned. |
Nevermind, |
This is weird since formula_installer |
6418a3c
to
9e3057c
Compare
Oh bugger. This'll teach me to write an implementation on a RailsCamp and forget to send a PR >.> |
I mean if yours is better I'd be happy to close this in favor of it. |
old_wd = Pathname.pwd | ||
Dir.chdir path.dirname | ||
diff = Utils.popen_read("git", "diff", "--diff-filter=M", "--name-only", "#{path}") | ||
Dir.chdir old_wd |
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.
You can do:
path.parent.cd do
diff = ...
end
Another thing that you need to check is formula file may be outside git repo.
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.
Another thing that you need to check is formula file may be outside git repo.
That was why I added the exitstatus
check; git should return non-zero in those cases. Are there cases where that's insufficient?
@dunn I don't believe so; I pushed it as https://github.com/Homebrew/homebrew/pull/41433/files. I just was chastising myself for having and implementing a reasonable idea, then not actually going 100% through forgetfulness and lack of tests :P |
I do think it's important that a solution announces "Formula modified locally; building from source" or similar. |
Updated; but let me know if this should be closed in favor of @DylanLacey's. |
def modified? | ||
path.parent.cd do | ||
diff = Utils.popen_read("git", "diff", "--diff-filter=M", "--name-only", "#{path}") | ||
return !diff.empty? && $?.exitstatus == 0 |
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.
return
is redundant
Still need help interpreting the test failure, I'm afraid. |
diff = Utils.popen_read("git", "diff", "--diff-filter=M", "--name-only", "#{path}") | ||
!diff.empty? && $?.exitstatus == 0 | ||
end | ||
end |
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.
Also add this method here: https://github.com/Homebrew/homebrew/blob/master/Library/Homebrew/test/test_bottle_hooks.rb#L6-L10
OK, I think that covers everything. |
Not getting those test failures locally. |
I currently see this message printed twice (it should only be output called once). Once that's fixed we're good to go. |
Sorry, where are you seeing doubled output? Also, added |
If I run |
Oh, I was testing with |
It makes sense that we get the message twice for formulae like libtorrent which call |
Anyway, fixed! |
@@ -32,6 +32,11 @@ def fetch | |||
def fetch_bottle? f | |||
return true if ARGV.force_bottle? && f.bottle | |||
return false unless f.bottle && f.pour_bottle? | |||
if formula.file_modified? | |||
ohai "#{formula.full_name}.rb is modified; fetching source" |
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.
formula.path.to_s.gsub("#{HOMEBREW_PREFIX}/", '')
might be a bit better (particularly for stuff from taps).
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.
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.
Maybe go for PATH is modified!
and then putting the rest fitting on the next line? What do you think?
@dunn This is looking awesome. A few more tweaks; almost there! |
closes Homebrew#36068 Closes Homebrew#41397. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Closes #36068.
Is performance something to worry about here?