aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/cmd/log_spec.rb
blob: bdbca8912193e85546d95233456f5aea2717238c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
describe "brew log", :integration_test do
  it "shows the Git log for the Homebrew repository when no argument is given" do
    HOMEBREW_REPOSITORY.cd do
      shutup do
        system "git", "init"
        system "git", "commit", "--allow-empty", "-m", "This is a test commit"
      end
    end

    expect { brew "log" }
      .to output(/This is a test commit/).to_stdout
      .and not_to_output.to_stderr
      .and be_a_success
  end

  it "shows the Git log for a given Formula" do
    setup_test_formula "testball"

    core_tap = CoreTap.new
    core_tap.path.cd do
      shutup do
        system "git", "init"
        system "git", "add", "--all"
        system "git", "commit", "-m", "This is a test commit for Testball"
      end
    end

    core_tap_url = "file://#{core_tap.path}"
    shallow_tap = Tap.fetch("homebrew", "shallow")
    shutup do
      system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path
    end

    expect { brew "log", "#{shallow_tap}/testball" }
      .to output(/This is a test commit for Testball/).to_stdout
      .and output(/Warning: The git repository is a shallow clone/).to_stderr
      .and be_a_success

    expect(shallow_tap.path/".git/shallow").to exist, "A shallow clone should have been created."
  end
end