Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
a77629b1
Commit
a77629b1
authored
Aug 17, 2016
by
Connor Shea
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into diff-line-comment-vuejs
parents
c8df2c5f
fa576d38
Changes
18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
11801 additions
and
124 deletions
+11801
-124
CHANGELOG
CHANGELOG
+4
-0
app/assets/javascripts/files_comment_button.js
app/assets/javascripts/files_comment_button.js
+1
-1
app/assets/javascripts/labels_select.js
app/assets/javascripts/labels_select.js
+7
-5
app/controllers/autocomplete_controller.rb
app/controllers/autocomplete_controller.rb
+6
-8
app/finders/move_to_project_finder.rb
app/finders/move_to_project_finder.rb
+14
-0
app/models/project.rb
app/models/project.rb
+2
-0
app/models/user.rb
app/models/user.rb
+7
-0
lib/gitlab/downtime_check/message.rb
lib/gitlab/downtime_check/message.rb
+15
-4
spec/controllers/autocomplete_controller_spec.rb
spec/controllers/autocomplete_controller_spec.rb
+188
-104
spec/finders/move_to_project_finder_spec.rb
spec/finders/move_to_project_finder_spec.rb
+75
-0
spec/lib/gitlab/downtime_check/message_spec.rb
spec/lib/gitlab/downtime_check/message_spec.rb
+24
-2
spec/models/user_spec.rb
spec/models/user_spec.rb
+47
-0
vendor/assets/javascripts/vue-resource.full.js
vendor/assets/javascripts/vue-resource.full.js
+1318
-0
vendor/assets/javascripts/vue-resource.js.erb
vendor/assets/javascripts/vue-resource.js.erb
+2
-0
vendor/assets/javascripts/vue-resource.min.js
vendor/assets/javascripts/vue-resource.min.js
+7
-0
vendor/assets/javascripts/vue.full.js
vendor/assets/javascripts/vue.full.js
+10073
-0
vendor/assets/javascripts/vue.js.erb
vendor/assets/javascripts/vue.js.erb
+2
-0
vendor/assets/javascripts/vue.min.js
vendor/assets/javascripts/vue.min.js
+9
-0
No files found.
CHANGELOG
View file @
a77629b1
...
...
@@ -97,6 +97,7 @@ v 8.11.0 (unreleased)
- Add commit stats in commit api. !5517 (dixpac)
- Add CI configuration button on project page
- Make error pages responsive (Takuya Noguchi)
- The performance of the project dropdown used for moving issues has been improved
- Fix skip_repo parameter being ignored when destroying a namespace
- Change requests_profiles resource constraint to catch virtually any file
- Bump gitlab_git to lazy load compare commits
...
...
@@ -146,6 +147,9 @@ v 8.10.3
- Fix importer for GitHub Pull Requests when a branch was removed. !5573
- Ignore invalid IPs in X-Forwarded-For when trusted proxies are configured. !5584
- Trim extra displayed carriage returns in diffs and files with CRLFs. !5588
- Fix label already exist error message in the right sidebar.
v 8.10.3 (unreleased)
v 8.10.2
- User can now search branches by name. !5144
...
...
app/assets/javascripts/files_comment_button.js
View file @
a77629b1
...
...
@@ -33,7 +33,7 @@
this
.
render
=
bind
(
this
.
render
,
this
);
this
.
VIEW_TYPE
=
$
(
'
input#view[type=hidden]
'
).
val
();
debounce
=
_
.
debounce
(
this
.
render
,
DEBOUNCE_TIMEOUT_DURATION
);
$
(
docu
ment
).
off
(
'
mouseover
'
,
LINE_COLUMN_CLASSES
).
off
(
'
mouseleave
'
,
LINE_COLUMN_CLASSES
).
on
(
'
mouseover
'
,
LINE_COLUMN_CLASSES
,
debounce
).
on
(
'
mouseleave
'
,
LINE_COLUMN_CLASSES
,
this
.
destroy
);
$
(
this
.
filesContainerEle
ment
).
off
(
'
mouseover
'
,
LINE_COLUMN_CLASSES
).
off
(
'
mouseleave
'
,
LINE_COLUMN_CLASSES
).
on
(
'
mouseover
'
,
LINE_COLUMN_CLASSES
,
debounce
).
on
(
'
mouseleave
'
,
LINE_COLUMN_CLASSES
,
this
.
destroy
);
}
FilesCommentButton
.
prototype
.
render
=
function
(
e
)
{
...
...
app/assets/javascripts/labels_select.js
View file @
a77629b1
...
...
@@ -70,13 +70,15 @@
name
:
newLabelField
.
val
(),
color
:
newColorField
.
val
()
},
function
(
label
)
{
var
errors
;
$newLabelCreateButton
.
enable
();
if
(
label
.
message
!=
null
)
{
errors
=
_
.
map
(
label
.
message
,
function
(
value
,
key
)
{
var
errorText
=
label
.
message
;
if
(
_
.
isObject
(
label
.
message
))
{
errorText
=
_
.
map
(
label
.
message
,
function
(
value
,
key
)
{
return
key
+
"
"
+
value
[
0
];
});
return
$newLabelError
.
html
(
errors
.
join
(
"
<br/>
"
)).
show
();
}).
join
(
'
<br/>
'
);
}
return
$newLabelError
.
html
(
errorText
).
show
();
}
else
{
return
$
(
'
.dropdown-menu-back
'
,
$dropdown
.
parent
()).
trigger
(
'
click
'
);
}
...
...
app/controllers/autocomplete_controller.rb
View file @
a77629b1
...
...
@@ -35,19 +35,13 @@ class AutocompleteController < ApplicationController
def
projects
project
=
Project
.
find_by_id
(
params
[
:project_id
])
projects
=
current_user
.
authorized_projects
projects
=
projects
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
projects
=
projects
.
select
do
|
project
|
current_user
.
can?
(
:admin_issue
,
project
)
end
projects
=
projects_finder
.
execute
(
project
,
search:
params
[
:search
],
offset_id:
params
[
:offset_id
])
no_project
=
{
id:
0
,
name_with_namespace:
'No project'
,
}
projects
.
unshift
(
no_project
)
projects
.
delete
(
project
)
projects
.
unshift
(
no_project
)
unless
params
[
:offset_id
].
present?
render
json:
projects
.
to_json
(
only:
[
:id
,
:name_with_namespace
],
methods: :name_with_namespace
)
end
...
...
@@ -79,4 +73,8 @@ class AutocompleteController < ApplicationController
end
end
end
def
projects_finder
MoveToProjectFinder
.
new
(
current_user
)
end
end
app/finders/move_to_project_finder.rb
0 → 100644
View file @
a77629b1
class
MoveToProjectFinder
def
initialize
(
user
)
@user
=
user
end
def
execute
(
from_project
,
search:
nil
,
offset_id:
nil
)
projects
=
@user
.
projects_where_can_admin_issues
projects
=
projects
.
search
(
search
)
if
search
.
present?
projects
=
projects
.
excluding_project
(
from_project
)
# to ask for Project#name_with_namespace
projects
.
includes
(
namespace: :owner
)
end
end
app/models/project.rb
View file @
a77629b1
...
...
@@ -197,6 +197,8 @@ class Project < ActiveRecord::Base
scope
:active
,
->
{
joins
(
:issues
,
:notes
,
:merge_requests
).
order
(
'issues.created_at, notes.created_at, merge_requests.created_at DESC'
)
}
scope
:abandoned
,
->
{
where
(
'projects.last_activity_at < ?'
,
6
.
months
.
ago
)
}
scope
:excluding_project
,
->
(
project
)
{
where
.
not
(
id:
project
)
}
state_machine
:import_status
,
initial: :none
do
event
:import_start
do
transition
[
:none
,
:finished
]
=>
:started
...
...
app/models/user.rb
View file @
a77629b1
...
...
@@ -429,6 +429,13 @@ class User < ActiveRecord::Base
owned_groups
.
select
(
:id
),
namespace
.
id
).
joins
(
:namespace
)
end
# Returns projects which user can admin issues on (for example to move an issue to that project).
#
# This logic is duplicated from `Ability#project_abilities` into a SQL form.
def
projects_where_can_admin_issues
authorized_projects
(
Gitlab
::
Access
::
REPORTER
).
non_archived
.
where
.
not
(
issues_enabled:
false
)
end
def
is_admin?
admin
end
...
...
lib/gitlab/downtime_check/message.rb
View file @
a77629b1
module
Gitlab
class
DowntimeCheck
class
Message
attr_reader
:path
,
:offline
,
:reason
attr_reader
:path
,
:offline
OFFLINE
=
"
\e
[3
2
moffline
\e
[0m"
ONLINE
=
"
\e
[3
1
monline
\e
[0m"
OFFLINE
=
"
\e
[3
1
moffline
\e
[0m"
ONLINE
=
"
\e
[3
2
monline
\e
[0m"
# path - The file path of the migration.
# offline - When set to `true` the migration will require downtime.
...
...
@@ -19,10 +19,21 @@ module Gitlab
label
=
offline
?
OFFLINE
:
ONLINE
message
=
"[
#{
label
}
]:
#{
path
}
"
message
+=
":
#{
reason
}
"
if
reason
if
reason?
message
+=
":
\n\n
#{
reason
}
\n\n
"
end
message
end
def
reason?
@reason
.
present?
end
def
reason
@reason
.
strip
.
lines
.
map
(
&
:strip
).
join
(
"
\n
"
)
end
end
end
end
spec/controllers/autocomplete_controller_spec.rb
View file @
a77629b1
...
...
@@ -3,6 +3,8 @@ require 'spec_helper'
describe
AutocompleteController
do
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:user
)
{
create
(
:user
)
}
context
'users and members'
do
let!
(
:user2
)
{
create
(
:user
)
}
let!
(
:non_member
)
{
create
(
:user
)
}
...
...
@@ -176,4 +178,86 @@ describe AutocompleteController do
expect
(
response_user_ids
).
to
contain_exactly
(
*
other_user_ids
)
end
end
end
context
'projects'
do
let
(
:authorized_project
)
{
create
(
:project
)
}
let
(
:authorized_search_project
)
{
create
(
:project
,
name:
'rugged'
)
}
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:master
]
end
context
'authorized projects'
do
before
do
authorized_project
.
team
<<
[
user
,
:master
]
end
describe
'GET #projects with project ID'
do
before
do
get
(
:projects
,
project_id:
project
.
id
)
end
let
(
:body
)
{
JSON
.
parse
(
response
.
body
)
}
it
do
expect
(
body
).
to
be_kind_of
(
Array
)
expect
(
body
.
size
).
to
eq
2
expect
(
body
.
first
[
'id'
]).
to
eq
0
expect
(
body
.
first
[
'name_with_namespace'
]).
to
eq
'No project'
expect
(
body
.
last
[
'id'
]).
to
eq
authorized_project
.
id
expect
(
body
.
last
[
'name_with_namespace'
]).
to
eq
authorized_project
.
name_with_namespace
end
end
end
context
'authorized projects and search'
do
before
do
authorized_project
.
team
<<
[
user
,
:master
]
authorized_search_project
.
team
<<
[
user
,
:master
]
end
describe
'GET #projects with project ID and search'
do
before
do
get
(
:projects
,
project_id:
project
.
id
,
search:
'rugged'
)
end
let
(
:body
)
{
JSON
.
parse
(
response
.
body
)
}
it
do
expect
(
body
).
to
be_kind_of
(
Array
)
expect
(
body
.
size
).
to
eq
2
expect
(
body
.
last
[
'id'
]).
to
eq
authorized_search_project
.
id
expect
(
body
.
last
[
'name_with_namespace'
]).
to
eq
authorized_search_project
.
name_with_namespace
end
end
end
context
'authorized projects without admin_issue ability'
do
before
(
:each
)
do
authorized_project
.
team
<<
[
user
,
:guest
]
expect
(
user
.
can?
(
:admin_issue
,
authorized_project
)).
to
eq
(
false
)
end
describe
'GET #projects with project ID'
do
before
do
get
(
:projects
,
project_id:
project
.
id
)
end
let
(
:body
)
{
JSON
.
parse
(
response
.
body
)
}
it
do
expect
(
body
).
to
be_kind_of
(
Array
)
expect
(
body
.
size
).
to
eq
1
# 'No project'
expect
(
body
.
first
[
'id'
]).
to
eq
0
end
end
end
end
end
spec/finders/move_to_project_finder_spec.rb
0 → 100644
View file @
a77629b1
require
'spec_helper'
describe
MoveToProjectFinder
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:no_access_project
)
{
create
(
:project
)
}
let
(
:guest_project
)
{
create
(
:project
)
}
let
(
:reporter_project
)
{
create
(
:project
)
}
let
(
:developer_project
)
{
create
(
:project
)
}
let
(
:master_project
)
{
create
(
:project
)
}
subject
{
described_class
.
new
(
user
)
}
describe
'#execute'
do
context
'filter'
do
it
'does not return projects under Gitlab::Access::REPORTER'
do
guest_project
.
team
<<
[
user
,
:guest
]
expect
(
subject
.
execute
(
project
)).
to
be_empty
end
it
'returns projects equal or above Gitlab::Access::REPORTER ordered by id in descending order'
do
reporter_project
.
team
<<
[
user
,
:reporter
]
developer_project
.
team
<<
[
user
,
:developer
]
master_project
.
team
<<
[
user
,
:master
]
expect
(
subject
.
execute
(
project
).
to_a
).
to
eq
([
master_project
,
developer_project
,
reporter_project
])
end
it
'does not include the source project'
do
project
.
team
<<
[
user
,
:reporter
]
expect
(
subject
.
execute
(
project
).
to_a
).
to
be_empty
end
it
'does not return archived projects'
do
reporter_project
.
team
<<
[
user
,
:reporter
]
reporter_project
.
update_attributes
(
archived:
true
)
other_reporter_project
=
create
(
:project
)
other_reporter_project
.
team
<<
[
user
,
:reporter
]
expect
(
subject
.
execute
(
project
).
to_a
).
to
eq
([
other_reporter_project
])
end
it
'does not return projects for which issues are disabled'
do
reporter_project
.
team
<<
[
user
,
:reporter
]
reporter_project
.
update_attributes
(
issues_enabled:
false
)
other_reporter_project
=
create
(
:project
)
other_reporter_project
.
team
<<
[
user
,
:reporter
]
expect
(
subject
.
execute
(
project
).
to_a
).
to
eq
([
other_reporter_project
])
end
end
context
'search'
do
it
'uses Project#search'
do
expect
(
user
).
to
receive_message_chain
(
:projects_where_can_admin_issues
,
:search
)
{
Project
.
all
}
subject
.
execute
(
project
,
search:
'wadus'
)
end
it
'returns projects matching a search query'
do
foo_project
=
create
(
:project
)
foo_project
.
team
<<
[
user
,
:master
]
wadus_project
=
create
(
:project
,
name:
'wadus'
)
wadus_project
.
team
<<
[
user
,
:master
]
expect
(
subject
.
execute
(
project
).
to_a
).
to
eq
([
wadus_project
,
foo_project
])
expect
(
subject
.
execute
(
project
,
search:
'wadus'
).
to_a
).
to
eq
([
wadus_project
])
end
end
end
end
spec/lib/gitlab/downtime_check/message_spec.rb
View file @
a77629b1
...
...
@@ -5,13 +5,35 @@ describe Gitlab::DowntimeCheck::Message do
it
'returns an ANSI formatted String for an offline migration'
do
message
=
described_class
.
new
(
'foo.rb'
,
true
,
'hello'
)
expect
(
message
.
to_s
).
to
eq
(
"[
\e
[3
2moffline
\e
[0m]: foo.rb: hello
"
)
expect
(
message
.
to_s
).
to
eq
(
"[
\e
[3
1moffline
\e
[0m]: foo.rb:
\n\n
hello
\n\n
"
)
end
it
'returns an ANSI formatted String for an online migration'
do
message
=
described_class
.
new
(
'foo.rb'
)
expect
(
message
.
to_s
).
to
eq
(
"[
\e
[31monline
\e
[0m]: foo.rb"
)
expect
(
message
.
to_s
).
to
eq
(
"[
\e
[32monline
\e
[0m]: foo.rb"
)
end
end
describe
'#reason?'
do
it
'returns false when no reason is specified'
do
message
=
described_class
.
new
(
'foo.rb'
)
expect
(
message
.
reason?
).
to
eq
(
false
)
end
it
'returns true when a reason is specified'
do
message
=
described_class
.
new
(
'foo.rb'
,
true
,
'hello'
)
expect
(
message
.
reason?
).
to
eq
(
true
)
end
end
describe
'#reason'
do
it
'strips excessive whitespace from the returned String'
do
message
=
described_class
.
new
(
'foo.rb'
,
true
,
" hello
\n
world
\n\n
foo"
)
expect
(
message
.
reason
).
to
eq
(
"hello
\n
world
\n\n
foo"
)
end
end
end
spec/models/user_spec.rb
View file @
a77629b1
...
...
@@ -957,6 +957,53 @@ describe User, models: true do
end
end
describe
'#projects_where_can_admin_issues'
do
let
(
:user
)
{
create
(
:user
)
}
it
'includes projects for which the user access level is above or equal to reporter'
do
create
(
:project
)
reporter_project
=
create
(
:project
)
developer_project
=
create
(
:project
)
master_project
=
create
(
:project
)
reporter_project
.
team
<<
[
user
,
:reporter
]
developer_project
.
team
<<
[
user
,
:developer
]
master_project
.
team
<<
[
user
,
:master
]
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
eq
([
master_project
,
developer_project
,
reporter_project
])
expect
(
user
.
can?
(
:admin_issue
,
master_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
developer_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
reporter_project
)).
to
eq
(
true
)
end
it
'does not include for which the user access level is below reporter'
do
project
=
create
(
:project
)
guest_project
=
create
(
:project
)
guest_project
.
team
<<
[
user
,
:guest
]
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
be_empty
expect
(
user
.
can?
(
:admin_issue
,
guest_project
)).
to
eq
(
false
)
expect
(
user
.
can?
(
:admin_issue
,
project
)).
to
eq
(
false
)
end
it
'does not include archived projects'
do
project
=
create
(
:project
)
project
.
update_attributes
(
archived:
true
)
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
be_empty
expect
(
user
.
can?
(
:admin_issue
,
project
)).
to
eq
(
false
)
end
it
'does not include projects for which issues are disabled'
do
project
=
create
(
:project
)
project
.
update_attributes
(
issues_enabled:
false
)
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
be_empty
expect
(
user
.
can?
(
:admin_issue
,
project
)).
to
eq
(
false
)
end
end
describe
'#ci_authorized_runners'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:runner
)
{
create
(
:ci_runner
)
}
...
...
vendor/assets/javascripts/vue-resource.full.js
0 → 100644
View file @
a77629b1
This diff is collapsed.
Click to expand it.
vendor/assets/javascripts/vue-resource.js.erb
0 → 100644
View file @
a77629b1
<%
type
=
Rails
.
env
.
development?
?
'full'
:
'min'
%>
<%=
File
.
read
(
Rails
.
root
.
join
(
"vendor/assets/javascripts/vue-resource.
#{
type
}
.js"
))
%>
vendor/assets/javascripts/vue-resource.min.js
0 → 100644
View file @
a77629b1
This diff is collapsed.
Click to expand it.
vendor/assets/javascripts/vue.full.js
0 → 100644
View file @
a77629b1
This diff is collapsed.
Click to expand it.
vendor/assets/javascripts/vue.js.erb
0 → 100644
View file @
a77629b1
<%
type
=
Rails
.
env
.
development?
?
'full'
:
'min'
%>
<%=
File
.
read
(
Rails
.
root
.
join
(
"vendor/assets/javascripts/vue.
#{
type
}
.js"
))
%>
vendor/assets/javascripts/vue.min.js
0 → 100644
View file @
a77629b1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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