Commit c87235a2 authored by Robert Speicher's avatar Robert Speicher

Merge branch '21569-dont-add-created-by-for-matched-users' into 'master'

Only add original author tag line when importing from GitHub if there isn't a linked GitLab account

## What does this MR do?
If there we've found a linked GitLab user for a creator of an issue or comment don't add the 'Created By:' line.

## What are the relevant issue numbers?

Closes #21569

See merge request !6081
parents 3de4e8b5 4a788f8a
...@@ -89,6 +89,7 @@ v 8.12.0 (unreleased) ...@@ -89,6 +89,7 @@ v 8.12.0 (unreleased)
- Fix repo title alignment (ClemMakesApps) - Fix repo title alignment (ClemMakesApps)
- Change update interval of contacted_at - Change update interval of contacted_at
- Fix branch title trailing space on hover (ClemMakesApps) - Fix branch title trailing space on hover (ClemMakesApps)
- Don't include 'Created By' tag line when importing from GitHub if there is a linked GitLab account (EspadaV8)
- Award emoji tooltips containing more than 10 usernames are now truncated !4780 (jlogandavison) - Award emoji tooltips containing more than 10 usernames are now truncated !4780 (jlogandavison)
- Fix duplicate "me" in award emoji tooltip !5218 (jlogandavison) - Fix duplicate "me" in award emoji tooltip !5218 (jlogandavison)
- Order award emoji tooltips in order they were added (EspadaV8) - Order award emoji tooltips in order they were added (EspadaV8)
......
...@@ -20,6 +20,11 @@ module Gitlab ...@@ -20,6 +20,11 @@ module Gitlab
find_by("identities.extern_uid = ? AND identities.provider = 'github'", github_id.to_s). find_by("identities.extern_uid = ? AND identities.provider = 'github'", github_id.to_s).
try(:id) try(:id)
end end
def gitlab_author_id
return @gitlab_author_id if defined?(@gitlab_author_id)
@gitlab_author_id = gitlab_user_id(raw_data.user.id)
end
end end
end end
end end
...@@ -21,7 +21,7 @@ module Gitlab ...@@ -21,7 +21,7 @@ module Gitlab
end end
def author_id def author_id
gitlab_user_id(raw_data.user.id) || project.creator_id gitlab_author_id || project.creator_id
end end
def body def body
...@@ -52,8 +52,12 @@ module Gitlab ...@@ -52,8 +52,12 @@ module Gitlab
end end
def note def note
if gitlab_author_id
body
else
formatter.author_line(author) + body formatter.author_line(author) + body
end end
end
def type def type
'LegacyDiffNote' if on_diff? 'LegacyDiffNote' if on_diff?
......
...@@ -49,7 +49,7 @@ module Gitlab ...@@ -49,7 +49,7 @@ module Gitlab
end end
def author_id def author_id
gitlab_user_id(raw_data.user.id) || project.creator_id gitlab_author_id || project.creator_id
end end
def body def body
...@@ -57,7 +57,11 @@ module Gitlab ...@@ -57,7 +57,11 @@ module Gitlab
end end
def description def description
@formatter.author_line(author) + body if gitlab_author_id
body
else
formatter.author_line(author) + body
end
end end
def milestone def milestone
......
...@@ -77,7 +77,7 @@ module Gitlab ...@@ -77,7 +77,7 @@ module Gitlab
end end
def author_id def author_id
gitlab_user_id(raw_data.user.id) || project.creator_id gitlab_author_id || project.creator_id
end end
def body def body
...@@ -85,8 +85,12 @@ module Gitlab ...@@ -85,8 +85,12 @@ module Gitlab
end end
def description def description
if gitlab_author_id
body
else
formatter.author_line(author) + body formatter.author_line(author) + body
end end
end
def milestone def milestone
if raw_data.milestone.present? if raw_data.milestone.present?
......
...@@ -73,6 +73,12 @@ describe Gitlab::GithubImport::CommentFormatter, lib: true do ...@@ -73,6 +73,12 @@ describe Gitlab::GithubImport::CommentFormatter, lib: true do
gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github') gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
expect(comment.attributes.fetch(:author_id)).to eq gl_user.id expect(comment.attributes.fetch(:author_id)).to eq gl_user.id
end end
it 'returns note without created at tag line' do
create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
expect(comment.attributes.fetch(:note)).to eq("I'm having a problem with this.")
end
end end
end end
end end
...@@ -109,6 +109,12 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do ...@@ -109,6 +109,12 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
expect(issue.attributes.fetch(:author_id)).to eq gl_user.id expect(issue.attributes.fetch(:author_id)).to eq gl_user.id
end end
it 'returns description without created at tag line' do
create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
expect(issue.attributes.fetch(:description)).to eq("I'm having a problem with this.")
end
end end
end end
......
...@@ -140,6 +140,12 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do ...@@ -140,6 +140,12 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
expect(pull_request.attributes.fetch(:author_id)).to eq gl_user.id expect(pull_request.attributes.fetch(:author_id)).to eq gl_user.id
end end
it 'returns description without created at tag line' do
create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
expect(pull_request.attributes.fetch(:description)).to eq('Please pull these awesome changes')
end
end end
context 'when it has a milestone' do context 'when it has a milestone' do
......
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