summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-02-16 14:35:48 +0100
committerRémy Coutable <remy@rymai.me>2017-02-23 19:06:00 +0100
commit3eb0354061b6c2ad39c90c9a3e9a5afa62e7685f (patch)
tree01147e7de1e4c50834c62aef7369782d2f8ad2a2 /spec
parent43fa9c1f1a40903f6416b954c326d67259c7290a (diff)
downloadgitlab-ce-3eb0354061b6c2ad39c90c9a3e9a5afa62e7685f.tar.gz
Make Git history follow renames again by performing the --skip in Ruby
This hack is needed because of an issue when --follow and --skip are passed to git log at the same time. See https://gitlab.com/gitlab-org/gitlab-ce/issues/23062 Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb96
1 files changed, 85 insertions, 11 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 2a915bf426f..05594089db3 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -546,7 +546,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
repository.log(options.merge(path: "encoding"))
end
- it "should not follow renames" do
+ it "does not follow renames" do
expect(log_commits).to include(commit_with_new_name)
expect(log_commits).to include(rename_commit)
expect(log_commits).not_to include(commit_with_old_name)
@@ -554,14 +554,88 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
context "and 'path' is a file that matches the new filename" do
- let(:log_commits) do
- repository.log(options.merge(path: "encoding/CHANGELOG"))
+ context 'without offset' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG"))
+ end
+
+ it "follows renames" do
+ expect(log_commits).to include(commit_with_new_name)
+ expect(log_commits).to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
+ end
end
- it "should follow renames" do
- expect(log_commits).to include(commit_with_new_name)
- expect(log_commits).to include(rename_commit)
- expect(log_commits).to include(commit_with_old_name)
+ context 'with offset=1' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG", offset: 1))
+ end
+
+ it "follows renames and skip the latest commit" do
+ expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
+ end
+ end
+
+ context 'with offset=1', 'and limit=1' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG", offset: 1, limit: 1))
+ end
+
+ it "follows renames, skip the latest commit and return only one commit" do
+ expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).to include(rename_commit)
+ expect(log_commits).not_to include(commit_with_old_name)
+ end
+ end
+
+ context 'with offset=1', 'and limit=2' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG", offset: 1, limit: 2))
+ end
+
+ it "follows renames, skip the latest commit and return only two commits" do
+ expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
+ end
+ end
+
+ context 'with offset=2' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG", offset: 2))
+ end
+
+ it "follows renames and skip the latest commit" do
+ expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).not_to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
+ end
+ end
+
+ context 'with offset=2', 'and limit=1' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG", offset: 2, limit: 1))
+ end
+
+ it "follows renames, skip the two latest commit and return only one commit" do
+ expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).not_to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
+ end
+ end
+
+ context 'with offset=2', 'and limit=2' do
+ let(:log_commits) do
+ repository.log(options.merge(path: "encoding/CHANGELOG", offset: 2, limit: 2))
+ end
+
+ it "follows renames, skip the two latest commit and return only one commit" do
+ expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).not_to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
+ end
end
end
@@ -570,17 +644,17 @@ describe Gitlab::Git::Repository, seed_helper: true do
repository.log(options.merge(path: "CHANGELOG"))
end
- it "should not follow renames" do
- expect(log_commits).to include(commit_with_old_name)
- expect(log_commits).to include(rename_commit)
+ it "does not follow renames" do
expect(log_commits).not_to include(commit_with_new_name)
+ expect(log_commits).to include(rename_commit)
+ expect(log_commits).to include(commit_with_old_name)
end
end
context "unknown ref" do
let(:log_commits) { repository.log(options.merge(ref: 'unknown')) }
- it "should return empty" do
+ it "return an empty array" do
expect(log_commits).to eq([])
end
end