Commit 7cb51ba5 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix/import-issues-last-updated' into 'master'

Fix issues last update timestamp not preserved after importing a project

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19689 and https://gitlab.com/gitlab-org/gitlab-ce/issues/19792 (similar, but not the same)

Now `updated_at` should be the time from the original project.

See merge request !5253
parents 50abec8c cc6d3a83
...@@ -94,6 +94,7 @@ v 8.10.0 (unreleased) ...@@ -94,6 +94,7 @@ v 8.10.0 (unreleased)
- Redesign Builds and Pipelines pages - Redesign Builds and Pipelines pages
- Change status color and icon for running builds - Change status color and icon for running builds
- Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.` - Fix markdown rendering for: consecutive labels references, label references that begin with a digit or contains `.`
- Fix last update timestamp on issues not preserved on gitlab.com and project imports
v 8.9.6 v 8.9.6
- Fix importing of events under notes for GitLab projects. !5154 - Fix importing of events under notes for GitLab projects. !5154
......
...@@ -15,6 +15,7 @@ module Gitlab ...@@ -15,6 +15,7 @@ module Gitlab
end end
def execute def execute
ActiveRecord::Base.no_touching do
project_identifier = CGI.escape(project.import_source) project_identifier = CGI.escape(project.import_source)
# Issues && Comments # Issues && Comments
...@@ -39,9 +40,11 @@ module Gitlab ...@@ -39,9 +40,11 @@ module Gitlab
description: body, description: body,
title: issue["title"], title: issue["title"],
state: issue["state"], state: issue["state"],
updated_at: issue["updated_at"],
author_id: gl_user_id(project, issue["author"]["id"]) author_id: gl_user_id(project, issue["author"]["id"])
) )
end end
end
true true
end end
......
...@@ -12,7 +12,10 @@ module Gitlab ...@@ -12,7 +12,10 @@ module Gitlab
json = IO.read(@path) json = IO.read(@path)
@tree_hash = ActiveSupport::JSON.decode(json) @tree_hash = ActiveSupport::JSON.decode(json)
@project_members = @tree_hash.delete('project_members') @project_members = @tree_hash.delete('project_members')
ActiveRecord::Base.no_touching do
create_relations create_relations
end
rescue => e rescue => e
@shared.error(e) @shared.error(e)
false false
......
...@@ -30,6 +30,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do ...@@ -30,6 +30,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
expect(Event.where.not(data: nil).first.data[:ref]).not_to be_empty expect(Event.where.not(data: nil).first.data[:ref]).not_to be_empty
end end
it 'preserves updated_at on issues' do
restored_project_json
issue = Issue.where(description: 'Aliquam enim illo et possimus.').first
expect(issue.reload.updated_at.to_s).to eq('2016-06-14 15:02:47 UTC')
end
context 'event at forth level of the tree' do context 'event at forth level of the tree' do
let(:event) { Event.where(title: 'test levels').first } let(:event) { Event.where(title: 'test levels').first }
......
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