summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2016-12-19 15:08:17 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2016-12-19 15:08:17 +0000
commitffcd20cec8b848e24b54fc37658d9841d34f5c35 (patch)
tree5cf52116f191549d2abc2cf279913a45b4eaa08e
parent16f950b4c321708c8701e031316b5ed91c50f2eb (diff)
parent527428a78ed4834b936b0aa7a6da430bf66baa2d (diff)
downloadgitlab-ce-ffcd20cec8b848e24b54fc37658d9841d34f5c35.tar.gz
Merge branch 'fix/import-export-build-token' into 'master'
Fix duplicated build token problem importing projects Reset token so duplicated builds do not thrown an error on import - [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if it does - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23475 See merge request !8171
-rw-r--r--changelogs/unreleased/fix-import-export-build-token.yml4
-rw-r--r--lib/gitlab/import_export/relation_factory.rb2
-rw-r--r--spec/lib/gitlab/import_export/project.json4
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb8
4 files changed, 17 insertions, 1 deletions
diff --git a/changelogs/unreleased/fix-import-export-build-token.yml b/changelogs/unreleased/fix-import-export-build-token.yml
new file mode 100644
index 00000000000..622487e6829
--- /dev/null
+++ b/changelogs/unreleased/fix-import-export-build-token.yml
@@ -0,0 +1,4 @@
+---
+title: Fix Import/Export duplicated builds error
+merge_request:
+author:
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index a0e80fccad9..9b590bcee8d 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -99,6 +99,8 @@ module Gitlab
def generate_imported_object
if BUILD_MODELS.include?(@relation_name) # call #trace= method after assigning the other attributes
trace = @relation_hash.delete('trace')
+ @relation_hash.delete('token')
+
imported_object do |object|
object.trace = trace
object.commit_id = nil
diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json
index ed9df468ced..1e5901651ae 100644
--- a/spec/lib/gitlab/import_export/project.json
+++ b/spec/lib/gitlab/import_export/project.json
@@ -6548,7 +6548,9 @@
"url": null
},
"erased_by_id": null,
- "erased_at": null
+ "erased_at": null,
+ "type": "Ci::Build",
+ "token": "abcd"
},
{
"id": 72,
diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
index 3038ab53ad8..4b07fa53bf5 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -189,6 +189,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
end
end
end
+
+ context 'when there is an existing build with build token' do
+ it 'restores project json correctly' do
+ create(:ci_build, token: 'abcd')
+
+ expect(restored_project_json).to be true
+ end
+ end
end
end
end