Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
937b3143
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
937b3143
编写于
5月 24, 2020
作者:
G
GitLab Bot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add latest changes from gitlab-org/gitlab@master
上级
735e7717
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
50 addition
and
19 deletion
+50
-19
.rubocop.yml
.rubocop.yml
+0
-1
app/models/chat_team.rb
app/models/chat_team.rb
+1
-1
app/models/project.rb
app/models/project.rb
+5
-11
app/models/project_import_state.rb
app/models/project_import_state.rb
+1
-1
changelogs/unreleased/leaky-constant-fix-22.yml
changelogs/unreleased/leaky-constant-fix-22.yml
+5
-0
changelogs/unreleased/rails-logger-cop-1.yml
changelogs/unreleased/rails-logger-cop-1.yml
+5
-0
changelogs/unreleased/rails-logger-cop-2.yml
changelogs/unreleased/rails-logger-cop-2.yml
+5
-0
changelogs/unreleased/rails-logger-cop-3.yml
changelogs/unreleased/rails-logger-cop-3.yml
+5
-0
spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb
...ions/20191125114345_add_admin_mode_protected_path_spec.rb
+4
-5
spec/models/project_import_state_spec.rb
spec/models/project_import_state_spec.rb
+19
-0
未找到文件。
.rubocop.yml
浏览文件 @
937b3143
...
@@ -355,7 +355,6 @@ RSpec/LeakyConstantDeclaration:
...
@@ -355,7 +355,6 @@ RSpec/LeakyConstantDeclaration:
-
'
spec/lib/gitlab/quick_actions/dsl_spec.rb'
-
'
spec/lib/gitlab/quick_actions/dsl_spec.rb'
-
'
spec/lib/marginalia_spec.rb'
-
'
spec/lib/marginalia_spec.rb'
-
'
spec/mailers/notify_spec.rb'
-
'
spec/mailers/notify_spec.rb'
-
'
spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb'
-
'
spec/models/concerns/batch_destroy_dependent_associations_spec.rb'
-
'
spec/models/concerns/batch_destroy_dependent_associations_spec.rb'
-
'
spec/models/concerns/bulk_insert_safe_spec.rb'
-
'
spec/models/concerns/bulk_insert_safe_spec.rb'
-
'
spec/models/concerns/bulk_insertable_associations_spec.rb'
-
'
spec/models/concerns/bulk_insertable_associations_spec.rb'
...
...
app/models/chat_team.rb
浏览文件 @
937b3143
...
@@ -12,6 +12,6 @@ class ChatTeam < ApplicationRecord
...
@@ -12,6 +12,6 @@ class ChatTeam < ApplicationRecord
# Either the group is not found, or the user doesn't have the proper
# Either the group is not found, or the user doesn't have the proper
# access on the mattermost instance. In the first case, we're done either way
# access on the mattermost instance. In the first case, we're done either way
# in the latter case, we can't recover by retrying, so we just log what happened
# in the latter case, we can't recover by retrying, so we just log what happened
Rails
.
logger
.
error
(
"Mattermost team deletion failed:
#{
e
}
"
)
# rubocop:disable Gitlab/RailsLogger
Gitlab
::
AppLogger
.
error
(
"Mattermost team deletion failed:
#{
e
}
"
)
end
end
end
end
app/models/project.rb
浏览文件 @
937b3143
...
@@ -925,17 +925,15 @@ class Project < ApplicationRecord
...
@@ -925,17 +925,15 @@ class Project < ApplicationRecord
job_id
job_id
end
end
# rubocop:disable Gitlab/RailsLogger
def
log_import_activity
(
job_id
,
type: :import
)
def
log_import_activity
(
job_id
,
type: :import
)
job_type
=
type
.
to_s
.
capitalize
job_type
=
type
.
to_s
.
capitalize
if
job_id
if
job_id
Rails
.
l
ogger
.
info
(
"
#{
job_type
}
job scheduled for
#{
full_path
}
with job ID
#{
job_id
}
."
)
Gitlab
::
AppL
ogger
.
info
(
"
#{
job_type
}
job scheduled for
#{
full_path
}
with job ID
#{
job_id
}
."
)
else
else
Rails
.
l
ogger
.
error
(
"
#{
job_type
}
job failed to create for
#{
full_path
}
."
)
Gitlab
::
AppL
ogger
.
error
(
"
#{
job_type
}
job failed to create for
#{
full_path
}
."
)
end
end
end
end
# rubocop:enable Gitlab/RailsLogger
def
reset_cache_and_import_attrs
def
reset_cache_and_import_attrs
run_after_commit
do
run_after_commit
do
...
@@ -1776,17 +1774,15 @@ class Project < ApplicationRecord
...
@@ -1776,17 +1774,15 @@ class Project < ApplicationRecord
ensure_pages_metadatum
.
update!
(
deployed:
false
)
ensure_pages_metadatum
.
update!
(
deployed:
false
)
end
end
# rubocop:disable Gitlab/RailsLogger
def
write_repository_config
(
gl_full_path:
full_path
)
def
write_repository_config
(
gl_full_path:
full_path
)
# We'd need to keep track of project full path otherwise directory tree
# We'd need to keep track of project full path otherwise directory tree
# created with hashed storage enabled cannot be usefully imported using
# created with hashed storage enabled cannot be usefully imported using
# the import rake task.
# the import rake task.
repository
.
raw_repository
.
write_config
(
full_path:
gl_full_path
)
repository
.
raw_repository
.
write_config
(
full_path:
gl_full_path
)
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
rescue
Gitlab
::
Git
::
Repository
::
NoRepository
=>
e
Rails
.
l
ogger
.
error
(
"Error writing to .git/config for project
#{
full_path
}
(
#{
id
}
):
#{
e
.
message
}
."
)
Gitlab
::
AppL
ogger
.
error
(
"Error writing to .git/config for project
#{
full_path
}
(
#{
id
}
):
#{
e
.
message
}
."
)
nil
nil
end
end
# rubocop:enable Gitlab/RailsLogger
def
after_import
def
after_import
repository
.
expire_content_cache
repository
.
expire_content_cache
...
@@ -1829,17 +1825,15 @@ class Project < ApplicationRecord
...
@@ -1829,17 +1825,15 @@ class Project < ApplicationRecord
@pipeline_status
||=
Gitlab
::
Cache
::
Ci
::
ProjectPipelineStatus
.
load_for_project
(
self
)
@pipeline_status
||=
Gitlab
::
Cache
::
Ci
::
ProjectPipelineStatus
.
load_for_project
(
self
)
end
end
# rubocop:disable Gitlab/RailsLogger
def
add_export_job
(
current_user
:,
after_export_strategy:
nil
,
params:
{})
def
add_export_job
(
current_user
:,
after_export_strategy:
nil
,
params:
{})
job_id
=
ProjectExportWorker
.
perform_async
(
current_user
.
id
,
self
.
id
,
after_export_strategy
,
params
)
job_id
=
ProjectExportWorker
.
perform_async
(
current_user
.
id
,
self
.
id
,
after_export_strategy
,
params
)
if
job_id
if
job_id
Rails
.
l
ogger
.
info
"Export job started for project ID
#{
self
.
id
}
with job ID
#{
job_id
}
"
Gitlab
::
AppL
ogger
.
info
"Export job started for project ID
#{
self
.
id
}
with job ID
#{
job_id
}
"
else
else
Rails
.
l
ogger
.
error
"Export job failed to start for project ID
#{
self
.
id
}
"
Gitlab
::
AppL
ogger
.
error
"Export job failed to start for project ID
#{
self
.
id
}
"
end
end
end
end
# rubocop:enable Gitlab/RailsLogger
def
import_export_shared
def
import_export_shared
@import_export_shared
||=
Gitlab
::
ImportExport
::
Shared
.
new
(
self
)
@import_export_shared
||=
Gitlab
::
ImportExport
::
Shared
.
new
(
self
)
...
...
app/models/project_import_state.rb
浏览文件 @
937b3143
...
@@ -84,7 +84,7 @@ class ProjectImportState < ApplicationRecord
...
@@ -84,7 +84,7 @@ class ProjectImportState < ApplicationRecord
update_column
(
:last_error
,
sanitized_message
)
update_column
(
:last_error
,
sanitized_message
)
rescue
ActiveRecord
::
ActiveRecordError
=>
e
rescue
ActiveRecord
::
ActiveRecordError
=>
e
Rails
.
logger
.
error
(
"Error setting import status to failed:
#{
e
.
message
}
. Original error:
#{
sanitized_message
}
"
)
# rubocop:disable Gitlab/RailsLogger
Gitlab
::
AppLogger
.
error
(
"Error setting import status to failed:
#{
e
.
message
}
. Original error:
#{
sanitized_message
}
"
)
ensure
ensure
@errors
=
original_errors
@errors
=
original_errors
end
end
...
...
changelogs/unreleased/leaky-constant-fix-22.yml
0 → 100644
浏览文件 @
937b3143
---
title
:
Fix leaky constant issue in admin mode migration spec
merge_request
:
32074
author
:
Rajendra Kadam
type
:
fixed
changelogs/unreleased/rails-logger-cop-1.yml
0 → 100644
浏览文件 @
937b3143
---
title
:
Use applogger in project import state file
merge_request
:
32182
author
:
Rajendra Kadam
type
:
fixed
changelogs/unreleased/rails-logger-cop-2.yml
0 → 100644
浏览文件 @
937b3143
---
title
:
Use applogger in project.rb
merge_request
:
32183
author
:
Rajendra Kadam
type
:
fixed
changelogs/unreleased/rails-logger-cop-3.yml
0 → 100644
浏览文件 @
937b3143
---
title
:
Use applogger in chat_team.rb
merge_request
:
32184
author
:
Rajendra Kadam
type
:
fixed
spec/migrations/20191125114345_add_admin_mode_protected_path_spec.rb
浏览文件 @
937b3143
...
@@ -4,10 +4,9 @@ require 'spec_helper'
...
@@ -4,10 +4,9 @@ require 'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20191125114345_add_admin_mode_protected_path.rb'
)
require
Rails
.
root
.
join
(
'db'
,
'migrate'
,
'20191125114345_add_admin_mode_protected_path.rb'
)
describe
AddAdminModeProtectedPath
do
describe
AddAdminModeProtectedPath
do
ADMIN_MODE_ENDPOINT
=
'/admin/session'
subject
(
:migration
)
{
described_class
.
new
}
subject
(
:migration
)
{
described_class
.
new
}
let
(
:admin_mode_endpoint
)
{
'/admin/session'
}
let
(
:application_settings
)
{
table
(
:application_settings
)
}
let
(
:application_settings
)
{
table
(
:application_settings
)
}
context
'no settings available'
do
context
'no settings available'
do
...
@@ -30,7 +29,7 @@ describe AddAdminModeProtectedPath do
...
@@ -30,7 +29,7 @@ describe AddAdminModeProtectedPath do
application_settings
.
create!
(
protected_paths:
'{a,b,c}'
)
application_settings
.
create!
(
protected_paths:
'{a,b,c}'
)
protected_paths_before
=
%w[a b c]
protected_paths_before
=
%w[a b c]
protected_paths_after
=
protected_paths_before
.
dup
<<
ADMIN_MODE_ENDPOINT
protected_paths_after
=
protected_paths_before
.
dup
<<
admin_mode_endpoint
expect
{
migrate!
}.
to
change
{
application_settings
.
first
.
protected_paths
}.
from
(
protected_paths_before
).
to
(
protected_paths_after
)
expect
{
migrate!
}.
to
change
{
application_settings
.
first
.
protected_paths
}.
from
(
protected_paths_before
).
to
(
protected_paths_after
)
end
end
...
@@ -38,13 +37,13 @@ describe AddAdminModeProtectedPath do
...
@@ -38,13 +37,13 @@ describe AddAdminModeProtectedPath do
it
'new default includes admin mode endpoint'
do
it
'new default includes admin mode endpoint'
do
settings_before
=
application_settings
.
create!
settings_before
=
application_settings
.
create!
expect
(
settings_before
.
protected_paths
).
not_to
include
(
ADMIN_MODE_ENDPOINT
)
expect
(
settings_before
.
protected_paths
).
not_to
include
(
admin_mode_endpoint
)
migrate!
migrate!
application_settings
.
reset_column_information
application_settings
.
reset_column_information
settings_after
=
application_settings
.
create!
settings_after
=
application_settings
.
create!
expect
(
settings_after
.
protected_paths
).
to
include
(
ADMIN_MODE_ENDPOINT
)
expect
(
settings_after
.
protected_paths
).
to
include
(
admin_mode_endpoint
)
end
end
end
end
spec/models/project_import_state_spec.rb
浏览文件 @
937b3143
...
@@ -57,6 +57,25 @@ describe ProjectImportState, type: :model do
...
@@ -57,6 +57,25 @@ describe ProjectImportState, type: :model do
end
end
end
end
describe
'#mark_as_failed'
do
let
(
:error_message
)
{
'some message'
}
it
'logs error when update column fails'
do
allow
(
import_state
).
to
receive
(
:update_column
).
and_raise
(
ActiveRecord
::
ActiveRecordError
)
allow
(
Gitlab
::
AppLogger
).
to
receive
(
:error
)
import_state
.
mark_as_failed
(
error_message
)
expect
(
Gitlab
::
AppLogger
).
to
have_received
(
:error
)
end
it
'updates last_error with error message'
do
import_state
.
mark_as_failed
(
error_message
)
expect
(
import_state
.
last_error
).
to
eq
(
error_message
)
end
end
describe
'#human_status_name'
do
describe
'#human_status_name'
do
context
'when import_state exists'
do
context
'when import_state exists'
do
it
'returns the humanized status name'
do
it
'returns the humanized status name'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录