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
5238f517eeb4
Commit
5238f517
authored
Jan 29, 2020
by
GitLab Bot
Browse files
Add latest changes from gitlab-org/gitlab@master
parent
5137254cfcca
Changes
68
Hide whitespace changes
Inline
Side-by-side
GITALY_SERVER_VERSION
View file @
5238f517
1.8
3
.0
1.8
5
.0
Gemfile
View file @
5238f517
...
...
@@ -456,7 +456,7 @@
end
# Gitaly GRPC protocol definitions
gem
'
gitaly
'
,
'~> 1.8
1
.0'
gem
'
gitaly
'
,
'~> 1.8
5
.0'
gem
'
grpc
'
,
'~> 1.24.0'
...
...
Gemfile.lock
View file @
5238f517
...
...
@@ -360,7 +360,7 @@
po_to_json (>= 1.0.0)
rails (>= 3.2.0)
git (1.5.0)
gitaly (1.8
1
.0)
gitaly (1.8
5
.0)
grpc (~> 1.0)
github-markup (1.7.0)
gitlab-chronic (0.10.5)
...
...
@@ -1209,7 +1209,7 @@
gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3)
gitaly (~> 1.8
1
.0)
gitaly (~> 1.8
5
.0)
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-labkit (= 0.9.1)
...
...
Guardfile
View file @
5238f517
...
...
@@ -2,7 +2,7 @@
# More info at https://github.com/guard/guard#readme
cmd
=
ENV
[
'SPRING'
]
?
'spring rspec'
:
'bundle exec rspec'
cmd
=
ENV
[
'GUARD_CMD'
]
||
(
ENV
[
'SPRING'
]
?
'spring rspec'
:
'bundle exec rspec'
)
guard
:rspec
,
cmd:
cmd
do
require
"guard/rspec/dsl"
...
...
app/assets/javascripts/clusters/components/applications.vue
View file @
5238f517
...
...
@@ -129,9 +129,6 @@
crossplaneInstalled
()
{
return
this
.
applications
.
crossplane
.
status
===
APPLICATION_STATUS
.
INSTALLED
;
},
enableClusterApplicationElasticStack
()
{
return
gon
.
features
&&
gon
.
features
.
enableClusterApplicationElasticStack
;
},
ingressModSecurityDescription
()
{
const
escapedUrl
=
_
.
escape
(
this
.
ingressModSecurityHelpPath
);
...
...
@@ -655,7 +652,6 @@
</div>
</application-row>
<application-row
v-if=
"enableClusterApplicationElasticStack"
id=
"elastic_stack"
:logo-url=
"elasticStackLogo"
:title=
"applications.elastic_stack.title"
...
...
app/assets/javascripts/repository/components/breadcrumbs.vue
View file @
5238f517
...
...
@@ -107,6 +107,6 @@
return
acc
.
concat
({
name
,
path
,
to
:
`/-/tree/
${
this
.
ref
}${
path
}
`
,
to
:
`/-/tree/
${
escape
(
this
.
ref
)
}${
path
}
`
,
});
},
...
...
@@ -111,6 +111,12 @@
});
},
[{
name
:
this
.
projectShortPath
,
path
:
'
/
'
,
to
:
`/-/tree/
${
this
.
ref
}
/`
}],
[
{
name
:
this
.
projectShortPath
,
path
:
'
/
'
,
to
:
`/-/tree/
${
escape
(
this
.
ref
)}
/`
,
},
],
);
},
canCreateMrFromFork
()
{
...
...
app/assets/javascripts/repository/components/table/parent_row.vue
View file @
5238f517
...
...
@@ -28,7 +28,7 @@
return
splitArray
.
join
(
'
/
'
);
},
parentRoute
()
{
return
{
path
:
`/-/tree/
${
this
.
commitRef
}
/
${
this
.
parentPath
}
`
};
return
{
path
:
`/-/tree/
${
escape
(
this
.
commitRef
)
}
/
${
this
.
parentPath
}
`
};
},
},
methods
:
{
...
...
app/assets/javascripts/repository/components/table/row.vue
View file @
5238f517
...
...
@@ -90,7 +90,7 @@
},
computed
:
{
routerLinkTo
()
{
return
this
.
isFolder
?
{
path
:
`/-/tree/
${
this
.
ref
}
/
${
this
.
path
}
`
}
:
null
;
return
this
.
isFolder
?
{
path
:
`/-/tree/
${
escape
(
this
.
ref
)
}
/
${
this
.
path
}
`
}
:
null
;
},
iconName
()
{
return
`fa-
${
getIconName
(
this
.
type
,
this
.
path
)}
`
;
...
...
app/assets/javascripts/repository/log_tree.js
View file @
5238f517
...
...
@@ -27,7 +27,10 @@
fetchpromise
=
axios
.
get
(
`
${
gon
.
relative_url_root
}
/
${
projectPath
}
/-/refs/
${
ref
}
/logs_tree/
${
path
.
replace
(
/^
\/
/
,
''
)}
`
,
`
${
gon
.
relative_url_root
}
/
${
projectPath
}
/-/refs/
${
escape
(
ref
)}
/logs_tree/
${
path
.
replace
(
/^
\/
/
,
''
,
)}
`
,
{
params
:
{
format
:
'
json
'
,
offset
},
},
...
...
app/assets/javascripts/repository/router.js
View file @
5238f517
...
...
@@ -12,7 +12,7 @@
base
:
joinPaths
(
gon
.
relative_url_root
||
''
,
base
),
routes
:
[
{
path
:
`/-/tree/
${
baseRef
}
(/.*)?`
,
path
:
`/-/tree/
${
escape
(
baseRef
)
}
(/.*)?`
,
name
:
'
treePath
'
,
component
:
TreePage
,
props
:
route
=>
({
...
...
app/controllers/clusters/clusters_controller.rb
View file @
5238f517
...
...
@@ -12,9 +12,6 @@
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
,
:clear_cache
]
before_action
:update_applications_status
,
only:
[
:cluster_status
]
before_action
only:
[
:show
]
do
push_frontend_feature_flag
(
:enable_cluster_application_elastic_stack
)
end
helper_method
:token_in_session
...
...
app/controllers/projects/merge_requests/diffs_controller.rb
View file @
5238f517
...
...
@@ -64,6 +64,10 @@
options
=
additional_attributes
.
merge
(
diff_view:
diff_view
)
if
@merge_request
.
project
.
context_commits_enabled?
options
[
:context_commits
]
=
@merge_request
.
context_commits
end
render
json:
DiffsSerializer
.
new
(
request
).
represent
(
diffs
,
options
)
end
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
5238f517
...
...
@@ -116,6 +116,15 @@
}
end
def
context_commits
return
render_404
unless
project
.
context_commits_enabled?
# Get commits from repository
# or from cache if already merged
commits
=
ContextCommitsFinder
.
new
(
project
,
@merge_request
,
{
search:
params
[
:search
],
limit:
params
[
:limit
],
offset:
params
[
:offset
]
}).
execute
render
json:
CommitEntity
.
represent
(
commits
,
{
type: :full
,
request:
merge_request
})
end
def
test_reports
reports_response
(
@merge_request
.
compare_test_reports
)
end
...
...
app/controllers/projects/repositories_controller.rb
View file @
5238f517
...
...
@@ -81,7 +81,7 @@
def
assign_archive_vars
if
params
[
:id
]
@ref
,
@filename
=
extract_ref
(
params
[
:id
])
@ref
,
@filename
=
extract_ref
_and_filename
(
params
[
:id
])
else
@ref
=
params
[
:ref
]
@filename
=
nil
...
...
@@ -89,6 +89,26 @@
rescue
InvalidPathError
render_404
end
# path can be of the form:
# master
# master/first.zip
# master/first/second.tar.gz
# master/first/second/third.zip
#
# In the archive case, we know that the last value is always the filename, so we
# do a greedy match to extract the ref. This avoid having to pull all ref names
# from Redis.
def
extract_ref_and_filename
(
id
)
path
=
id
.
strip
data
=
path
.
match
(
/(.*)\/(.*)/
)
if
data
[
data
[
1
],
data
[
2
]]
else
[
path
,
nil
]
end
end
end
Projects
::
RepositoriesController
.
prepend_if_ee
(
'EE::Projects::RepositoriesController'
)
app/finders/context_commits_finder.rb
0 → 100644
View file @
5238f517
# frozen_string_literal: true
class
ContextCommitsFinder
def
initialize
(
project
,
merge_request
,
params
=
{})
@project
=
project
@merge_request
=
merge_request
@search
=
params
[
:search
]
@limit
=
(
params
[
:limit
]
||
40
).
to_i
@offset
=
(
params
[
:offset
]
||
0
).
to_i
end
def
execute
commits
=
init_collection
commits
=
filter_existing_commits
(
commits
)
commits
end
private
attr_reader
:project
,
:merge_request
,
:search
,
:limit
,
:offset
def
init_collection
commits
=
if
search
.
present?
search_commits
else
project
.
repository
.
commits
(
merge_request
.
source_branch
,
{
limit:
limit
,
offset:
offset
})
end
commits
end
def
filter_existing_commits
(
commits
)
commits
.
select!
{
|
commit
|
already_included_ids
.
exclude?
(
commit
.
id
)
}
commits
end
def
search_commits
key
=
search
.
strip
commits
=
[]
if
Commit
.
valid_hash?
(
key
)
mr_existing_commits_ids
=
merge_request
.
commits
.
map
(
&
:id
)
if
mr_existing_commits_ids
.
exclude?
key
commit_by_sha
=
project
.
repository
.
commit
(
key
)
commits
=
[
commit_by_sha
]
if
commit_by_sha
end
else
commits
=
project
.
repository
.
find_commits_by_message
(
search
,
nil
,
nil
,
20
)
end
commits
end
def
already_included_ids
mr_existing_commits_ids
=
merge_request
.
commits
.
map
(
&
:id
)
mr_context_commits_ids
=
merge_request
.
context_commits
.
map
(
&
:id
)
mr_existing_commits_ids
+
mr_context_commits_ids
end
end
app/helpers/diff_helper.rb
View file @
5238f517
...
...
@@ -29,6 +29,8 @@
if
action_name
==
'diff_for_path'
options
[
:expanded
]
=
true
options
[
:paths
]
=
params
.
values_at
(
:old_path
,
:new_path
)
elsif
action_name
==
'show'
options
[
:include_context_commits
]
=
true
unless
@project
.
context_commits_enabled?
end
options
...
...
app/models/concerns/cached_commit.rb
0 → 100644
View file @
5238f517
# frozen_string_literal: true
module
CachedCommit
extend
ActiveSupport
::
Concern
def
to_hash
Gitlab
::
Git
::
Commit
::
SERIALIZE_KEYS
.
each_with_object
({})
do
|
key
,
hash
|
hash
[
key
]
=
public_send
(
key
)
# rubocop:disable GitlabSecurity/PublicSend
end
end
# We don't save these, because they would need a table or a serialised
# field. They aren't used anywhere, so just pretend the commit has no parents.
def
parent_ids
[]
end
end
app/models/merge_request.rb
View file @
5238f517
...
...
@@ -34,6 +34,8 @@
has_internal_id
:iid
,
scope: :target_project
,
track_if:
->
{
!
importing?
},
init:
->
(
s
)
{
s
&
.
target_project
&
.
merge_requests
&
.
maximum
(
:iid
)
}
has_many
:merge_request_diffs
has_many
:merge_request_context_commits
has_many
:merge_request_context_commit_diff_files
,
through: :merge_request_context_commits
,
source: :diff_files
has_many
:merge_request_milestones
has_many
:milestones
,
through: :merge_request_milestones
...
...
@@ -399,6 +401,10 @@
"
#{
project
.
to_reference_base
(
from
,
full:
full
)
}#{
reference
}
"
end
def
context_commits
@context_commits
||=
merge_request_context_commits
.
map
(
&
:to_commit
)
end
def
commits
(
limit:
nil
)
return
merge_request_diff
.
commits
(
limit:
limit
)
if
persisted?
...
...
app/models/merge_request_context_commit.rb
0 → 100644
View file @
5238f517
# frozen_string_literal: true
class
MergeRequestContextCommit
<
ApplicationRecord
include
CachedCommit
include
ShaAttribute
belongs_to
:merge_request
has_many
:diff_files
,
class_name:
'MergeRequestContextCommitDiffFile'
sha_attribute
:sha
validates
:sha
,
presence:
true
validates
:sha
,
uniqueness:
{
message:
'has already been added'
}
# delete all MergeRequestContextCommit & MergeRequestContextCommitDiffFile for given merge_request & commit SHAs
def
self
.
delete_bulk
(
merge_request
,
commits
)
commit_ids
=
commits
.
map
(
&
:sha
)
merge_request
.
merge_request_context_commits
.
where
(
sha:
commit_ids
).
delete_all
end
# create MergeRequestContextCommit by given commit sha and it's diff file record
def
self
.
bulk_insert
(
*
args
)
Gitlab
::
Database
.
bulk_insert
(
'merge_request_context_commits'
,
*
args
)
end
def
to_commit
# Here we are storing the commit sha because to_hash removes the sha parameter and we lose
# the reference, this happens because we are storing the ID in db and the Commit class replaces
# id with sha and removes it, so in our case it will be some incremented integer which is not
# what we want
commit_hash
=
attributes
.
except
(
'id'
).
to_hash
commit_hash
[
'id'
]
=
sha
Commit
.
from_hash
(
commit_hash
,
merge_request
.
target_project
)
end
end
app/models/merge_request_context_commit_diff_file.rb
0 → 100644
View file @
5238f517
# frozen_string_literal: true
class
MergeRequestContextCommitDiffFile
<
ApplicationRecord
include
Gitlab
::
EncodingHelper
include
ShaAttribute
include
DiffFile
belongs_to
:merge_request_context_commit
,
inverse_of: :diff_files
sha_attribute
:sha
alias_attribute
:id
,
:sha
# create MergeRequestContextCommitDiffFile by given diff file record(s)
def
self
.
bulk_insert
(
*
args
)
Gitlab
::
Database
.
bulk_insert
(
'merge_request_context_commit_diff_files'
,
*
args
)
end
end
Prev
1
2
3
4
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