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
27d9ac0f
Commit
27d9ac0f
authored
Feb 04, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make gitlab works with gitlab-shell
parent
6b9a6090
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
42 additions
and
69 deletions
+42
-69
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+0
-5
app/models/key.rb
app/models/key.rb
+4
-0
app/models/project.rb
app/models/project.rb
+0
-14
app/models/users_project.rb
app/models/users_project.rb
+0
-7
app/observers/key_observer.rb
app/observers/key_observer.rb
+4
-8
app/observers/project_observer.rb
app/observers/project_observer.rb
+11
-5
config/initializers/5_backend.rb
config/initializers/5_backend.rb
+2
-2
lib/gitlab/backend/shell.rb
lib/gitlab/backend/shell.rb
+20
-27
lib/gitolited.rb
lib/gitolited.rb
+1
-1
No files found.
app/controllers/application_controller.rb
View file @
27d9ac0f
...
@@ -10,11 +10,6 @@ class ApplicationController < ActionController::Base
...
@@ -10,11 +10,6 @@ class ApplicationController < ActionController::Base
helper_method
:abilities
,
:can?
helper_method
:abilities
,
:can?
rescue_from
Gitlab
::
Gitolite
::
AccessDenied
do
|
exception
|
log_exception
(
exception
)
render
"errors/gitolite"
,
layout:
"errors"
,
status:
500
end
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
log_exception
(
exception
)
log_exception
(
exception
)
render
"errors/encoding"
,
layout:
"errors"
,
status:
500
render
"errors/encoding"
,
layout:
"errors"
,
status:
500
...
...
app/models/key.rb
View file @
27d9ac0f
...
@@ -80,4 +80,8 @@ class Key < ActiveRecord::Base
...
@@ -80,4 +80,8 @@ class Key < ActiveRecord::Base
def
last_deploy?
def
last_deploy?
Key
.
where
(
identifier:
identifier
).
count
==
0
Key
.
where
(
identifier:
identifier
).
count
==
0
end
end
def
owner_name
user
.
username
end
end
end
app/models/project.rb
View file @
27d9ac0f
...
@@ -459,20 +459,6 @@ class Project < ActiveRecord::Base
...
@@ -459,20 +459,6 @@ class Project < ActiveRecord::Base
namespace
.
try
(
:path
)
||
''
namespace
.
try
(
:path
)
||
''
end
end
def
update_repository
GitoliteWorker
.
perform_async
(
:update_repository
,
self
.
id
)
end
def
destroy_repository
GitoliteWorker
.
perform_async
(
:remove_repository
,
self
.
path_with_namespace
)
end
def
repo_exists?
def
repo_exists?
@repo_exists
||=
(
repository
&&
repository
.
branches
.
present?
)
@repo_exists
||=
(
repository
&&
repository
.
branches
.
present?
)
rescue
rescue
...
...
app/models/users_project.rb
View file @
27d9ac0f
...
@@ -25,9 +25,6 @@ class UsersProject < ActiveRecord::Base
...
@@ -25,9 +25,6 @@ class UsersProject < ActiveRecord::Base
attr_accessor
:skip_git
attr_accessor
:skip_git
after_save
:update_repository
,
unless: :skip_git?
after_destroy
:update_repository
,
unless: :skip_git?
validates
:user
,
presence:
true
validates
:user
,
presence:
true
validates
:user_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:user_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:project_access
,
inclusion:
{
in:
[
GUEST
,
REPORTER
,
DEVELOPER
,
MASTER
]
},
presence:
true
validates
:project_access
,
inclusion:
{
in:
[
GUEST
,
REPORTER
,
DEVELOPER
,
MASTER
]
},
presence:
true
...
@@ -136,10 +133,6 @@ class UsersProject < ActiveRecord::Base
...
@@ -136,10 +133,6 @@ class UsersProject < ActiveRecord::Base
end
end
end
end
def
update_repository
project
.
update_repository
end
def
project_access_human
def
project_access_human
Project
.
access_options
.
key
(
self
.
project_access
)
Project
.
access_options
.
key
(
self
.
project_access
)
end
end
...
...
app/observers/key_observer.rb
View file @
27d9ac0f
...
@@ -3,20 +3,16 @@ class KeyObserver < ActiveRecord::Observer
...
@@ -3,20 +3,16 @@ class KeyObserver < ActiveRecord::Observer
def
after_save
(
key
)
def
after_save
(
key
)
GitoliteWorker
.
perform_async
(
GitoliteWorker
.
perform_async
(
:set_key
,
:add_key
,
key
.
identifier
,
key
.
owner_name
,
key
.
key
,
key
.
key
key
.
projects
.
map
(
&
:id
)
)
)
end
end
def
after_destroy
(
key
)
def
after_destroy
(
key
)
return
if
key
.
is_deploy_key
&&
!
key
.
last_deploy?
GitoliteWorker
.
perform_async
(
GitoliteWorker
.
perform_async
(
:remove_key
,
:remove_key
,
key
.
identifier
,
key
.
key
,
key
.
projects
.
map
(
&
:id
)
)
)
end
end
end
end
app/observers/project_observer.rb
View file @
27d9ac0f
class
ProjectObserver
<
ActiveRecord
::
Observer
class
ProjectObserver
<
ActiveRecord
::
Observer
def
after_create
(
project
)
def
after_create
(
project
)
project
.
update_repository
GitoliteWorker
.
perform_async
(
:add_repository
,
project
.
path_with_namespace
)
log_info
(
"
#{
project
.
owner
.
name
}
created a new project
\"
#{
project
.
name_with_namespace
}
\"
"
)
end
end
def
after_update
(
project
)
def
after_update
(
project
)
...
@@ -8,14 +13,15 @@ class ProjectObserver < ActiveRecord::Observer
...
@@ -8,14 +13,15 @@ class ProjectObserver < ActiveRecord::Observer
end
end
def
after_destroy
(
project
)
def
after_destroy
(
project
)
log_info
(
"Project
\"
#{
project
.
name
}
\"
was removed"
)
GitoliteWorker
.
perform_async
(
:remove_repository
,
self
.
path_with_namespace
)
project
.
satellite
.
destroy
project
.
satellite
.
destroy
project
.
destroy_repository
project
.
destroy_repository
end
def
after_create
project
log_info
(
"Project
\"
#{
project
.
name
}
\"
was removed"
)
log_info
(
"
#{
project
.
owner
.
name
}
created a new project
\"
#{
project
.
name_with_namespace
}
\"
"
)
end
end
protected
protected
...
...
config/initializers/5_backend.rb
View file @
27d9ac0f
# GIT over HTTP
# GIT over HTTP
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"grack_auth"
)
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"grack_auth"
)
# GIT
OLITE backend
# GIT
over SSH
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"
gitolite
"
)
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"
shell
"
)
lib/gitlab/backend/
gitolite
.rb
→
lib/gitlab/backend/
shell
.rb
View file @
27d9ac0f
module
Gitlab
module
Gitlab
class
Gitolite
class
Shell
class
AccessDenied
<
StandardError
;
end
class
AccessDenied
<
StandardError
;
end
def
config
# Init new repository
Gitlab
::
GitoliteConfig
.
new
end
# Add new key to gitlab-shell
#
# Ex.
# add_key("randx", "sha-rsa ...")
#
#
def
add_key
(
username
,
key_content
)
# name - project path with namespace
# TODO: implement
end
# Remove ssh key from gitlab shell
#
#
# Ex.
# Ex.
#
remove_key("sha-rsa
")
#
add_repository("gitlab/gitlab-ci
")
#
#
def
remove_key
(
key_content
)
def
add_repository
(
name
)
# TODO: implement
system
(
"/home/git/gitlab-shell/bin/gitlab-projects add-project
#{
name
}
.git"
)
end
end
# Remove repository from file system
# Remove repository from file system
...
@@ -32,26 +21,30 @@ module Gitlab
...
@@ -32,26 +21,30 @@ module Gitlab
# remove_repository("gitlab/gitlab-ci")
# remove_repository("gitlab/gitlab-ci")
#
#
def
remove_repository
(
name
)
def
remove_repository
(
name
)
# TODO: implement
system
(
"/home/git/gitlab-shell/bin/gitlab-projects rm-project
#{
name
}
.git"
)
end
end
#
Init new repository
#
Add new key to gitlab-shell
#
#
# name - project path with namespace
# Ex.
# add_key("randx", "sha-rsa ...")
#
def
add_key
(
username
,
key_content
)
system
(
"/home/git/gitlab-shell/bin/gitlab-keys add-key
#{
username
}
\"
#{
key_content
}
\"
"
)
end
# Remove ssh key from gitlab shell
#
#
# Ex.
# Ex.
#
add_repository("gitlab/gitlab-ci
")
#
remove_key("sha-rsa
")
#
#
def
add_repository
(
name
)
def
remove_key
(
key_content
)
# TODO: implement
system
(
"/home/git/gitlab-shell/bin/gitlab-keys rm-key
\"
#{
key_content
}
\"
"
)
end
end
def
url_to_repo
path
def
url_to_repo
path
Gitlab
.
config
.
gitolite
.
ssh_path_prefix
+
"
#{
path
}
.git"
Gitlab
.
config
.
gitolite
.
ssh_path_prefix
+
"
#{
path
}
.git"
end
end
def
enable_automerge
config
.
admin_all_repo!
end
end
end
end
end
lib/gitolited.rb
View file @
27d9ac0f
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
#
#
module
Gitolited
module
Gitolited
def
gitolite
def
gitolite
Gitlab
::
Gitolite
.
new
Gitlab
::
Shell
.
new
end
end
end
end
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