From b24f1743255efe631a1d8fdd1357c5a4f475fa0e Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Thu, 14 Jan 2016 18:57:31 +0800 Subject: [PATCH] download_strategy: add source_modified_time --- Library/Homebrew/download_strategy.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 77ec788b9b..6eaa7be715 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -26,6 +26,12 @@ class AbstractDownloadStrategy def cached_location end + # @!attribute [r] + # return most recent modified time for all files in the current working directory after stage. + def source_modified_time + Pathname.pwd.to_enum(:find).select(&:file?).map(&:mtime).max + end + # Remove {#cached_location} and any other files associated with the resource # from the cache. def clear_cache @@ -555,6 +561,10 @@ class GitDownloadStrategy < VCSDownloadStrategy cp_r File.join(cached_location, "."), Dir.pwd end + def source_modified_time + Time.parse Utils.popen_read("git", "--git-dir", git_dir, "show", "-s", "--format=%cD") + end + private def cache_tag