From 146664b45f12e2d127b1373a3af7174bd2c60e53 Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Sat, 19 Sep 2020 15:21:46 +1000 Subject: [PATCH] utils/git: cherry-pick test --- Library/Homebrew/test/utils/git_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/test/utils/git_spec.rb b/Library/Homebrew/test/utils/git_spec.rb index 5096700037..09329fdc73 100644 --- a/Library/Homebrew/test/utils/git_spec.rb +++ b/Library/Homebrew/test/utils/git_spec.rb @@ -34,6 +34,12 @@ describe Utils::Git do File.open("LICENSE.txt", "w") { |f| f.write("LICENSE") } system git, "add", HOMEBREW_CACHE/"LICENSE.txt" system git, "commit", "-m", "'written to File'" + + File.open("LICENSE.txt", "w") { |f| f.write("test") } + system git, "add", HOMEBREW_CACHE/"LICENSE.txt" + system git, "commit", "-m", "'written to File'" + @cherry_pick_commit = `git rev-parse HEAD` + system git, "reset", "--hard", "HEAD^" end end @@ -43,8 +49,13 @@ describe Utils::Git do let(:files) { ["README.md", "LICENSE.txt"] } let(:files_hash1) { [@h3[0..6], ["LICENSE.txt"]] } let(:files_hash2) { [@h2[0..6], ["README.md"]] } + let(:cherry_pick_commit) { @cherry_pick_commit[0..6] } describe "#cherry_pick!" do + it "can cherry pick a commit" do + expect(described_class.cherry_pick!(HOMEBREW_CACHE, cherry_pick_commit)).to be_truthy + end + it "aborts when cherry picking an existing hash" do expect { described_class.cherry_pick!(HOMEBREW_CACHE, file_hash1)