Commit f76d3eb7 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'mc/bug/remove-reliance-on-branch-context' into 'master'

Resolve project from branch repository

See merge request gitlab-org/gitlab!55694
parents f0acac26 4a164684
......@@ -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
---
title: Resolve project from branch in commit resolver.
merge_request: 55694
author:
type: fixed
......@@ -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