Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Marking tasks as :phony fails to prevent rebuild

未关闭
#25 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
ruby
领域
build-system

调研方向

从 lib/rake/phony.rb 开始,然后按照 issue 的建议阅读 FileTask#out_of_date? 和 Task#timestamp。使用 source.file 和 final.file 运行提供的复现步骤,并比较第一次和第二次 rake 运行。当 :phony 前置条件不再导致依赖它的 FileTask 在第二次运行时重新构建时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

The :phony task fails to prevent rebuild of FileTasks dependent on non-file tasks.

lib/rake/phony.rb
# Defines a :phony task that you can use as a dependency. This allows
# file-based tasks to use non-file-based tasks as prerequisites
# without forcing them to rebuild.
#
# See FileTask#out_of_date? and Task#timestamp for more info.

require 'rake'

task :phony

Rake::Task[:phony].tap do |task|
  def task.timestamp # :nodoc:
    Time.at 0
  end
end
Code reproducing bug
require 'rake/phony'

task :default => 'final.file'

file 'final.file' => ['source.file', :intermediate] do |f|
  touch f.name
end

# Marked as phony, so should not force FileTask to rebuild
task :intermediate => [:phony] do |t|
  puts "#{t.name} task"
end
Bug demo
$ touch source.file      # Create the source file
$ rake                   # Run Rake to build 'final.file'
intermediate task
touch final.file
$ rake                   # Rake should NOT rebuild, but does.     <<<<<<<<
intermediate task
touch final.file

Mentioned here

主要语言
Ruby
星标
2.5k
派生
650
平均合并
6 分钟
30 天内合并 PR
3

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/rake 的其他 Issue

查看 ruby/rake 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。