4 # Commit log for "foo" repository in test.git.tar
5 # master is the main branch
6 # b1 is a branch off of master
15 def self.included base
17 @tmpdir = Dir.mktmpdir()
18 system("tar", "-xC", @tmpdir, "-f", "test/test.git.tar")
19 Rails.configuration.git_repositories_dir = "#{@tmpdir}/test"
20 intdir = Rails.configuration.git_internal_dir
21 if not File.exist? intdir
22 FileUtils.mkdir_p intdir
23 IO.read("|git --git-dir #{intdir.to_s.shellescape} init")
29 FileUtils.remove_entry @tmpdir, true
30 FileUtils.remove_entry Commit.cache_dir_base, true
35 IO.read "|git --git-dir #{Rails.configuration.git_internal_dir.shellescape} log --format=format:%H -n1 #{tag.shellescape}"
38 # Intercept fetch_remote_repository and fetch from a specified url
39 # or local fixture instead of the remote url requested. fakeurl can
40 # be a url (probably starting with file:///) or the name of a
41 # fixture (as a symbol)
42 def fetch_remote_from_local_repo url, fakeurl
43 if fakeurl.is_a? Symbol
44 fakeurl = 'file://' + repositories(fakeurl).server_path
46 Commit.expects(:fetch_remote_repository).once.with do |gitdir, giturl|
48 Commit.unstub(:fetch_remote_repository)
49 Commit.fetch_remote_repository gitdir, fakeurl