Commit 9e9a2cc9 authored by Robert May's avatar Robert May

Return commits by author

First bit of roughing out the return of commits based on author.
parent 05f99b90
......@@ -139,6 +139,7 @@ class Repository
repo: raw_repository,
ref: ref,
path: opts[:path],
author: opts[:author],
follow: Array(opts[:path]).length == 1,
limit: opts[:limit],
offset: opts[:offset],
......
......@@ -322,6 +322,7 @@ module Gitlab
limit: 10,
offset: 0,
path: nil,
author: nil,
follow: false,
skip_merges: false,
after: nil,
......
......@@ -324,6 +324,7 @@ module Gitlab
request.after = GitalyClient.timestamp(options[:after]) if options[:after]
request.before = GitalyClient.timestamp(options[:before]) if options[:before]
request.revision = encode_binary(options[:ref]) if options[:ref]
request.author = encode_binary(options[:author]) if options[:author]
request.order = options[:order].upcase.sub('DEFAULT', 'NONE') if options[:order].present?
request.paths = encode_repeated(Array(options[:path])) if options[:path].present?
......
......@@ -306,5 +306,19 @@ describe Gitlab::GitalyClient::CommitService do
client.find_commits(order: 'topo')
end
it 'sends an RPC request with an author' do
request = Gitaly::FindCommitsRequest.new(
repository: repository_message,
disable_walk: true,
order: 'NONE',
author: "Billy Baggins <bilbo@shire.com>"
)
expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:find_commits)
.with(request, kind_of(Hash)).and_return([])
client.find_commits(order: 'default', author: "Billy Baggins <bilbo@shire.com>")
end
end
end
......@@ -320,6 +320,20 @@ describe Repository do
end
end
context "when 'author' is set" do
let(:commit) { repository.commits(nil, limit: 1).first }
let(:known_author) { "#{commit.author_name} <#{commit.author_email}>" }
let(:unknown_author) { "The Man With No Name <zapp@brannigan.com>" }
it "returns commits from that author" do
expect(repository.commits(nil, author: known_author, limit: 1).size).to be > 0
end
it "doesn't returns commits from an unknown author" do
expect(repository.commits(nil, author: unknown_author, limit: 1).size).to eq(0)
end
end
context "when 'all' flag is set" do
it 'returns every commit from the repository' do
expect(repository.commits(nil, all: true, limit: 60).size).to eq(60)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment