Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
723104c4
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
723104c4
编写于
12月 29, 2011
作者:
M
miks
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial deploy_key feature commit
上级
53ce00f7
变更
16
显示空白变更内容
内联
并排
Showing
16 changed file
with
222 addition
and
1 deletion
+222
-1
app/controllers/deploy_keys_controller.rb
app/controllers/deploy_keys_controller.rb
+42
-0
app/models/deploy_key.rb
app/models/deploy_key.rb
+49
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/views/deploy_keys/_form.html.haml
app/views/deploy_keys/_form.html.haml
+16
-0
app/views/deploy_keys/_show.html.haml
app/views/deploy_keys/_show.html.haml
+7
-0
app/views/deploy_keys/create.js.haml
app/views/deploy_keys/create.js.haml
+9
-0
app/views/deploy_keys/edit.html.haml
app/views/deploy_keys/edit.html.haml
+7
-0
app/views/deploy_keys/index.html.haml
app/views/deploy_keys/index.html.haml
+16
-0
app/views/deploy_keys/new.html.haml
app/views/deploy_keys/new.html.haml
+5
-0
app/views/deploy_keys/new.js.haml
app/views/deploy_keys/new.js.haml
+11
-0
app/views/deploy_keys/show.html.haml
app/views/deploy_keys/show.html.haml
+10
-0
app/views/layouts/project.html.haml
app/views/layouts/project.html.haml
+1
-0
config/routes.rb
config/routes.rb
+2
-0
db/migrate/20111225202855_create_deploy_keys.rb
db/migrate/20111225202855_create_deploy_keys.rb
+12
-0
lib/gitlabhq/gitolite.rb
lib/gitlabhq/gitolite.rb
+1
-1
spec/models/deploy_key_spec.rb
spec/models/deploy_key_spec.rb
+33
-0
未找到文件。
app/controllers/deploy_keys_controller.rb
0 → 100644
浏览文件 @
723104c4
class
DeployKeysController
<
ApplicationController
respond_to
:js
layout
"project"
before_filter
:project
# before_filter :authorize_admin_project!
# before_filter :require_non_empty_project
def
project
@project
||=
Project
.
find_by_code
(
params
[
:project_id
])
end
def
index
@keys
=
@project
.
deploy_keys
.
all
end
def
show
@key
=
@project
.
deploy_keys
.
find
(
params
[
:id
])
end
def
new
@key
=
@project
.
deploy_keys
.
new
respond_with
(
@key
)
end
def
create
@key
=
@project
.
deploy_keys
.
new
(
params
[
:key
])
@key
.
save
respond_with
(
@key
)
end
def
destroy
@key
=
@project
.
deploy_keys
.
find
(
params
[
:id
])
@key
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
deploy_keys_url
}
format
.
js
{
render
:nothing
=>
true
}
end
end
end
app/models/deploy_key.rb
0 → 100644
浏览文件 @
723104c4
class
DeployKey
<
ActiveRecord
::
Base
belongs_to
:project
validates
:title
,
:presence
=>
true
,
:length
=>
{
:within
=>
0
..
255
}
validates
:key
,
:presence
=>
true
,
:uniqueness
=>
true
,
:length
=>
{
:within
=>
0
..
5000
}
before_save
:set_identifier
after_save
:update_repository
after_destroy
:repository_delete_key
def
set_identifier
self
.
identifier
=
"deploy_
#{
project
.
code
}
_
#{
Time
.
now
.
to_i
}
"
end
def
update_repository
Gitlabhq
::
GitHost
.
system
.
new
.
configure
do
|
c
|
c
.
update_keys
(
identifier
,
key
)
c
.
update_project
(
project
)
end
end
def
repository_delete_key
Gitlabhq
::
GitHost
.
system
.
new
.
configure
do
|
c
|
c
.
delete_key
(
identifier
)
c
.
update_project
(
project
)
end
end
end
# == Schema Information
#
# Table name: keys
#
# id :integer not null, primary key
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# key :text
# title :string(255)
# identifier :string(255)
#
app/models/project.rb
浏览文件 @
723104c4
...
...
@@ -14,6 +14,7 @@ class Project < ActiveRecord::Base
has_many
:users
,
:through
=>
:users_projects
has_many
:notes
,
:dependent
=>
:destroy
has_many
:snippets
,
:dependent
=>
:destroy
has_many
:deploy_keys
,
:dependent
=>
:destroy
acts_as_taggable
...
...
app/views/deploy_keys/_form.html.haml
0 → 100644
浏览文件 @
723104c4
%div
=
form_for
[
@project
,
@key
],
:remote
=>
true
do
|
f
|
-
if
@key
.
errors
.
any?
%ul
-
@key
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.form-row
=
f
.
label
:title
=
f
.
text_field
:title
,
:style
=>
"width:300px"
.form-row
=
f
.
label
:key
=
f
.
text_area
:key
,
:style
=>
"width:300px; height:130px"
.form-row
=
f
.
submit
'Save'
,
:class
=>
"grey-button"
app/views/deploy_keys/_show.html.haml
0 → 100644
浏览文件 @
723104c4
%a
.update-item
{
:href
=>
project_deploy_key_path
(
key
)}
%span
.update-title
=
key
.
title
%span
.update-author
Added
=
time_ago_in_words
(
key
.
created_at
)
ago
app/views/deploy_keys/create.js.haml
0 → 100644
浏览文件 @
723104c4
-
if
@key
.
valid?
:plain
$("#new_key_dialog").dialog("close");
$("#keys-table .data").append("
#{
escape_javascript
(
render
(
:partial
=>
'show'
,
:locals
=>
{
:key
=>
@key
}
))
}
");
$("#no_ssh_key_defined").hide();
-
else
:plain
$("#new_key_dialog").empty();
$("#new_key_dialog").append("
#{
escape_javascript
(
render
(
'form'
))
}
");
app/views/deploy_keys/edit.html.haml
0 → 100644
浏览文件 @
723104c4
%h1
Editing key
=
render
'form'
=
link_to
'Show'
,
@key
\|
=
link_to
'Back'
,
project_deploy_keys_path
app/views/deploy_keys/index.html.haml
0 → 100644
浏览文件 @
723104c4
%h2
.icon
%span
>
SSH Keys
%div
#new-key-holder
.right
=
link_to
"Add new"
,
new_project_deploy_key_path
,
:remote
=>
true
,
:class
=>
"grey-button"
%br
%div
#keys-table
{
:class
=>
"update-data ui-box ui-box-small ui-box-big"
}
.data
-
@keys
.
each
do
|
key
|
=
render
(
:partial
=>
'show'
,
:locals
=>
{
:key
=>
key
})
:javascript
$
(
'
.delete-key
'
).
live
(
'
ajax:success
'
,
function
()
{
$
(
this
).
closest
(
'
.update-item
'
).
fadeOut
();
});
app/views/deploy_keys/new.html.haml
0 → 100644
浏览文件 @
723104c4
%h1
New key
=
render
'form'
=
link_to
'Back'
,
project_deploy_keys_path
app/views/deploy_keys/new.js.haml
0 → 100644
浏览文件 @
723104c4
:plain
var new_key_dialog = $("<div id='new_key_dialog'></div>");
new_key_dialog.html("
#{
escape_javascript
(
render
(
'form'
))
}
");
$(new_key_dialog).dialog({
width: 350,
resizable: false,
draggable: false,
title: "Add new public key",
close: function(event, ui) { $("#new_key_dialog").remove();},
modal: true
});
app/views/deploy_keys/show.html.haml
0 → 100644
浏览文件 @
723104c4
.ui-box.width-100p
%h3
=
@key
.
title
.data
%pre
=
@key
.
key
.clear
.buttons
=
link_to
'Remove'
,
@key
,
:confirm
=>
'Are you sure?'
,
:method
=>
:delete
,
:class
=>
"red-button delete-key right"
.clear
app/views/layouts/project.html.haml
浏览文件 @
723104c4
...
...
@@ -49,6 +49,7 @@
-
if
can?
current_user
,
:admin_project
,
@project
=
link_to
"Admin"
,
edit_project_path
(
@project
),
:class
=>
(
current_page?
(
edit_project_path
(
@project
)))
?
"current"
:
nil
=
link_to
"Deploy keys"
,
project_deploy_keys_path
(
@project
),
:class
=>
(
current_page?
(
project_deploy_keys_path
(
@project
)))
?
"current"
:
nil
.medium-tags
{
:style
=>
'padding: 10px 0 0 10px; width: 210px;'
}=
tag_list
@project
...
...
config/routes.rb
浏览文件 @
723104c4
...
...
@@ -41,6 +41,8 @@ Gitlab::Application.routes.draw do
get
"graph"
end
resources
:deploy_keys
resources
:refs
,
:only
=>
[],
:path
=>
"/"
do
collection
do
get
"switch"
...
...
db/migrate/20111225202855_create_deploy_keys.rb
0 → 100644
浏览文件 @
723104c4
class
CreateDeployKeys
<
ActiveRecord
::
Migration
def
change
create_table
:deploy_keys
do
|
t
|
t
.
integer
"project_id"
,
:null
=>
false
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
text
"key"
t
.
string
"title"
t
.
string
"identifier"
end
end
end
lib/gitlabhq/gitolite.rb
浏览文件 @
723104c4
...
...
@@ -71,7 +71,7 @@ module Gitlabhq
::
Gitolite
::
Config
::
Repo
.
new
(
repo_name
)
end
name_readers
=
project
.
repository_readers
name_readers
=
project
.
repository_readers
+
project
.
deploy_keys
name_writers
=
project
.
repository_writers
repo
.
clean_permissions
...
...
spec/models/deploy_key_spec.rb
0 → 100644
浏览文件 @
723104c4
require
'spec_helper'
describe
DeployKey
do
describe
"Associations"
do
it
{
should
belong_to
(
:project
)
}
end
describe
"Validation"
do
it
{
should
validate_presence_of
(
:title
)
}
it
{
should
validate_presence_of
(
:key
)
}
end
describe
"Methods"
do
it
{
should
respond_to
:projects
}
end
it
{
Factory
.
create
(
:key
,
:project
=>
Factory
(
:project
)).
should
be_valid
}
end
# == Schema Information
#
# Table name: deploy_keys
#
# id :integer not null, primary key
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# key :text
# title :string(255)
# identifier :string(255)
#
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录