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
iv
gitlab-ce
Commits
723104c4
Commit
723104c4
authored
Dec 29, 2011
by
miks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial deploy_key feature commit
parent
53ce00f7
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
222 additions
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
No files found.
app/controllers/deploy_keys_controller.rb
0 → 100644
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
723104c4
%h1
New key
=
render
'form'
=
link_to
'Back'
,
project_deploy_keys_path
app/views/deploy_keys/new.js.haml
0 → 100644
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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
View file @
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)
#
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