Skip to content
Snippets Groups Projects
Unverified Commit 2f5f352b authored by Vlad Shablinsky's avatar Vlad Shablinsky Committed by Xu Cheng
Browse files

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`
parent cc01d3f5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment