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 # Extract the test repository data into the default test
18 # environment's Rails.configuration.git_repositories_dir. (We
19 # don't use that config setting here, though: it doesn't seem
20 # worth the risk of stepping on a real git repo root.)
21 @tmpdir = Rails.root.join 'tmp', 'git'
22 FileUtils.mkdir_p @tmpdir
23 system("tar", "-xC", @tmpdir.to_s, "-f", "test/test.git.tar")
24 Rails.configuration.git_repositories_dir = "#{@tmpdir}/test"
26 intdir = Rails.configuration.git_internal_dir
27 if not File.exist? intdir
28 FileUtils.mkdir_p intdir
29 IO.read("|git --git-dir #{intdir.to_s.shellescape} init")
35 FileUtils.remove_entry @tmpdir, true
36 FileUtils.remove_entry Commit.cache_dir_base, true
41 IO.read "|git --git-dir #{Rails.configuration.git_internal_dir.shellescape} log --format=format:%H -n1 #{tag.shellescape}"
44 # Intercept fetch_remote_repository and fetch from a specified url
45 # or local fixture instead of the remote url requested. fakeurl can
46 # be a url (probably starting with file:///) or the name of a
47 # fixture (as a symbol)
48 def fetch_remote_from_local_repo url, fakeurl
49 if fakeurl.is_a? Symbol
50 fakeurl = 'file://' + repositories(fakeurl).server_path
52 Commit.expects(:fetch_remote_repository).once.with do |gitdir, giturl|
54 Commit.unstub(:fetch_remote_repository)
55 Commit.fetch_remote_repository gitdir, fakeurl