From 2f5f352baa95ce9cc6b4e0007ee2fc028ffc2a1a Mon Sep 17 00:00:00 2001 From: Vlad Shablinsky <vladshablinsky@gmail.com> Date: Tue, 24 May 2016 23:00:29 +0300 Subject: [PATCH] VCSDownloadStrategy: add last_commit method Implement: * VCSDownloadStrategy#last_commit Use last modified file timestamp * SubversionDownloadStrategy#last_commit Use `svn info --show-item revision` * GitDownloadStrategy#last_commit Use `git rev-parse HEAD` * MercurialDownloadStrategy#last_commit Use `hg parent --template {node}` * BazaarDownloadStrategy#last_commit Use `bazaar revno` * FossilDownloadStrategy#last_commit Use `fossil info tip` --- Library/Homebrew/download_strategy.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 4ce3e3412c..f690155f2e 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -153,6 +153,12 @@ class VCSDownloadStrategy < AbstractDownloadStrategy version.head? end + # Return last commit's unique identifier for the repository. + # Return most recent modified timestamp unless overridden. + def last_commit + source_modified_time.to_i.to_s + end + private def cache_tag @@ -501,6 +507,10 @@ class SubversionDownloadStrategy < VCSDownloadStrategy Time.parse REXML::XPath.first(xml, "//date/text()").to_s end + def last_commit + Utils.popen_read("svn", "info", "--show-item", "revision", cached_location.to_s).strip + end + private def repo_url @@ -581,6 +591,10 @@ class GitDownloadStrategy < VCSDownloadStrategy Time.parse Utils.popen_read("git", "--git-dir", git_dir, "show", "-s", "--format=%cD") end + def last_commit + Utils.popen_read("git", "--git-dir", git_dir ,"rev-parse", "HEAD").chomp + end + private def cache_tag @@ -818,6 +832,10 @@ class MercurialDownloadStrategy < VCSDownloadStrategy Time.parse Utils.popen_read("hg", "tip", "--template", "{date|isodate}", "-R", cached_location.to_s) end + def last_commit + Utils.popen_read("hg", "parent", "--template", "{node}", "-R", cached_location.to_s) + end + private def cache_tag @@ -854,6 +872,10 @@ class BazaarDownloadStrategy < VCSDownloadStrategy Time.parse Utils.popen_read("bzr", "log", "-l", "1", "--timezone=utc", cached_location.to_s)[/^timestamp: (.+)$/, 1] end + def last_commit + Utils.popen_read("bzr", "revno", cached_location.to_s).chomp + end + private def cache_tag @@ -891,6 +913,10 @@ class FossilDownloadStrategy < VCSDownloadStrategy Time.parse Utils.popen_read("fossil", "info", "tip", "-R", cached_location.to_s)[/^uuid: +\h+ (.+)$/, 1] end + def last_commit + Utils.popen_read("fossil", "info", "tip", "-R", cached_location.to_s)[/^uuid: +(\h+) .+$/, 1] + end + private def cache_tag -- GitLab