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
Jérome Perrin
gitlab-ce
Commits
71214bee
Commit
71214bee
authored
Nov 22, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move directory with project. Fixed all related path methods to use namespace
parent
e29ccece
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
55 additions
and
10 deletions
+55
-10
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+6
-2
app/controllers/dashboard_controller.rb
app/controllers/dashboard_controller.rb
+1
-1
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+1
-1
app/observers/issue_observer.rb
app/observers/issue_observer.rb
+3
-3
app/observers/project_observer.rb
app/observers/project_observer.rb
+20
-0
app/roles/repository.rb
app/roles/repository.rb
+6
-2
spec/factories.rb
spec/factories.rb
+5
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+12
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-0
No files found.
app/controllers/admin/groups_controller.rb
View file @
71214bee
...
@@ -48,14 +48,18 @@ class Admin::GroupsController < AdminController
...
@@ -48,14 +48,18 @@ class Admin::GroupsController < AdminController
def
project_update
def
project_update
project_ids
=
params
[
:project_ids
]
project_ids
=
params
[
:project_ids
]
Project
.
where
(
id:
project_ids
).
update_all
(
group_id:
@group
.
id
)
Project
.
where
(
id:
project_ids
).
each
do
|
project
|
project
.
namespace_id
=
@group
.
id
project
.
save
end
redirect_to
:back
,
notice:
'Group was successfully updated.'
redirect_to
:back
,
notice:
'Group was successfully updated.'
end
end
def
remove_project
def
remove_project
@project
=
Project
.
find
(
params
[
:project_id
])
@project
=
Project
.
find
(
params
[
:project_id
])
@project
.
group
_id
=
nil
@project
.
namespace
_id
=
nil
@project
.
save
@project
.
save
redirect_to
:back
,
notice:
'Group was successfully updated.'
redirect_to
:back
,
notice:
'Group was successfully updated.'
...
...
app/controllers/dashboard_controller.rb
View file @
71214bee
...
@@ -4,7 +4,7 @@ class DashboardController < ApplicationController
...
@@ -4,7 +4,7 @@ class DashboardController < ApplicationController
before_filter
:event_filter
,
only: :index
before_filter
:event_filter
,
only: :index
def
index
def
index
@groups
=
Group
.
where
(
id:
current_user
.
projects
.
pluck
(
:
group
_id
))
@groups
=
Group
.
where
(
id:
current_user
.
projects
.
pluck
(
:
namespace
_id
))
@projects
=
current_user
.
projects_sorted_by_activity
@projects
=
current_user
.
projects_sorted_by_activity
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
30
)
@projects
=
@projects
.
page
(
params
[
:page
]).
per
(
30
)
...
...
app/controllers/groups_controller.rb
View file @
71214bee
...
@@ -54,7 +54,7 @@ class GroupsController < ApplicationController
...
@@ -54,7 +54,7 @@ class GroupsController < ApplicationController
end
end
def
projects
def
projects
@projects
||=
current_user
.
projects_sorted_by_activity
.
where
(
group
_id:
@group
.
id
)
@projects
||=
current_user
.
projects_sorted_by_activity
.
where
(
namespace
_id:
@group
.
id
)
end
end
def
project_ids
def
project_ids
...
...
app/observers/issue_observer.rb
View file @
71214bee
...
@@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer
...
@@ -3,7 +3,7 @@ class IssueObserver < ActiveRecord::Observer
def
after_create
(
issue
)
def
after_create
(
issue
)
if
issue
.
assignee
&&
issue
.
assignee
!=
current_user
if
issue
.
assignee
&&
issue
.
assignee
!=
current_user
Notify
.
new_issue_email
(
issue
.
id
).
deliver
Notify
.
new_issue_email
(
issue
.
id
).
deliver
end
end
end
end
...
@@ -14,8 +14,8 @@ class IssueObserver < ActiveRecord::Observer
...
@@ -14,8 +14,8 @@ class IssueObserver < ActiveRecord::Observer
status
=
'closed'
if
issue
.
is_being_closed?
status
=
'closed'
if
issue
.
is_being_closed?
status
=
'reopened'
if
issue
.
is_being_reopened?
status
=
'reopened'
if
issue
.
is_being_reopened?
if
status
if
status
Note
.
create_status_change_note
(
issue
,
current_user
,
status
)
Note
.
create_status_change_note
(
issue
,
current_user
,
status
)
[
issue
.
author
,
issue
.
assignee
].
compact
.
each
do
|
recipient
|
[
issue
.
author
,
issue
.
assignee
].
compact
.
each
do
|
recipient
|
Notify
.
issue_status_changed_email
(
recipient
.
id
,
issue
.
id
,
status
,
current_user
)
Notify
.
issue_status_changed_email
(
recipient
.
id
,
issue
.
id
,
status
,
current_user
)
end
end
end
end
...
...
app/observers/project_observer.rb
View file @
71214bee
class
ProjectObserver
<
ActiveRecord
::
Observer
class
ProjectObserver
<
ActiveRecord
::
Observer
def
after_save
(
project
)
def
after_save
(
project
)
project
.
update_repository
project
.
update_repository
# Move repository if namespace changed
if
project
.
namespace_id_changed?
move_project
(
project
)
end
end
end
def
after_destroy
(
project
)
def
after_destroy
(
project
)
...
@@ -18,4 +23,19 @@ class ProjectObserver < ActiveRecord::Observer
...
@@ -18,4 +23,19 @@ class ProjectObserver < ActiveRecord::Observer
def
log_info
message
def
log_info
message
Gitlab
::
AppLogger
.
info
message
Gitlab
::
AppLogger
.
info
message
end
end
def
move_project
(
project
)
old_dir
=
Namespace
.
find_by_id
(
project
.
namespace_id_was
).
try
(
:code
)
||
''
new_dir
=
Namespace
.
find_by_id
(
project
.
namespace_id
).
try
(
:code
)
||
''
# Create new dir if missing
new_dir_path
=
File
.
join
(
Gitlab
.
config
.
git_base_path
,
new_dir
)
Dir
.
mkdir
(
new_dir_path
)
unless
File
.
exists?
(
new_dir_path
)
old_path
=
File
.
join
(
Gitlab
.
config
.
git_base_path
,
old_dir
,
"
#{
project
.
path
}
.git"
)
new_path
=
File
.
join
(
new_dir_path
,
"
#{
project
.
path
}
.git"
)
binding
.
pry
`mv
#{
old_path
}
#{
new_path
}
`
end
end
end
app/roles/repository.rb
View file @
71214bee
...
@@ -79,11 +79,15 @@ module Repository
...
@@ -79,11 +79,15 @@ module Repository
end
end
def
url_to_repo
def
url_to_repo
git_host
.
url_to_repo
(
path
)
git_host
.
url_to_repo
(
path
_with_namespace
)
end
end
def
path_to_repo
def
path_to_repo
File
.
join
(
Gitlab
.
config
.
git_base_path
,
"
#{
path
}
.git"
)
File
.
join
(
Gitlab
.
config
.
git_base_path
,
namespace_dir
,
"
#{
path
}
.git"
)
end
def
namespace_dir
namespace
.
try
(
:code
)
||
''
end
end
def
update_repository
def
update_repository
...
...
spec/factories.rb
View file @
71214bee
...
@@ -29,10 +29,14 @@ FactoryGirl.define do
...
@@ -29,10 +29,14 @@ FactoryGirl.define do
owner
owner
end
end
factory
:
group
do
factory
:
namespace
do
sequence
(
:name
)
{
|
n
|
"group
#{
n
}
"
}
sequence
(
:name
)
{
|
n
|
"group
#{
n
}
"
}
code
{
name
.
downcase
.
gsub
(
/\s/
,
'_'
)
}
code
{
name
.
downcase
.
gsub
(
/\s/
,
'_'
)
}
owner
owner
factory
:group
do
type
'Group'
end
end
end
factory
:users_project
do
factory
:users_project
do
...
...
spec/models/namespace_spec.rb
0 → 100644
View file @
71214bee
require
'spec_helper'
describe
Namespace
do
let!
(
:namespace
)
{
create
(
:namespace
)
}
it
{
should
have_many
:projects
}
it
{
should
validate_presence_of
:name
}
it
{
should
validate_uniqueness_of
(
:name
)
}
it
{
should
validate_presence_of
:code
}
it
{
should
validate_uniqueness_of
(
:code
)
}
it
{
should
validate_presence_of
:owner
}
end
spec/models/project_spec.rb
View file @
71214bee
...
@@ -24,6 +24,7 @@ require 'spec_helper'
...
@@ -24,6 +24,7 @@ require 'spec_helper'
describe
Project
do
describe
Project
do
describe
"Associations"
do
describe
"Associations"
do
it
{
should
belong_to
(
:group
)
}
it
{
should
belong_to
(
:group
)
}
it
{
should
belong_to
(
:namespace
)
}
it
{
should
belong_to
(
:owner
).
class_name
(
'User'
)
}
it
{
should
belong_to
(
:owner
).
class_name
(
'User'
)
}
it
{
should
have_many
(
:users
)
}
it
{
should
have_many
(
:users
)
}
it
{
should
have_many
(
:events
).
dependent
(
:destroy
)
}
it
{
should
have_many
(
:events
).
dependent
(
:destroy
)
}
...
...
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