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
674cbe93
Commit
674cbe93
authored
Nov 29, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dont allow project creation without repository
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
27cd35de
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
41 deletions
+52
-41
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+4
-3
app/models/project.rb
app/models/project.rb
+21
-0
app/services/projects/create_service.rb
app/services/projects/create_service.rb
+26
-24
app/views/projects/create.js.haml
app/views/projects/create.js.haml
+0
-13
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+1
-1
No files found.
app/controllers/projects_controller.rb
View file @
674cbe93
...
...
@@ -19,10 +19,11 @@ class ProjectsController < ApplicationController
def
create
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
project_params
).
execute
flash
[
:notice
]
=
'Project was successfully created.'
if
@project
.
saved?
respond_to
do
|
format
|
format
.
js
if
@project
.
saved?
redirect_to
project_path
(
@project
),
notice:
'Project was successfully created.'
else
render
'new'
end
end
...
...
app/models/project.rb
View file @
674cbe93
...
...
@@ -586,4 +586,25 @@ class Project < ActiveRecord::Base
def
origin_merge_requests
merge_requests
.
where
(
source_project_id:
self
.
id
)
end
def
create_repository
if
gitlab_shell
.
add_repository
(
path_with_namespace
)
true
else
errors
.
add
(
:base
,
"Failed to create repository"
)
false
end
end
def
repository_exists?
!!
repository
.
exists?
end
def
create_wiki
ProjectWiki
.
new
(
self
,
self
.
owner
).
wiki
true
rescue
ProjectWiki
::
CouldNotCreateWikiError
=>
ex
errors
.
add
(
:base
,
"Failed create wiki"
)
false
end
end
app/services/projects/create_service.rb
View file @
674cbe93
...
...
@@ -37,35 +37,22 @@ module Projects
@project
.
creator
=
current_user
if
@project
.
save
log_info
(
"
#{
@project
.
owner
.
name
}
created a new project
\"
#{
@project
.
name_with_namespace
}
\"
"
)
system_hook_service
.
execute_hooks_for
(
@project
,
:create
)
Project
.
transaction
do
@project
.
save
unless
@project
.
group
@project
.
team
<<
[
current_user
,
:master
]
end
@project
.
update_column
(
:last_activity_at
,
@project
.
created_at
)
if
@project
.
import?
@project
.
import_start
else
GitlabShellWorker
.
perform_async
(
:add_repository
,
@project
.
path_with_namespace
)
unless
@project
.
import?
unless
@project
.
create_repository
raise
'Failed to create repository'
end
end
end
if
@project
.
persisted?
if
@project
.
wiki_enabled?
begin
# force the creation of a wiki,
ProjectWiki
.
new
(
@project
,
@project
.
owner
).
wiki
rescue
ProjectWiki
::
CouldNotCreateWikiError
=>
ex
# Prevent project observer crash
# if failed to create wiki
nil
end
@project
.
create_wiki
end
after_create_actions
end
@project
...
...
@@ -84,5 +71,20 @@ module Projects
namespace
=
Namespace
.
find_by
(
id:
namespace_id
)
current_user
.
can?
(
:create_projects
,
namespace
)
end
def
after_create_actions
log_info
(
"
#{
@project
.
owner
.
name
}
created a new project
\"
#{
@project
.
name_with_namespace
}
\"
"
)
system_hook_service
.
execute_hooks_for
(
@project
,
:create
)
unless
@project
.
group
@project
.
team
<<
[
current_user
,
:master
]
end
@project
.
update_column
(
:last_activity_at
,
@project
.
created_at
)
if
@project
.
import?
@project
.
import_start
end
end
end
end
app/views/projects/create.js.haml
deleted
100644 → 0
View file @
27cd35de
-
if
@project
.
saved?
-
if
@project
.
import?
:plain
location.href = "
#{
import_project_path
(
@project
)
}
";
-
else
:plain
location.href = "
#{
project_path
(
@project
)
}
";
-
else
:plain
$(".project-edit-errors").html("
#{
escape_javascript
(
render
(
'errors'
))
}
");
$('.project-submit').enable();
$('.save-project-loader').hide();
$('.project-edit-container').show();
app/views/projects/new.html.haml
View file @
674cbe93
...
...
@@ -3,7 +3,7 @@
=
render
'projects/errors'
.project-edit-content
=
form_for
@project
,
remote:
true
,
html:
{
class:
'new_project form-horizontal'
}
do
|
f
|
=
form_for
@project
,
html:
{
class:
'new_project form-horizontal'
}
do
|
f
|
.form-group.project-name-holder
=
f
.
label
:name
,
class:
'control-label'
do
%strong
Project name
...
...
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