summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-15 18:14:41 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-18 12:15:50 -0300
commitd13bba44f0de0aa5df00c37b4f743504d187bb03 (patch)
treec566729ef0fb665ccc224797d8b6ad716ed01d56
parent70e6fa31064984c691e283eddf6712bc031e0842 (diff)
downloadgitlab-ce-d13bba44f0de0aa5df00c37b4f743504d187bb03.tar.gz
Use GitHub Issue/PR number as iid to keep references
With these changes we don’t lost the issue/pr references when importing them to GitLab.
-rw-r--r--app/models/concerns/internal_id.rb10
-rw-r--r--lib/gitlab/github_import/issue_formatter.rb1
-rw-r--r--lib/gitlab/github_import/pull_request_formatter.rb1
-rw-r--r--spec/lib/gitlab/github_import/issue_formatter_spec.rb2
-rw-r--r--spec/lib/gitlab/github_import/pull_request_formatter_spec.rb3
5 files changed, 13 insertions, 4 deletions
diff --git a/app/models/concerns/internal_id.rb b/app/models/concerns/internal_id.rb
index 51288094ef1..5382dde6765 100644
--- a/app/models/concerns/internal_id.rb
+++ b/app/models/concerns/internal_id.rb
@@ -7,11 +7,13 @@ module InternalId
end
def set_iid
- records = project.send(self.class.name.tableize)
- records = records.with_deleted if self.paranoid?
- max_iid = records.maximum(:iid)
+ if iid.blank?
+ records = project.send(self.class.name.tableize)
+ records = records.with_deleted if self.paranoid?
+ max_iid = records.maximum(:iid)
- self.iid = max_iid.to_i + 1
+ self.iid = max_iid.to_i + 1
+ end
end
def to_param
diff --git a/lib/gitlab/github_import/issue_formatter.rb b/lib/gitlab/github_import/issue_formatter.rb
index 1e3ba44f27c..acb332cb0cb 100644
--- a/lib/gitlab/github_import/issue_formatter.rb
+++ b/lib/gitlab/github_import/issue_formatter.rb
@@ -3,6 +3,7 @@ module Gitlab
class IssueFormatter < BaseFormatter
def attributes
{
+ iid: number,
project: project,
title: raw_data.title,
description: description,
diff --git a/lib/gitlab/github_import/pull_request_formatter.rb b/lib/gitlab/github_import/pull_request_formatter.rb
index 4e507b090e8..5ee8a14624a 100644
--- a/lib/gitlab/github_import/pull_request_formatter.rb
+++ b/lib/gitlab/github_import/pull_request_formatter.rb
@@ -3,6 +3,7 @@ module Gitlab
class PullRequestFormatter < BaseFormatter
def attributes
{
+ iid: number,
title: raw_data.title,
description: description,
source_project: source_project,
diff --git a/spec/lib/gitlab/github_import/issue_formatter_spec.rb b/spec/lib/gitlab/github_import/issue_formatter_spec.rb
index fd05428b322..4f3d7f4405b 100644
--- a/spec/lib/gitlab/github_import/issue_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/issue_formatter_spec.rb
@@ -30,6 +30,7 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
it 'returns formatted attributes' do
expected = {
+ iid: 1347,
project: project,
title: 'Found a bug',
description: "*Created by: octocat*\n\nI'm having a problem with this.",
@@ -50,6 +51,7 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
it 'returns formatted attributes' do
expected = {
+ iid: 1347,
project: project,
title: 'Found a bug',
description: "*Created by: octocat*\n\nI'm having a problem with this.",
diff --git a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
index e49dcb42342..11249e57ca8 100644
--- a/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+++ b/spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
@@ -35,6 +35,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
it 'returns formatted attributes' do
expected = {
+ iid: 1347,
title: 'New feature',
description: "*Created by: octocat*\n\nPlease pull these awesome changes",
source_project: project,
@@ -58,6 +59,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
it 'returns formatted attributes' do
expected = {
+ iid: 1347,
title: 'New feature',
description: "*Created by: octocat*\n\nPlease pull these awesome changes",
source_project: project,
@@ -81,6 +83,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
it 'returns formatted attributes' do
expected = {
+ iid: 1347,
title: 'New feature',
description: "*Created by: octocat*\n\nPlease pull these awesome changes",
source_project: project,