Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
526f94808fb6
Commit
526f9480
authored
Feb 22, 2017
by
Douwe Maan
Browse files
Fix code for cops
parent
2f73ee08314b
Changes
44
Hide whitespace changes
Inline
Side-by-side
app/controllers/concerns/creates_commit.rb
View file @
526f9480
...
...
@@ -101,13 +101,14 @@
# TODO: We should really clean this up
def
set_commit_variables
@mr_source_project
=
if
can?
(
current_user
,
:push_code
,
@project
)
# Edit file in this project
@project
else
# Merge request from fork to this project
current_user
.
fork_of
(
@project
)
end
@mr_source_project
=
if
can?
(
current_user
,
:push_code
,
@project
)
# Edit file in this project
@project
else
# Merge request from fork to this project
current_user
.
fork_of
(
@project
)
end
# Merge request to this project
@mr_target_project
=
@project
...
...
app/controllers/projects/git_http_client_controller.rb
View file @
526f9480
...
...
@@ -76,11 +76,12 @@
return
@project
if
defined?
(
@project
)
project_id
,
_
=
project_id_with_suffix
@project
=
if
project_id
.
blank?
nil
else
Project
.
find_by_full_path
(
"
#{
params
[
:namespace_id
]
}
/
#{
project_id
}
"
)
end
@project
=
if
project_id
.
blank?
nil
else
Project
.
find_by_full_path
(
"
#{
params
[
:namespace_id
]
}
/
#{
project_id
}
"
)
end
end
# This method returns two values so that we can parse
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
526f9480
...
...
@@ -381,14 +381,15 @@
end
def
merge_widget_refresh
@status
=
if
merge_request
.
merge_when_build_succeeds
:merge_when_build_succeeds
else
# Only MRs that can be merged end in this action
# MR can be already picked up for merge / merged already or can be waiting for worker to be picked up
# in last case it does not have any special status. Possible error is handled inside widget js function
:success
end
@status
=
if
merge_request
.
merge_when_build_succeeds
:merge_when_build_succeeds
else
# Only MRs that can be merged end in this action
# MR can be already picked up for merge / merged already or can be waiting for worker to be picked up
# in last case it does not have any special status. Possible error is handled inside widget js function
:success
end
render
'merge'
end
...
...
app/controllers/sessions_controller.rb
View file @
526f9480
...
...
@@ -15,11 +15,12 @@
def
new
set_minimum_password_length
@ldap_servers
=
if
Gitlab
.
config
.
ldap
.
enabled
Gitlab
::
LDAP
::
Config
.
servers
else
[]
end
@ldap_servers
=
if
Gitlab
.
config
.
ldap
.
enabled
Gitlab
::
LDAP
::
Config
.
servers
else
[]
end
super
end
...
...
app/finders/notes_finder.rb
View file @
526f9480
...
...
@@ -28,11 +28,12 @@
private
def
init_collection
@notes
=
if
@params
[
:target_id
]
on_target
(
@params
[
:target_type
],
@params
[
:target_id
])
else
notes_of_any_type
end
@notes
=
if
@params
[
:target_id
]
on_target
(
@params
[
:target_type
],
@params
[
:target_id
])
else
notes_of_any_type
end
end
def
notes_of_any_type
...
...
app/helpers/application_helper.rb
View file @
526f9480
...
...
@@ -69,11 +69,12 @@
end
def
avatar_icon
(
user_or_email
=
nil
,
size
=
nil
,
scale
=
2
)
user
=
if
user_or_email
.
is_a?
(
User
)
user_or_email
else
User
.
find_by_any_email
(
user_or_email
.
try
(
:downcase
))
end
user
=
if
user_or_email
.
is_a?
(
User
)
user_or_email
else
User
.
find_by_any_email
(
user_or_email
.
try
(
:downcase
))
end
if
user
user
.
avatar_url
(
size
)
||
default_avatar
...
...
app/helpers/blob_helper.rb
View file @
526f9480
...
...
@@ -153,16 +153,17 @@
# Because we are opionated we set the cache headers ourselves.
response
.
cache_control
[
:public
]
=
@project
.
public?
response
.
cache_control
[
:max_age
]
=
if
@ref
&&
@commit
&&
@ref
==
@commit
.
id
# This is a link to a commit by its commit SHA. That means that the blob
# is immutable. The only reason to invalidate the cache is if the commit
# was deleted or if the user lost access to the repository.
Blob
::
CACHE_TIME_IMMUTABLE
else
# A branch or tag points at this blob. That means that the expected blob
# value may change over time.
Blob
::
CACHE_TIME
end
response
.
cache_control
[
:max_age
]
=
if
@ref
&&
@commit
&&
@ref
==
@commit
.
id
# This is a link to a commit by its commit SHA. That means that the blob
# is immutable. The only reason to invalidate the cache is if the commit
# was deleted or if the user lost access to the repository.
Blob
::
CACHE_TIME_IMMUTABLE
else
# A branch or tag points at this blob. That means that the expected blob
# value may change over time.
Blob
::
CACHE_TIME
end
response
.
etag
=
@blob
.
id
!
stale
...
...
app/helpers/submodule_helper.rb
View file @
526f9480
...
...
@@ -38,7 +38,7 @@
def
self_url?
(
url
,
namespace
,
project
)
return
true
if
url
==
[
Gitlab
.
config
.
gitlab
.
url
,
'/'
,
namespace
,
'/'
,
project
,
'.git'
].
join
(
''
)
project
,
'.git'
].
join
(
''
)
url
==
gitlab_shell
.
url_to_repo
([
namespace
,
'/'
,
project
].
join
(
''
))
end
...
...
app/mailers/repository_check_mailer.rb
View file @
526f9480
class
RepositoryCheckMailer
<
BaseMailer
def
notify
(
failed_count
)
@message
=
if
failed_count
==
1
"One project failed its last repository check"
else
"
#{
failed_count
}
projects failed their last repository check"
end
@message
=
if
failed_count
==
1
"One project failed its last repository check"
else
"
#{
failed_count
}
projects failed their last repository check"
end
mail
(
to:
User
.
admins
.
pluck
(
:email
),
...
...
app/models/commit.rb
View file @
526f9480
...
...
@@ -122,11 +122,12 @@
def
full_title
return
@full_title
if
@full_title
@full_title
=
if
safe_message
.
blank?
no_commit_message
else
safe_message
.
split
(
"
\n
"
,
2
).
first
end
@full_title
=
if
safe_message
.
blank?
no_commit_message
else
safe_message
.
split
(
"
\n
"
,
2
).
first
end
end
# Returns the commits description
...
...
app/models/concerns/case_sensitivity.rb
View file @
526f9480
...
...
@@ -13,11 +13,12 @@
params
.
each
do
|
key
,
value
|
column
=
ActiveRecord
::
Base
.
connection
.
quote_table_name
(
key
)
condition
=
if
cast_lower
"LOWER(
#{
column
}
) = LOWER(:value)"
else
"
#{
column
}
= :value"
end
condition
=
if
cast_lower
"LOWER(
#{
column
}
) = LOWER(:value)"
else
"
#{
column
}
= :value"
end
criteria
=
criteria
.
where
(
condition
,
value:
value
)
end
...
...
app/models/concerns/sortable.rb
View file @
526f9480
...
...
@@ -46,11 +46,12 @@
where
(
"label_links.target_id =
#{
target_column
}
"
).
reorder
(
nil
)
query
=
if
target_type_column
query
.
where
(
"label_links.target_type =
#{
target_type_column
}
"
)
else
query
.
where
(
label_links:
{
target_type:
target_type
})
end
query
=
if
target_type_column
query
.
where
(
"label_links.target_type =
#{
target_type_column
}
"
)
else
query
.
where
(
label_links:
{
target_type:
target_type
})
end
query
=
query
.
where
.
not
(
title:
excluded_labels
)
if
excluded_labels
.
present?
...
...
app/models/network/graph.rb
View file @
526f9480
...
...
@@ -188,11 +188,12 @@
end
# and mark it as reserved
min_time
=
if
parent_time
.
nil?
leaves
.
first
.
time
else
parent_time
+
1
end
min_time
=
if
parent_time
.
nil?
leaves
.
first
.
time
else
parent_time
+
1
end
max_time
=
leaves
.
last
.
time
leaves
.
last
.
parents
(
@map
).
each
do
|
parent
|
...
...
app/models/project.rb
View file @
526f9480
...
...
@@ -453,13 +453,14 @@
end
def
add_import_job
job_id
=
if
forked?
RepositoryForkWorker
.
perform_async
(
id
,
forked_from_project
.
repository_storage_path
,
forked_from_project
.
path_with_namespace
,
self
.
namespace
.
full_path
)
else
RepositoryImportWorker
.
perform_async
(
self
.
id
)
end
job_id
=
if
forked?
RepositoryForkWorker
.
perform_async
(
id
,
forked_from_project
.
repository_storage_path
,
forked_from_project
.
path_with_namespace
,
self
.
namespace
.
full_path
)
else
RepositoryImportWorker
.
perform_async
(
self
.
id
)
end
if
job_id
Rails
.
logger
.
info
"Import job started for
#{
path_with_namespace
}
with job ID
#{
job_id
}
"
...
...
app/models/project_services/pushover_service.rb
View file @
526f9480
...
...
@@ -72,13 +72,14 @@
before
=
data
[
:before
]
after
=
data
[
:after
]
message
=
if
Gitlab
::
Git
.
blank_ref?
(
before
)
"
#{
data
[
:user_name
]
}
pushed new branch
\"
#{
ref
}
\"
."
elsif
Gitlab
::
Git
.
blank_ref?
(
after
)
"
#{
data
[
:user_name
]
}
deleted branch
\"
#{
ref
}
\"
."
else
"
#{
data
[
:user_name
]
}
push to branch
\"
#{
ref
}
\"
."
end
message
=
if
Gitlab
::
Git
.
blank_ref?
(
before
)
"
#{
data
[
:user_name
]
}
pushed new branch
\"
#{
ref
}
\"
."
elsif
Gitlab
::
Git
.
blank_ref?
(
after
)
"
#{
data
[
:user_name
]
}
deleted branch
\"
#{
ref
}
\"
."
else
"
#{
data
[
:user_name
]
}
push to branch
\"
#{
ref
}
\"
."
end
if
data
[
:total_commits_count
]
>
0
message
<<
"
\n
Total commits count:
#{
data
[
:total_commits_count
]
}
"
...
...
app/services/system_note_service.rb
View file @
526f9480
...
...
@@ -408,12 +408,13 @@
# Initial scope should be system notes of this noteable type
notes
=
Note
.
system
.
where
(
noteable_type:
noteable
.
class
)
notes
=
if
noteable
.
is_a?
(
Commit
)
# Commits have non-integer IDs, so they're stored in `commit_id`
notes
.
where
(
commit_id:
noteable
.
id
)
else
notes
.
where
(
noteable_id:
noteable
.
id
)
end
notes
=
if
noteable
.
is_a?
(
Commit
)
# Commits have non-integer IDs, so they're stored in `commit_id`
notes
.
where
(
commit_id:
noteable
.
id
)
else
notes
.
where
(
noteable_id:
noteable
.
id
)
end
notes_for_mentioner
(
mentioner
,
noteable
,
notes
).
exists?
end
...
...
config/initializers/1_settings.rb
View file @
526f9480
...
...
@@ -14,9 +14,10 @@
end
def
build_gitlab_ci_url
custom_port
=
if
on_standard_port?
(
gitlab
)
nil
else
":
#{
gitlab
.
port
}
"
end
custom_port
=
if
on_standard_port?
(
gitlab
)
nil
else
":
#{
gitlab
.
port
}
"
end
[
gitlab
.
protocol
,
...
...
@@ -22,8 +23,8 @@
[
gitlab
.
protocol
,
"://"
,
gitlab
.
host
,
custom_port
,
gitlab
.
relative_url_root
"://"
,
gitlab
.
host
,
custom_port
,
gitlab
.
relative_url_root
].
join
(
''
)
end
...
...
@@ -81,9 +82,9 @@
def
base_url
(
config
)
custom_port
=
on_standard_port?
(
config
)
?
nil
:
":
#{
config
.
port
}
"
[
config
.
protocol
,
"://"
,
config
.
host
,
custom_port
"://"
,
config
.
host
,
custom_port
]
end
...
...
@@ -160,15 +161,16 @@
github_settings
[
"args"
]
||=
Settingslogic
.
new
({})
github_settings
[
"args"
][
"client_options"
]
=
if
github_settings
[
"url"
].
include?
(
github_default_url
)
OmniAuth
::
Strategies
::
GitHub
.
default_options
[
:client_options
]
else
{
"site"
=>
File
.
join
(
github_settings
[
"url"
],
"api/v3"
),
"authorize_url"
=>
File
.
join
(
github_settings
[
"url"
],
"login/oauth/authorize"
),
"token_url"
=>
File
.
join
(
github_settings
[
"url"
],
"login/oauth/access_token"
)
}
end
github_settings
[
"args"
][
"client_options"
]
=
if
github_settings
[
"url"
].
include?
(
github_default_url
)
OmniAuth
::
Strategies
::
GitHub
.
default_options
[
:client_options
]
else
{
"site"
=>
File
.
join
(
github_settings
[
"url"
],
"api/v3"
),
"authorize_url"
=>
File
.
join
(
github_settings
[
"url"
],
"login/oauth/authorize"
),
"token_url"
=>
File
.
join
(
github_settings
[
"url"
],
"login/oauth/access_token"
)
}
end
end
Settings
[
'shared'
]
||=
Settingslogic
.
new
({})
...
...
lib/api/api_guard.rb
View file @
526f9480
...
...
@@ -115,7 +115,7 @@
def
install_error_responders
(
base
)
error_classes
=
[
MissingTokenError
,
TokenNotFoundError
,
ExpiredError
,
RevokedError
,
InsufficientScopeError
]
ExpiredError
,
RevokedError
,
InsufficientScopeError
]
base
.
send
:rescue_from
,
*
error_classes
,
oauth2_bearer_token_error_handler
end
...
...
lib/api/award_emoji.rb
View file @
526f9480
...
...
@@ -16,7 +16,7 @@
end
[
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/award_emoji"
,
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/notes/:note_id/award_emoji"
":id/
#{
awardable_string
}
/:
#{
awardable_id_string
}
/notes/:note_id/award_emoji"
].
each
do
|
endpoint
|
desc
'Get a list of project +awardable+ award emoji'
do
...
...
lib/banzai/filter/abstract_reference_filter.rb
View file @
526f9480
...
...
@@ -160,11 +160,12 @@
data
=
data_attributes_for
(
link_content
||
match
,
project
,
object
,
link:
!!
link_content
)
url
=
if
matches
.
names
.
include?
(
"url"
)
&&
matches
[
:url
]
matches
[
:url
]
else
url_for_object_cached
(
object
,
project
)
end
url
=
if
matches
.
names
.
include?
(
"url"
)
&&
matches
[
:url
]
matches
[
:url
]
else
url_for_object_cached
(
object
,
project
)
end
content
=
link_content
||
object_link_text
(
object
,
matches
)
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment