aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Shablinsky2016-05-24 23:00:29 +0300
committerXu Cheng2016-07-06 16:19:49 +0800
commit2f5f352baa95ce9cc6b4e0007ee2fc028ffc2a1a (patch)
treeda89efe41d48ca43688e6231a528894000a5e8df
parentcc01d3f59aedfa6acefc82660e52d615f3165df5 (diff)
downloadbrew-2f5f352baa95ce9cc6b4e0007ee2fc028ffc2a1a.tar.bz2
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`
-rw-r--r--Library/Homebrew/download_strategy.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index 4ce3e3412..f690155f2 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