Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

fetch/build formula from source when modified #41397

Closed
wants to merge 1 commit into from

Conversation

dunn
Copy link
Contributor

@dunn dunn commented Jul 6, 2015

Closes #36068.

Is performance something to worry about here?

@dunn
Copy link
Contributor Author

dunn commented Jul 6, 2015

Oh, forgot to add the override flag @DylanLacey mentioned.

@dunn
Copy link
Contributor Author

dunn commented Jul 6, 2015

Nevermind, --force-bottle still works to override it.

@dunn
Copy link
Contributor Author

dunn commented Jul 6, 2015

  1) Error:
BottleHookTests#test_has_no_bottle:
NoMethodError: undefined method `is_modified?' for #<BottleHookTests::FormulaDouble:0x007f9203054078>
    /usr/local/Library/Homebrew/formula_installer.rb:65:in `pour_bottle?'

This is weird since formula_installer requires formula. I must be missing something.

@dunn dunn force-pushed the no-bottle branch 2 times, most recently from 6418a3c to 9e3057c Compare July 6, 2015 04:57
@DylanLacey
Copy link

Oh bugger. This'll teach me to write an implementation on a RailsCamp and forget to send a PR >.>

@dunn
Copy link
Contributor Author

dunn commented Jul 6, 2015

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
Copy link
Member

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.

Copy link
Contributor Author

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?

@DylanLacey
Copy link

@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

@tdsmith
Copy link
Contributor

tdsmith commented Jul 7, 2015

I do think it's important that a solution announces "Formula modified locally; building from source" or similar.

@dunn
Copy link
Contributor Author

dunn commented Jul 7, 2015

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
Copy link
Member

Choose a reason for hiding this comment

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

return is redundant

@dunn
Copy link
Contributor Author

dunn commented Jul 7, 2015

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
Copy link
Member

Choose a reason for hiding this comment

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

@dunn
Copy link
Contributor Author

dunn commented Jul 9, 2015

OK, I think that covers everything.

@dunn
Copy link
Contributor Author

dunn commented Jul 9, 2015

Not getting those test failures locally.

@MikeMcQuaid
Copy link
Member

I currently see this message printed twice (it should only be output called once). Once that's fixed we're good to go.

@dunn
Copy link
Contributor Author

dunn commented Jul 10, 2015

Sorry, where are you seeing doubled output?

Also, added .rb to the ohai, since it's the file that's been modified.

@MikeMcQuaid
Copy link
Member

If I run brew install wget after modifying the formula.

@dunn
Copy link
Contributor Author

dunn commented Jul 10, 2015

Oh, I was testing with brew install when and it doesn't happen for that formula. Bizarre; I'll investigate.

@dunn
Copy link
Contributor Author

dunn commented Jul 10, 2015

It makes sense that we get the message twice for formulae like libtorrent which call pour_bottle?, but I'm not sure why wget does it.

@dunn
Copy link
Contributor Author

dunn commented Jul 10, 2015

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"
Copy link
Member

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On narrow tmux/screen panes the path will get cut off, but I think that's fine:
screenshot 2015-07-11 10 25 18

Copy link
Member

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?

@MikeMcQuaid
Copy link
Member

@dunn This is looking awesome. A few more tweaks; almost there!

@dunn
Copy link
Contributor Author

dunn commented Jul 11, 2015

Three changes:

  • Fixed the git diff to detect committed as well as staged changes
  • changed the ohai to opoo (I think it should stand out a bit from all the other ohais, but either way is OK, really)
  • Modified the message as below:
    screenshot 2015-07-11 14 03 21

@dunn dunn closed this in 1134222 Jul 19, 2015
@dunn dunn deleted the no-bottle branch July 19, 2015 03:57
woodruffw pushed a commit to woodruffw-forks/homebrew that referenced this pull request Jul 22, 2015
closes Homebrew#36068

Closes Homebrew#41397.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants