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
Léo-Paul Géneau
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
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
|
log_exception
(
exception
)
render
"errors/encoding"
,
layout:
"errors"
,
status:
500
...
...
app/models/key.rb
View file @
27d9ac0f
...
...
@@ -80,4 +80,8 @@ class Key < ActiveRecord::Base
def
last_deploy?
Key
.
where
(
identifier:
identifier
).
count
==
0
end
def
owner_name
user
.
username
end
end
app/models/project.rb
View file @
27d9ac0f
...
...
@@ -459,20 +459,6 @@ class Project < ActiveRecord::Base
namespace
.
try
(
:path
)
||
''
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?
@repo_exists
||=
(
repository
&&
repository
.
branches
.
present?
)
rescue
...
...
app/models/users_project.rb
View file @
27d9ac0f
...
...
@@ -25,9 +25,6 @@ class UsersProject < ActiveRecord::Base
attr_accessor
:skip_git
after_save
:update_repository
,
unless: :skip_git?
after_destroy
:update_repository
,
unless: :skip_git?
validates
:user
,
presence:
true
validates
:user_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already exists in project"
}
validates
:project_access
,
inclusion:
{
in:
[
GUEST
,
REPORTER
,
DEVELOPER
,
MASTER
]
},
presence:
true
...
...
@@ -136,10 +133,6 @@ class UsersProject < ActiveRecord::Base
end
end
def
update_repository
project
.
update_repository
end
def
project_access_human
Project
.
access_options
.
key
(
self
.
project_access
)
end
...
...
app/observers/key_observer.rb
View file @
27d9ac0f
...
...
@@ -3,20 +3,16 @@ class KeyObserver < ActiveRecord::Observer
def
after_save
(
key
)
GitoliteWorker
.
perform_async
(
:set_key
,
key
.
identifier
,
key
.
key
,
key
.
projects
.
map
(
&
:id
)
:add_key
,
key
.
owner_name
,
key
.
key
)
end
def
after_destroy
(
key
)
return
if
key
.
is_deploy_key
&&
!
key
.
last_deploy?
GitoliteWorker
.
perform_async
(
:remove_key
,
key
.
identifier
,
key
.
projects
.
map
(
&
:id
)
key
.
key
,
)
end
end
app/observers/project_observer.rb
View file @
27d9ac0f
class
ProjectObserver
<
ActiveRecord
::
Observer
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
def
after_update
(
project
)
...
...
@@ -8,14 +13,15 @@ class ProjectObserver < ActiveRecord::Observer
end
def
after_destroy
(
project
)
log_info
(
"Project
\"
#{
project
.
name
}
\"
was removed"
)
GitoliteWorker
.
perform_async
(
:remove_repository
,
self
.
path_with_namespace
)
project
.
satellite
.
destroy
project
.
destroy_repository
end
def
after_create
project
log_info
(
"
#{
project
.
owner
.
name
}
created a new project
\"
#{
project
.
name_with_namespace
}
\"
"
)
log_info
(
"Project
\"
#{
project
.
name
}
\"
was removed"
)
end
protected
...
...
config/initializers/5_backend.rb
View file @
27d9ac0f
# GIT over HTTP
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"grack_auth"
)
# GIT
OLITE backend
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"
gitolite
"
)
# GIT
over SSH
require
Rails
.
root
.
join
(
"lib"
,
"gitlab"
,
"backend"
,
"
shell
"
)
lib/gitlab/backend/
gitolite
.rb
→
lib/gitlab/backend/
shell
.rb
View file @
27d9ac0f
module
Gitlab
class
Gitolite
class
Shell
class
AccessDenied
<
StandardError
;
end
def
config
Gitlab
::
GitoliteConfig
.
new
end
# Add new key to gitlab-shell
#
# Ex.
# add_key("randx", "sha-rsa ...")
# Init new repository
#
def
add_key
(
username
,
key_content
)
# TODO: implement
end
# Remove ssh key from gitlab shell
# name - project path with namespace
#
# Ex.
#
remove_key("sha-rsa
")
#
add_repository("gitlab/gitlab-ci
")
#
def
remove_key
(
key_content
)
# TODO: implement
def
add_repository
(
name
)
system
(
"/home/git/gitlab-shell/bin/gitlab-projects add-project
#{
name
}
.git"
)
end
# Remove repository from file system
...
...
@@ -32,26 +21,30 @@ module Gitlab
# remove_repository("gitlab/gitlab-ci")
#
def
remove_repository
(
name
)
# TODO: implement
system
(
"/home/git/gitlab-shell/bin/gitlab-projects rm-project
#{
name
}
.git"
)
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.
#
add_repository("gitlab/gitlab-ci
")
#
remove_key("sha-rsa
")
#
def
add_repository
(
name
)
# TODO: implement
def
remove_key
(
key_content
)
system
(
"/home/git/gitlab-shell/bin/gitlab-keys rm-key
\"
#{
key_content
}
\"
"
)
end
def
url_to_repo
path
Gitlab
.
config
.
gitolite
.
ssh_path_prefix
+
"
#{
path
}
.git"
end
def
enable_automerge
config
.
admin_all_repo!
end
end
end
lib/gitolited.rb
View file @
27d9ac0f
...
...
@@ -6,6 +6,6 @@
#
module
Gitolited
def
gitolite
Gitlab
::
Gitolite
.
new
Gitlab
::
Shell
.
new
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