Commit 0a1f0bfc authored by Matija Čupić's avatar Matija Čupić

Resolve project from branch repository

parent e367975a
......@@ -30,8 +30,6 @@ module Mutations
def resolve(project_path:, name:, ref:)
project = authorized_find!(project_path)
context.scoped_set!(:branch_project, project)
result = ::Branches::CreateService.new(project, current_user)
.execute(name, ref)
......
......@@ -10,8 +10,9 @@ module Resolvers
return unless branch
commit = branch.dereferenced_target
project = Project.find_by_full_path(commit.repository.gl_project_path)
::Commit.new(commit, context[:branch_project]) if commit
::Commit.new(commit, project) if commit
end
end
end
......@@ -20,6 +20,7 @@ module Gitlab
].freeze
attr_accessor(*SERIALIZE_KEYS)
attr_reader :repository
def ==(other)
return false unless other.is_a?(Gitlab::Git::Commit)
......
......@@ -15,6 +15,10 @@ RSpec.describe Resolvers::BranchCommitResolver do
is_expected.to eq(repository.commits('master', limit: 1).last)
end
it 'sets project container' do
expect(commit.container).to eq(repository.project)
end
context 'when branch does not exist' do
let(:branch) { nil }
......
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