-
Notifications
You must be signed in to change notification settings - Fork 9
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
Lookup prerequisites with same name outside of scope instead of matching self #264
Lookup prerequisites with same name outside of scope instead of matching self #264
Conversation
application[prerequisite_name, @scope] | ||
scoped_prerequisite_task = application[prerequisite_name, @scope] | ||
if scoped_prerequisite_task == self | ||
unscoped_prerequisite_task = application[prerequisite_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.
I'm concerned about this @scope
-less lookup. Does it follow ruby's constant lookup rules, or does it always only look at top-level.
What prerequisite task is discovered with:
m = task 'm'
a_m = nil
namespace 'a' do
a_m = task 'm'
namespace 'b' do
task x: 'm'
end
end
Whichever behavior (m
or a_m
) this change causes should be tested and documented.
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.
Good point ✨ I'll look into it and follow up. Thanks.
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.
After thinking further, I think m
should be the dependency for a:b:x
, not a:m
.
I think this is best because it prevents unintentional change in dependencies as you add new tasks in the namespaces between the root and current namespace.
Any updates on this @svanderbleek, or should I finish it? |
I'll finish it, thanks for the ping. To finish we just need the two namespace test, correct? |
Correct |
@drbrain rebased and updated with |
Any thoughts @drbrain? |
Since this changes the behavior of rake I have to wait until rake 11 to merge it. Barring any bugs or other commitments this will probably be within a month or so |
according to the Rakefile Format https://github.com/jimweirich/rake/blob/master/doc/rakefile.rdoc, the way to do this is '^b' or 'rake:b'. this does seem to work for prerequisites, but not for task names. task :test do
puts 'hi test'
end
namespace :test do
task :unit do
puts 'hi units'
end
task :unit => '^test' # works
task '^test' => :unit # does not work
end
Am I missing something? |
@bhenderson Your example is off, but you are correct. Here is the problem I was talking about: task :test do
puts 'hi test'
end
namespace :unit do
task :test do
puts 'hi units'
end
task :test => '^test' # works
task :test => 'test' # doesn't work
end I didn't know about the syntax. |
Task#lookup_prerequisite
finds self if looking up a prerequisite outside of the namespace with the same task name. Behavior in this case is debatable but at least there should be a way to specify to lookup the task outside of the scope instead of ending the chain with a circular reference. If this default behavior I have implemented looks good this solves the problem by convention. Otherwise notation will need to be introduced such asWhere global signifies to lookup outside the namespace.