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
Boxiang Sun
gitlab-ce
Commits
375caeef
Commit
375caeef
authored
Feb 13, 2013
by
Sebastian Ziebell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into fixes/api
parents
ae40e855
b9f8b401
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
224 additions
and
94 deletions
+224
-94
app/assets/stylesheets/gitlab_bootstrap/common.scss
app/assets/stylesheets/gitlab_bootstrap/common.scss
+1
-0
app/controllers/graph_controller.rb
app/controllers/graph_controller.rb
+11
-1
app/controllers/public/projects_controller.rb
app/controllers/public/projects_controller.rb
+1
-1
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+11
-0
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+3
-3
app/models/event.rb
app/models/event.rb
+2
-2
app/models/milestone.rb
app/models/milestone.rb
+2
-2
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/note.rb
app/models/note.rb
+2
-2
app/models/project.rb
app/models/project.rb
+1
-1
app/models/snippet.rb
app/models/snippet.rb
+3
-3
app/models/user.rb
app/models/user.rb
+4
-4
app/models/users_project.rb
app/models/users_project.rb
+4
-4
app/views/admin/users/_form.html.haml
app/views/admin/users/_form.html.haml
+3
-3
app/views/graph/_head.html.haml
app/views/graph/_head.html.haml
+16
-0
app/views/graph/show.html.haml
app/views/graph/show.html.haml
+4
-6
app/views/profiles/account.html.haml
app/views/profiles/account.html.haml
+7
-1
config/routes.rb
config/routes.rb
+1
-1
doc/api/repositories.md
doc/api/repositories.md
+3
-0
lib/api/projects.rb
lib/api/projects.rb
+1
-0
lib/extracts_path.rb
lib/extracts_path.rb
+4
-1
lib/gitlab/graph/json_builder.rb
lib/gitlab/graph/json_builder.rb
+48
-20
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+15
-30
lib/tasks/sidekiq.rake
lib/tasks/sidekiq.rake
+6
-1
spec/factories.rb
spec/factories.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+5
-0
spec/requests/profile_spec.rb
spec/requests/profile_spec.rb
+48
-0
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+1
-0
vendor/assets/javascripts/branch-graph.js
vendor/assets/javascripts/branch-graph.js
+15
-6
No files found.
app/assets/stylesheets/gitlab_bootstrap/common.scss
View file @
375caeef
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
.hint
{
font-style
:
italic
;
color
:
#999
;
}
.hint
{
font-style
:
italic
;
color
:
#999
;
}
.light
{
color
:
#888
}
.light
{
color
:
#888
}
.tiny
{
font-weight
:
normal
}
.tiny
{
font-weight
:
normal
}
.vtop
{
vertical-align
:
top
;
}
/** ALERT MESSAGES **/
/** ALERT MESSAGES **/
...
...
app/controllers/graph_controller.rb
View file @
375caeef
...
@@ -7,10 +7,20 @@ class GraphController < ProjectResourceController
...
@@ -7,10 +7,20 @@ class GraphController < ProjectResourceController
before_filter
:require_non_empty_project
before_filter
:require_non_empty_project
def
show
def
show
if
params
.
has_key?
(
:q
)
&&
params
[
:q
].
blank?
redirect_to
project_graph_path
(
@project
,
params
[
:id
])
return
end
if
params
.
has_key?
(
:q
)
@q
=
params
[
:q
]
@commit
=
@project
.
repository
.
commit
(
@q
)
||
@commit
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
)
graph
=
Gitlab
::
Graph
::
JsonBuilder
.
new
(
project
,
@ref
,
@commit
)
render
:json
=>
graph
.
to_json
render
:json
=>
graph
.
to_json
end
end
end
end
...
...
app/controllers/public/projects_controller.rb
View file @
375caeef
...
@@ -6,7 +6,7 @@ class Public::ProjectsController < ApplicationController
...
@@ -6,7 +6,7 @@ class Public::ProjectsController < ApplicationController
layout
'public'
layout
'public'
def
index
def
index
@projects
=
Project
.
public
@projects
=
Project
.
public
_only
@projects
=
@projects
.
includes
(
:namespace
).
order
(
"namespaces.path, projects.name ASC"
).
page
(
params
[
:page
]).
per
(
20
)
@projects
=
@projects
.
includes
(
:namespace
).
order
(
"namespaces.path, projects.name ASC"
).
page
(
params
[
:page
]).
per
(
20
)
end
end
end
end
app/controllers/registrations_controller.rb
View file @
375caeef
class
RegistrationsController
<
Devise
::
RegistrationsController
class
RegistrationsController
<
Devise
::
RegistrationsController
before_filter
:signup_enabled?
before_filter
:signup_enabled?
def
destroy
if
current_user
.
owned_projects
.
count
>
0
redirect_to
account_profile_path
,
alert:
"Remove projects and groups before removing account."
and
return
end
current_user
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
new_user_session_path
,
notice:
"Account successfully removed."
}
end
end
private
private
def
signup_enabled?
def
signup_enabled?
...
...
app/models/concerns/issuable.rb
View file @
375caeef
...
@@ -19,12 +19,12 @@ module Issuable
...
@@ -19,12 +19,12 @@ module Issuable
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:title
,
presence:
true
,
length:
{
within:
0
..
255
}
validates
:closed
,
inclusion:
{
in:
[
true
,
false
]
}
validates
:closed
,
inclusion:
{
in:
[
true
,
false
]
}
scope
:opened
,
where
(
closed:
false
)
scope
:opened
,
->
{
where
(
closed:
false
)
}
scope
:closed
,
where
(
closed:
true
)
scope
:closed
,
->
{
where
(
closed:
true
)
}
scope
:of_group
,
->
(
group
)
{
where
(
project_id:
group
.
project_ids
)
}
scope
:of_group
,
->
(
group
)
{
where
(
project_id:
group
.
project_ids
)
}
scope
:of_user_team
,
->
(
team
)
{
where
(
project_id:
team
.
project_ids
,
assignee_id:
team
.
member_ids
)
}
scope
:of_user_team
,
->
(
team
)
{
where
(
project_id:
team
.
project_ids
,
assignee_id:
team
.
member_ids
)
}
scope
:assigned
,
->
(
u
)
{
where
(
assignee_id:
u
.
id
)}
scope
:assigned
,
->
(
u
)
{
where
(
assignee_id:
u
.
id
)}
scope
:recent
,
order
(
"created_at DESC"
)
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
delegate
:name
,
delegate
:name
,
:email
,
:email
,
...
...
app/models/event.rb
View file @
375caeef
...
@@ -42,8 +42,8 @@ class Event < ActiveRecord::Base
...
@@ -42,8 +42,8 @@ class Event < ActiveRecord::Base
serialize
:data
serialize
:data
# Scopes
# Scopes
scope
:recent
,
order
(
"created_at DESC"
)
scope
:recent
,
->
{
order
(
"created_at DESC"
)
}
scope
:code_push
,
where
(
action:
Pushed
)
scope
:code_push
,
->
{
where
(
action:
Pushed
)
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
scope
:in_projects
,
->
(
project_ids
)
{
where
(
project_id:
project_ids
).
recent
}
class
<<
self
class
<<
self
...
...
app/models/milestone.rb
View file @
375caeef
...
@@ -20,8 +20,8 @@ class Milestone < ActiveRecord::Base
...
@@ -20,8 +20,8 @@ class Milestone < ActiveRecord::Base
has_many
:issues
has_many
:issues
has_many
:merge_requests
has_many
:merge_requests
scope
:active
,
where
(
closed:
false
)
scope
:active
,
->
{
where
(
closed:
false
)
}
scope
:closed
,
where
(
closed:
true
)
scope
:closed
,
->
{
where
(
closed:
true
)
}
validates
:title
,
presence:
true
validates
:title
,
presence:
true
validates
:project
,
presence:
true
validates
:project
,
presence:
true
...
...
app/models/namespace.rb
View file @
375caeef
...
@@ -29,7 +29,7 @@ class Namespace < ActiveRecord::Base
...
@@ -29,7 +29,7 @@ class Namespace < ActiveRecord::Base
after_update
:move_dir
after_update
:move_dir
after_destroy
:rm_dir
after_destroy
:rm_dir
scope
:root
,
where
(
'type IS NULL'
)
scope
:root
,
->
{
where
(
'type IS NULL'
)
}
def
self
.
search
query
def
self
.
search
query
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
where
(
"name LIKE :query OR path LIKE :query"
,
query:
"%
#{
query
}
%"
)
...
...
app/models/note.rb
View file @
375caeef
...
@@ -43,8 +43,8 @@ class Note < ActiveRecord::Base
...
@@ -43,8 +43,8 @@ class Note < ActiveRecord::Base
# Scopes
# Scopes
scope
:for_commit_id
,
->
(
commit_id
)
{
where
(
noteable_type:
"Commit"
,
commit_id:
commit_id
)
}
scope
:for_commit_id
,
->
(
commit_id
)
{
where
(
noteable_type:
"Commit"
,
commit_id:
commit_id
)
}
scope
:inline
,
where
(
"line_code IS NOT NULL"
)
scope
:inline
,
->
{
where
(
"line_code IS NOT NULL"
)
}
scope
:not_inline
,
where
(
"line_code IS NULL"
)
scope
:not_inline
,
->
{
where
(
"line_code IS NULL"
)
}
scope
:common
,
->
{
where
(
noteable_type:
[
""
,
nil
])
}
scope
:common
,
->
{
where
(
noteable_type:
[
""
,
nil
])
}
scope
:fresh
,
->
{
order
(
"created_at ASC, id ASC"
)
}
scope
:fresh
,
->
{
order
(
"created_at ASC, id ASC"
)
}
...
...
app/models/project.rb
View file @
375caeef
...
@@ -91,7 +91,7 @@ class Project < ActiveRecord::Base
...
@@ -91,7 +91,7 @@ class Project < ActiveRecord::Base
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
scope
:sorted_by_activity
,
->
()
{
order
(
"(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC"
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:personal
,
->
(
user
)
{
where
(
namespace_id:
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:joined
,
->
(
user
)
{
where
(
"namespace_id != ?"
,
user
.
namespace_id
)
}
scope
:public
,
where
(
public:
true
)
scope
:public
_only
,
->
{
where
(
public:
true
)
}
class
<<
self
class
<<
self
def
abandoned
def
abandoned
...
...
app/models/snippet.rb
View file @
375caeef
...
@@ -31,9 +31,9 @@ class Snippet < ActiveRecord::Base
...
@@ -31,9 +31,9 @@ class Snippet < ActiveRecord::Base
validates
:content
,
presence:
true
validates
:content
,
presence:
true
# Scopes
# Scopes
scope
:fresh
,
order
(
"created_at DESC"
)
scope
:fresh
,
->
{
order
(
"created_at DESC"
)
}
scope
:non_expired
,
where
([
"expires_at IS NULL OR expires_at > ?"
,
Time
.
current
])
scope
:non_expired
,
->
{
where
([
"expires_at IS NULL OR expires_at > ?"
,
Time
.
current
])
}
scope
:expired
,
where
([
"expires_at IS NOT NULL AND expires_at < ?"
,
Time
.
current
])
scope
:expired
,
->
{
where
([
"expires_at IS NOT NULL AND expires_at < ?"
,
Time
.
current
])
}
def
self
.
content_types
def
self
.
content_types
[
[
...
...
app/models/user.rb
View file @
375caeef
...
@@ -87,10 +87,10 @@ class User < ActiveRecord::Base
...
@@ -87,10 +87,10 @@ class User < ActiveRecord::Base
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
delegate
:path
,
to: :namespace
,
allow_nil:
true
,
prefix:
true
# Scopes
# Scopes
scope
:admins
,
where
(
admin:
true
)
scope
:admins
,
->
{
where
(
admin:
true
)
}
scope
:blocked
,
where
(
blocked:
true
)
scope
:blocked
,
->
{
where
(
blocked:
true
)
}
scope
:active
,
where
(
blocked:
false
)
scope
:active
,
->
{
where
(
blocked:
false
)
}
scope
:alphabetically
,
order
(
'name ASC'
)
scope
:alphabetically
,
->
{
order
(
'name ASC'
)
}
scope
:in_team
,
->
(
team
){
where
(
id:
team
.
member_ids
)
}
scope
:in_team
,
->
(
team
){
where
(
id:
team
.
member_ids
)
}
scope
:not_in_team
,
->
(
team
){
where
(
'users.id NOT IN (:ids)'
,
ids:
team
.
member_ids
)
}
scope
:not_in_team
,
->
(
team
){
where
(
'users.id NOT IN (:ids)'
,
ids:
team
.
member_ids
)
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
scope
:potential_team_members
,
->
(
team
)
{
team
.
members
.
any?
?
active
.
not_in_team
(
team
)
:
active
}
...
...
app/models/users_project.rb
View file @
375caeef
...
@@ -32,10 +32,10 @@ class UsersProject < ActiveRecord::Base
...
@@ -32,10 +32,10 @@ class UsersProject < ActiveRecord::Base
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
delegate
:name
,
:username
,
:email
,
to: :user
,
prefix:
true
scope
:guests
,
where
(
project_access:
GUEST
)
scope
:guests
,
->
{
where
(
project_access:
GUEST
)
}
scope
:reporters
,
where
(
project_access:
REPORTER
)
scope
:reporters
,
->
{
where
(
project_access:
REPORTER
)
}
scope
:developers
,
where
(
project_access:
DEVELOPER
)
scope
:developers
,
->
{
where
(
project_access:
DEVELOPER
)
}
scope
:masters
,
where
(
project_access:
MASTER
)
scope
:masters
,
->
{
where
(
project_access:
MASTER
)
}
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:in_project
,
->
(
project
)
{
where
(
project_id:
project
.
id
)
}
scope
:in_projects
,
->
(
projects
)
{
where
(
project_id:
project_ids
)
}
scope
:in_projects
,
->
(
projects
)
{
where
(
project_id:
project_ids
)
}
...
...
app/views/admin/users/_form.html.haml
View file @
375caeef
...
@@ -11,17 +11,17 @@
...
@@ -11,17 +11,17 @@
.clearfix
.clearfix
=
f
.
label
:name
=
f
.
label
:name
.input
.input
=
f
.
text_field
:name
,
required:
true
=
f
.
text_field
:name
,
required:
true
,
autocomplete:
"off"
%span
.help-inline
* required
%span
.help-inline
* required
.clearfix
.clearfix
=
f
.
label
:username
=
f
.
label
:username
.input
.input
=
f
.
text_field
:username
,
required:
true
=
f
.
text_field
:username
,
required:
true
,
autocomplete:
"off"
%span
.help-inline
* required
%span
.help-inline
* required
.clearfix
.clearfix
=
f
.
label
:email
=
f
.
label
:email
.input
.input
=
f
.
text_field
:email
,
required:
true
=
f
.
text_field
:email
,
required:
true
,
autocomplete:
"off"
%span
.help-inline
* required
%span
.help-inline
* required
%fieldset
%fieldset
...
...
app/views/graph/_head.html.haml
0 → 100644
View file @
375caeef
%h3
.page_title
Project Network Graph
%hr
.clearfix
.pull-left
=
render
partial:
'shared/ref_switcher'
,
locals:
{
destination:
'graph'
,
path:
@path
}
.search.pull-right
=
form_tag
project_graph_path
(
@project
,
params
[
:id
]),
method: :get
do
|
f
|
.control-group
=
label_tag
:search
,
"Looking for commit:"
,
class:
'control-label light'
.controls
=
text_field_tag
:q
,
@q
,
placeholder:
"Input SHA"
,
class:
"search-input xlarge"
=
button_tag
type:
'submit'
,
class:
'btn vtop'
do
%i
.icon-search
app/views/graph/show.html.haml
View file @
375caeef
%h3
.page_title
Project Network Graph
=
render
"head"
%br
=
render
partial:
'shared/ref_switcher'
,
locals:
{
destination:
'graph'
,
path:
@path
}
%br
.graph_holder
.graph_holder
%h4
%h4
%small
You can move around the graph by using the arrow keys.
%small
You can move around the graph by using the arrow keys.
...
@@ -12,8 +9,9 @@
...
@@ -12,8 +9,9 @@
var
branch_graph
;
var
branch_graph
;
$
(
function
(){
$
(
function
(){
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
format: :json
)
}
'
,
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
q:
@q
,
format: :json
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
ref
:
'
#{
@ref
}
'
,
commit_id
:
'
#{
@commit
.
id
}
'
});
});
});
});
app/views/profiles/account.html.haml
View file @
375caeef
...
@@ -77,4 +77,10 @@
...
@@ -77,4 +77,10 @@
.input
.input
=
f
.
submit
'Save username'
,
class:
"btn btn-save"
=
f
.
submit
'Save username'
,
class:
"btn btn-save"
-
if
Gitlab
.
config
.
gitlab
.
signup_enabled
%fieldset
.remove-account
%legend
Remove account
%small
.cred.pull-right
Before removing the account you must remove all projects!
=
link_to
'Delete account'
,
user_registration_path
,
confirm:
"REMOVE
#{
current_user
.
name
}
? Are you sure?"
,
method: :delete
,
class:
"btn btn-remove delete-key btn-small pull-right"
\ No newline at end of file
config/routes.rb
View file @
375caeef
...
@@ -167,12 +167,12 @@ Gitlab::Application.routes.draw do
...
@@ -167,12 +167,12 @@ Gitlab::Application.routes.draw do
get
"files"
get
"files"
end
end
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:tree
,
only:
[
:show
,
:edit
,
:update
],
constraints:
{
id:
/.+/
}
resources
:tree
,
only:
[
:show
,
:edit
,
:update
],
constraints:
{
id:
/.+/
}
resources
:commit
,
only:
[
:show
],
constraints:
{
id:
/[[:alnum:]]{6,40}/
}
resources
:commit
,
only:
[
:show
],
constraints:
{
id:
/[[:alnum:]]{6,40}/
}
resources
:commits
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:commits
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:compare
,
only:
[
:index
,
:create
]
resources
:compare
,
only:
[
:index
,
:create
]
resources
:blame
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blame
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:blob
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:graph
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
resources
:graph
,
only:
[
:show
],
constraints:
{
id:
/.+/
}
match
"/compare/:from...:to"
=>
"compare#show"
,
as:
"compare"
,
match
"/compare/:from...:to"
=>
"compare#show"
,
as:
"compare"
,
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
:via
=>
[
:get
,
:post
],
constraints:
{
from:
/.+/
,
to:
/.+/
}
...
...
doc/api/repositories.md
View file @
375caeef
...
@@ -79,6 +79,9 @@ Parameters:
...
@@ -79,6 +79,9 @@ Parameters:
}
}
```
```
Will return status code
`200`
on success or
`404 Not found`
if the branch is not available.
## Protect a project repository branch
## Protect a project repository branch
Protect a single project repository branch.
Protect a single project repository branch.
...
...
lib/api/projects.rb
View file @
375caeef
...
@@ -265,6 +265,7 @@ module Gitlab
...
@@ -265,6 +265,7 @@ module Gitlab
# GET /projects/:id/repository/branches/:branch
# GET /projects/:id/repository/branches/:branch
get
":id/repository/branches/:branch"
do
get
":id/repository/branches/:branch"
do
@branch
=
user_project
.
repo
.
heads
.
find
{
|
item
|
item
.
name
==
params
[
:branch
]
}
@branch
=
user_project
.
repo
.
heads
.
find
{
|
item
|
item
.
name
==
params
[
:branch
]
}
not_found!
(
"Branch does not exist"
)
if
@branch
.
nil?
present
@branch
,
with:
Entities
::
RepoObject
,
project:
user_project
present
@branch
,
with:
Entities
::
RepoObject
,
project:
user_project
end
end
...
...
lib/extracts_path.rb
View file @
375caeef
...
@@ -117,7 +117,10 @@ module ExtractsPath
...
@@ -117,7 +117,10 @@ module ExtractsPath
@id
=
File
.
join
(
@ref
,
@path
)
@id
=
File
.
join
(
@ref
,
@path
)
@commit
=
CommitDecorator
.
decorate
(
@project
.
repository
.
commit
(
@ref
))
# It is used "@project.repository.commits(@ref, @path, 1, 0)",
# because "@project.repository.commit(@ref)" returns wrong commit when @ref is tag name.
commits
=
@project
.
repository
.
commits
(
@ref
,
@path
,
1
,
0
)
@commit
=
CommitDecorator
.
decorate
(
commits
.
first
)
@tree
=
Tree
.
new
(
@commit
.
tree
,
@ref
,
@path
)
@tree
=
Tree
.
new
(
@commit
.
tree
,
@ref
,
@path
)
@tree
=
TreeDecorator
.
new
(
@tree
)
@tree
=
TreeDecorator
.
new
(
@tree
)
...
...
lib/gitlab/graph/json_builder.rb
View file @
375caeef
...
@@ -9,9 +9,10 @@ module Gitlab
...
@@ -9,9 +9,10 @@ module Gitlab
@max_count
||=
650
@max_count
||=
650
end
end
def
initialize
project
,
ref
def
initialize
project
,
ref
,
commit
@project
=
project
@project
=
project
@ref
=
ref
@ref
=
ref
@commit
=
commit
@repo
=
project
.
repo
@repo
=
project
.
repo
@ref_cache
=
{}
@ref_cache
=
{}
...
@@ -31,7 +32,8 @@ module Gitlab
...
@@ -31,7 +32,8 @@ module Gitlab
# Get commits from repository
# Get commits from repository
#
#
def
collect_commits
def
collect_commits
@commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
max_count:
self
.
class
.
max_count
}).
dup
@commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
topo_order:
true
,
max_count:
self
.
class
.
max_count
,
skip:
to_commit
}).
dup
# Decorate with app/models/commit.rb
# Decorate with app/models/commit.rb
@commits
.
map!
{
|
commit
|
::
Commit
.
new
(
commit
)
}
@commits
.
map!
{
|
commit
|
::
Commit
.
new
(
commit
)
}
...
@@ -49,41 +51,28 @@ module Gitlab
...
@@ -49,41 +51,28 @@ module Gitlab
# list of commits. As well as returns date list
# list of commits. As well as returns date list
# corelated with time set on commits.
# corelated with time set on commits.
#
#
# @param [Array<Graph::Commit>] comits to index
# @param [Array<Graph::Commit>] com
m
its to index
#
#
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
# @return [Array<TimeDate>] list of commit dates corelated with time on commits
def
index_commits
def
index_commits
days
,
heads
,
times
=
[],
[],
[]
days
,
times
=
[],
[]
map
=
{}
map
=
{}
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
commits
.
reverse
.
each_with_index
do
|
c
,
i
|
c
.
time
=
i
c
.
time
=
i
days
[
i
]
=
c
.
committed_date
days
[
i
]
=
c
.
committed_date
map
[
c
.
id
]
=
c
map
[
c
.
id
]
=
c
heads
+=
c
.
refs
unless
c
.
refs
.
nil?
times
[
i
]
=
c
times
[
i
]
=
c
end
end
heads
.
select!
{
|
h
|
h
.
is_a?
Grit
::
Head
or
h
.
is_a?
Grit
::
Remote
}
# sort heads so the master is top and current branches are closer
heads
.
sort!
do
|
a
,
b
|
if
a
.
name
==
@ref
-
1
elsif
b
.
name
==
@ref
1
else
b
.
commit
.
committed_date
<=>
a
.
commit
.
committed_date
end
end
@_reserved
=
{}
@_reserved
=
{}
days
.
each_index
do
|
i
|
days
.
each_index
do
|
i
|
@_reserved
[
i
]
=
[]
@_reserved
[
i
]
=
[]
end
end
heads
.
each
do
|
h
|
commits_sort_by_ref
.
each
do
|
commit
|
if
map
.
include?
h
.
commit
.
id
then
if
map
.
include?
commit
.
id
then
place_chain
(
map
[
h
.
commit
.
id
],
map
)
place_chain
(
map
[
commit
.
id
],
map
)
end
end
end
end
...
@@ -95,6 +84,45 @@ module Gitlab
...
@@ -95,6 +84,45 @@ module Gitlab
days
days
end
end
# Skip count that the target commit is displayed in center.
def
to_commit
commits
=
Grit
::
Commit
.
find_all
(
repo
,
nil
,
{
topo_order:
true
})
commit_index
=
commits
.
index
do
|
c
|
c
.
id
==
@commit
.
id
end
if
commit_index
&&
(
self
.
class
.
max_count
/
2
<
commit_index
)
then
# get max index that commit is displayed in the center.
commit_index
-
self
.
class
.
max_count
/
2
else
0
end
end
def
commits_sort_by_ref
commits
.
sort
do
|
a
,
b
|
if
include_ref?
(
a
)
-
1
elsif
include_ref?
(
b
)
1
else
b
.
committed_date
<=>
a
.
committed_date
end
end
end
def
include_ref?
(
commit
)
heads
=
commit
.
refs
.
select
do
|
ref
|
ref
.
is_a?
(
Grit
::
Head
)
or
ref
.
is_a?
(
Grit
::
Remote
)
or
ref
.
is_a?
(
Grit
::
Tag
)
end
heads
.
map!
do
|
head
|
head
.
name
end
heads
.
include?
(
@ref
)
end
def
find_free_parent_spaces
(
commit
,
map
,
times
)
def
find_free_parent_spaces
(
commit
,
map
,
times
)
spaces
=
[]
spaces
=
[]
...
...
lib/tasks/gitlab/check.rake
View file @
375caeef
...
@@ -311,7 +311,7 @@ namespace :gitlab do
...
@@ -311,7 +311,7 @@ namespace :gitlab do
"Remove
\"
-e
\"
so the line starts with PATH"
"Remove
\"
-e
\"
so the line starts with PATH"
)
)
for_more_information
(
for_more_information
(
see_installation_guide_section
(
"Git
olite
"
),
see_installation_guide_section
(
"Git
lab Shell
"
),
"https://github.com/gitlabhq/gitlabhq/issues/1059"
"https://github.com/gitlabhq/gitlabhq/issues/1059"
)
)
fix_and_rerun
fix_and_rerun
...
@@ -368,10 +368,10 @@ namespace :gitlab do
...
@@ -368,10 +368,10 @@ namespace :gitlab do
namespace
:gitlab_shell
do
namespace
:gitlab_shell
do
desc
"GITLAB | Check the configuration of Git
olite
"
desc
"GITLAB | Check the configuration of Git
lab Shell
"
task
check: :environment
do
task
check: :environment
do
warn_user_is_not_gitlab
warn_user_is_not_gitlab
start_checking
"Git
olite
"
start_checking
"Git
lab Shell
"
check_repo_base_exists
check_repo_base_exists
check_repo_base_is_not_symlink
check_repo_base_is_not_symlink
...
@@ -380,7 +380,7 @@ namespace :gitlab do
...
@@ -380,7 +380,7 @@ namespace :gitlab do
check_post_receive_hook_is_up_to_date
check_post_receive_hook_is_up_to_date
check_repos_post_receive_hooks_is_link
check_repos_post_receive_hooks_is_link
finished_checking
"Git
olite
"
finished_checking
"Git
lab Shell
"
end
end
...
@@ -392,7 +392,7 @@ namespace :gitlab do
...
@@ -392,7 +392,7 @@ namespace :gitlab do
print
"post-receive hook up-to-date? ... "
print
"post-receive hook up-to-date? ... "
hook_file
=
"post-receive"
hook_file
=
"post-receive"
gitlab_shell_hooks_path
=
File
.
join
(
Gitlab
.
config
.
gitlab_shell
.
hooks_path
,
"common"
)
gitlab_shell_hooks_path
=
Gitlab
.
config
.
gitlab_shell
.
hooks_path
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
...
@@ -401,22 +401,7 @@ namespace :gitlab do
...
@@ -401,22 +401,7 @@ namespace :gitlab do
return
return
end
end
gitlab_shell_hook_content
=
File
.
read
(
gitlab_shell_hook_file
)
gitlab_hook_file
=
Rails
.
root
.
join
.
join
(
"lib"
,
"hooks"
,
hook_file
)
gitlab_hook_content
=
File
.
read
(
gitlab_hook_file
)
if
gitlab_shell_hook_content
==
gitlab_hook_content
puts
"yes"
.
green
puts
"yes"
.
green
else
puts
"no"
.
red
try_fixing_it
(
"sudo -u
#{
gitlab_shell_ssh_user
}
cp
#{
gitlab_hook_file
}
#{
gitlab_shell_hook_file
}
"
)
for_more_information
(
see_installation_guide_section
"Setup GitLab Hooks"
)
fix_and_rerun
end
end
end
def
check_repo_base_exists
def
check_repo_base_exists
...
@@ -430,12 +415,12 @@ namespace :gitlab do
...
@@ -430,12 +415,12 @@ namespace :gitlab do
puts
"no"
.
red
puts
"no"
.
red
puts
"
#{
repo_base_path
}
is missing"
.
red
puts
"
#{
repo_base_path
}
is missing"
.
red
try_fixing_it
(
try_fixing_it
(
"This should have been created when setting up Git
olite
."
,
"This should have been created when setting up Git
lab Shell
."
,
"Make sure it's set correctly in config/gitlab.yml"
,
"Make sure it's set correctly in config/gitlab.yml"
,
"Make sure Git
olite
is installed correctly."
"Make sure Git
lab Shell
is installed correctly."
)
)
for_more_information
(
for_more_information
(
see_installation_guide_section
"Git
olite
"
see_installation_guide_section
"Git
lab Shell
"
)
)
fix_and_rerun
fix_and_rerun
end
end
...
@@ -480,7 +465,7 @@ namespace :gitlab do
...
@@ -480,7 +465,7 @@ namespace :gitlab do
"find
#{
repo_base_path
}
-type d -print0 | sudo xargs -0 chmod g+s"
"find
#{
repo_base_path
}
-type d -print0 | sudo xargs -0 chmod g+s"
)
)
for_more_information
(
for_more_information
(
see_installation_guide_section
"Git
olite
"
see_installation_guide_section
"Git
lab Shell
"
)
)
fix_and_rerun
fix_and_rerun
end
end
...
@@ -506,7 +491,7 @@ namespace :gitlab do
...
@@ -506,7 +491,7 @@ namespace :gitlab do
"sudo chown -R
#{
gitlab_shell_ssh_user
}
:
#{
gitlab_shell_owner_group
}
#{
repo_base_path
}
"
"sudo chown -R
#{
gitlab_shell_ssh_user
}
:
#{
gitlab_shell_owner_group
}
#{
repo_base_path
}
"
)
)
for_more_information
(
for_more_information
(
see_installation_guide_section
"Git
olite
"
see_installation_guide_section
"Git
lab Shell
"
)
)
fix_and_rerun
fix_and_rerun
end
end
...
@@ -516,7 +501,7 @@ namespace :gitlab do
...
@@ -516,7 +501,7 @@ namespace :gitlab do
print
"post-receive hooks in repos are links: ... "
print
"post-receive hooks in repos are links: ... "
hook_file
=
"post-receive"
hook_file
=
"post-receive"
gitlab_shell_hooks_path
=
File
.
join
(
Gitlab
.
config
.
gitlab_shell
.
hooks_path
,
"common"
)
gitlab_shell_hooks_path
=
Gitlab
.
config
.
gitlab_shell
.
hooks_path
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_hook_file
=
File
.
join
(
gitlab_shell_hooks_path
,
hook_file
)
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
gitlab_shell_ssh_user
=
Gitlab
.
config
.
gitlab_shell
.
ssh_user
...
@@ -545,7 +530,7 @@ namespace :gitlab do
...
@@ -545,7 +530,7 @@ namespace :gitlab do
"sudo -u
#{
gitlab_shell_ssh_user
}
ln -sf
#{
gitlab_shell_hook_file
}
#{
project_hook_file
}
"
"sudo -u
#{
gitlab_shell_ssh_user
}
ln -sf
#{
gitlab_shell_hook_file
}
#{
project_hook_file
}
"
)
)
for_more_information
(
for_more_information
(
"
lib
/support/rewrite-hooks.sh"
"
#{
gitlab_shell_user_home
}
/gitlab-shell
/support/rewrite-hooks.sh"
)
)
fix_and_rerun
fix_and_rerun
next
next
...
@@ -555,7 +540,7 @@ namespace :gitlab do
...
@@ -555,7 +540,7 @@ namespace :gitlab do
File
.
realpath
(
project_hook_file
)
==
File
.
realpath
(
gitlab_shell_hook_file
)
File
.
realpath
(
project_hook_file
)
==
File
.
realpath
(
gitlab_shell_hook_file
)
puts
"ok"
.
green
puts
"ok"
.
green
else
else
puts
"not a link to Git
olite
's hook"
.
red
puts
"not a link to Git
lab Shell
's hook"
.
red
try_fixing_it
(
try_fixing_it
(
"sudo -u
#{
gitlab_shell_ssh_user
}
ln -sf
#{
gitlab_shell_hook_file
}
#{
project_hook_file
}
"
"sudo -u
#{
gitlab_shell_ssh_user
}
ln -sf
#{
gitlab_shell_hook_file
}
#{
project_hook_file
}
"
)
)
...
@@ -577,7 +562,7 @@ namespace :gitlab do
...
@@ -577,7 +562,7 @@ namespace :gitlab do
end
end
def
gitlab_shell_version
def
gitlab_shell_version
gitlab_shell_version_file
=
"
#{
gitlab_shell_user_home
}
/gitlab
_shell/src
/VERSION"
gitlab_shell_version_file
=
"
#{
gitlab_shell_user_home
}
/gitlab
-shell
/VERSION"
if
File
.
readable?
(
gitlab_shell_version_file
)
if
File
.
readable?
(
gitlab_shell_version_file
)
File
.
read
(
gitlab_shell_version_file
)
File
.
read
(
gitlab_shell_version_file
)
end
end
...
...
lib/tasks/sidekiq.rake
View file @
375caeef
...
@@ -9,6 +9,11 @@ namespace :sidekiq do
...
@@ -9,6 +9,11 @@ namespace :sidekiq do
run
"nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e
#{
Rails
.
env
}
-P
#{
pidfile
}
>>
#{
Rails
.
root
.
join
(
"log"
,
"sidekiq.log"
)
}
2>&1 &"
run
"nohup bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e
#{
Rails
.
env
}
-P
#{
pidfile
}
>>
#{
Rails
.
root
.
join
(
"log"
,
"sidekiq.log"
)
}
2>&1 &"
end
end
desc
"GITLAB | Start sidekiq with launchd on Mac OS X"
task
:launchd
do
run
"bundle exec sidekiq -q post_receive,mailer,system_hook,project_web_hook,gitlab_shell,common,default -e
#{
Rails
.
env
}
-P
#{
pidfile
}
>>
#{
Rails
.
root
.
join
(
"log"
,
"sidekiq.log"
)
}
2>&1"
end
def
pidfile
def
pidfile
Rails
.
root
.
join
(
"tmp"
,
"pids"
,
"sidekiq.pid"
)
Rails
.
root
.
join
(
"tmp"
,
"pids"
,
"sidekiq.pid"
)
end
end
...
...
spec/factories.rb
View file @
375caeef
...
@@ -123,7 +123,7 @@ FactoryGirl.define do
...
@@ -123,7 +123,7 @@ FactoryGirl.define do
factory
:event
do
factory
:event
do
factory
:closed_issue_event
do
factory
:closed_issue_event
do
project
project
action
Event
::
Closed
action
{
Event
::
Closed
}
target
factory: :closed_issue
target
factory: :closed_issue
author
factory: :user
author
factory: :user
end
end
...
...
spec/requests/api/projects_spec.rb
View file @
375caeef
...
@@ -115,6 +115,11 @@ describe Gitlab::API do
...
@@ -115,6 +115,11 @@ describe Gitlab::API do
json_response
[
'commit'
][
'id'
].
should
==
'621491c677087aa243f165eab467bfdfbee00be1'
json_response
[
'commit'
][
'id'
].
should
==
'621491c677087aa243f165eab467bfdfbee00be1'
json_response
[
'protected'
].
should
==
false
json_response
[
'protected'
].
should
==
false
end
end
it
"should return a 404 error if branch is not available"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/branches/unknown"
,
user
)
response
.
status
.
should
==
404
end
end
end
describe
"PUT /projects/:id/repository/branches/:branch/protect"
do
describe
"PUT /projects/:id/repository/branches/:branch/protect"
do
...
...
spec/requests/profile_spec.rb
0 → 100644
View file @
375caeef
require
'spec_helper'
describe
"Profile account page"
do
let
(
:user
)
{
create
(
:user
)
}
before
do
login_as
:user
end
describe
"when signup is enabled"
do
before
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
true
)
visit
account_profile_path
end
it
{
page
.
should
have_content
(
"Remove account"
)
}
it
"should delete the account"
,
js:
true
do
expect
{
click_link
"Delete account"
}.
to
change
{
User
.
count
}.
by
(
-
1
)
current_path
.
should
==
new_user_session_path
end
end
describe
"when signup is enabled and user has a project"
do
before
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
true
)
@project
=
create
(
:project
,
namespace:
@user
.
namespace
)
@project
.
team
<<
[
@user
,
:master
]
visit
account_profile_path
end
it
{
page
.
should
have_content
(
"Remove account"
)
}
it
"should not allow user to delete the account"
do
expect
{
click_link
"Delete account"
}.
not_to
change
{
User
.
count
}.
by
(
-
1
)
end
end
describe
"when signup is disabled"
do
before
do
Gitlab
.
config
.
gitlab
.
stub
(
:signup_enabled
).
and_return
(
false
)
visit
account_profile_path
end
it
"should not have option to remove account"
do
page
.
should_not
have_content
(
"Remove account"
)
current_path
.
should
==
account_profile_path
end
end
end
\ No newline at end of file
spec/routing/project_routing_spec.rb
View file @
375caeef
...
@@ -392,6 +392,7 @@ end
...
@@ -392,6 +392,7 @@ end
describe
BlobController
,
"routing"
do
describe
BlobController
,
"routing"
do
it
"to #show"
do
it
"to #show"
do
get
(
"/gitlabhq/blob/master/app/models/project.rb"
).
should
route_to
(
'blob#show'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/project.rb'
)
get
(
"/gitlabhq/blob/master/app/models/project.rb"
).
should
route_to
(
'blob#show'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/project.rb'
)
get
(
"/gitlabhq/blob/master/app/models/compare.rb"
).
should
route_to
(
'blob#show'
,
project_id:
'gitlabhq'
,
id:
'master/app/models/compare.rb'
)
end
end
end
end
...
...
vendor/assets/javascripts/branch-graph.js
View file @
375caeef
...
@@ -161,13 +161,22 @@
...
@@ -161,13 +161,22 @@
if
(
this
.
commits
[
i
].
refs
)
{
if
(
this
.
commits
[
i
].
refs
)
{
this
.
appendLabel
(
x
,
y
,
this
.
commits
[
i
].
refs
);
this
.
appendLabel
(
x
,
y
,
this
.
commits
[
i
].
refs
);
}
// The main branch is displayed in the center.
// mark commit and displayed in the center
re
=
new
RegExp
(
'
(^| )
'
+
this
.
options
.
ref
+
'
( |$)
'
);
if
(
this
.
commits
[
i
].
id
==
this
.
options
.
commit_id
)
{
if
(
this
.
commits
[
i
].
refs
.
match
(
re
))
{
r
.
path
([
'
M
'
,
x
,
y
-
5
,
'
L
'
,
x
+
4
,
y
-
15
,
'
L
'
,
x
-
4
,
y
-
15
,
'
Z
'
]).
attr
({
"
fill
"
:
"
#000
"
,
"
fill-opacity
"
:
.
7
,
"
stroke
"
:
"
none
"
});
scrollLeft
=
x
-
graphWidth
/
2
;
scrollLeft
=
x
-
graphWidth
/
2
;
}
}
}
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
this
.
appendAnchor
(
top
,
this
.
commits
[
i
],
x
,
y
);
}
}
...
...
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