lib/braid/mirror.rb in norbert-braid-0.4.12 vs lib/braid/mirror.rb in norbert-braid-0.4.13
- old
+ new
@@ -89,50 +89,42 @@
remote_hash != local_hash ? git.diff_tree(remote_hash, local_hash, path) : ""
end
def fetch
unless type == "svn"
- init_or_fetch_local_cache
+ git_cache.fetch(url) if cached?
git.fetch(remote)
else
git_svn.fetch(remote)
end
end
- def cached_url
- if Braid::USE_LOCAL_CACHE
- File.join(Braid::LOCAL_CACHE_DIR, url.gsub(/[\/:@]/, "_"))
+ def cached?
+ git.remote_url(remote) == git_cache.path(url)
+ end
+
+ def base_revision
+ if revision
+ unless type == "svn"
+ git.rev_parse(revision)
+ else
+ git_svn.commit_hash(remote, revision)
+ end
else
- url
+ inferred_revision
end
end
- def init_or_fetch_local_cache
- git_cache.init_or_fetch(url, cached_url)
- end
-
private
def method_missing(name, *args)
if ATTRIBUTES.find { |attribute| name.to_s =~ /^(#{attribute})(=)?$/ }
unless $2
attributes[$1]
else
attributes[$1] = args[0]
end
else
raise NameError, "unknown attribute `#{name}'"
- end
- end
-
- def base_revision
- if revision
- unless type == "svn"
- git.rev_parse(revision)
- else
- git_svn.commit_hash(remote, revision)
- end
- else
- inferred_revision
end
end
def inferred_revision
local_commits = git.rev_list("HEAD", "-- #{path}").split("\n")