Skip to content

Commit

Permalink
Added info box on project page
Browse files Browse the repository at this point in the history
  • Loading branch information
untoldwind committed Apr 22, 2010
1 parent 8ab4afb commit de008bb
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 19 deletions.
8 changes: 8 additions & 0 deletions app/views/projects/.tmp__redmine_gitosis.rhtml.10033~
@@ -0,0 +1,8 @@
<% if @project.repository && @project.repository.is_a?(Repository::Git) %>
<div class="box">
<h3>Git Repository</h3>
<ul>
<li>Developer URL: <%= Setting.plugin_redmine_gitosis['developerBaseUrl'] + @project.identifier %>.git</li>
</ul>
</div>
<% end %>
8 changes: 8 additions & 0 deletions app/views/projects/_redmine_gitosis.rhtml
@@ -0,0 +1,8 @@
<% if @project.repository && @project.repository.is_a?(Repository::Git) %>
<div class="box">
<h3>Git Repository</h3>
<ul>
<li>Developer URL: <%= Setting.plugin_redmine_gitosis['developerBaseUrl'] + @project.identifier %>.git</li>
</ul>
</div>
<% end %>
3 changes: 3 additions & 0 deletions app/views/repositories/.tmp_git_instructions.html.erb.16899~
@@ -0,0 +1,3 @@
<h2><%= l(:label_repository)%></h2>
<%# This can be used to display basic git setup instructions, like on github... %>
<% html_title(l(:label_repository)) -%>
5 changes: 5 additions & 0 deletions app/views/settings/.tmp__redmine_gitosis.rhtml.14123~
@@ -0,0 +1,5 @@
<div class="box tabular settings">
<p>Uri: <%= text_field_tag("settings[uri]", settings['uri'], :size => 60) %><br />
<p>Base path: <%= text_field_tag("settings[basePath]", settings['basePath'], :size => 60) %><br />

</div>
6 changes: 6 additions & 0 deletions app/views/settings/.tmp__redmine_gitosis.rhtml.89749~
@@ -0,0 +1,6 @@
<div class="box tabular settings">
<p><label>Gitosi URL</label> <%= text_field_tag("settings[gitosisUrl]", settings['gitosisUrl'], :size => 60) %><br />
<p><label>Gitosi identity file</label> <%= text_field_tag("settings[gitosisIdentityFile]", settings['gitosisIdentityFile'], :size => 60) %><br />
<p><label>Base path</label> <%= text_field_tag("settings[basePath]", settings['basePath'], :size => 60) %><br />
<p><label>Developer base URL</label> <%= text_field_tag("settings[developerBaseUrl]", settings['developerBaseUrl'], :size => 60) %><br />
</div>
7 changes: 4 additions & 3 deletions app/views/settings/_redmine_gitosis.rhtml
@@ -1,5 +1,6 @@
<div class="box tabular settings">
<p>Uri: <%= text_field_tag("settings[uri]", settings['uri'], :size => 60) %><br />
<p>Base path: <%= text_field_tag("settings[basePath]", settings['basePath'], :size => 60) %><br />

<p><label>Gitosi URL</label> <%= text_field_tag("settings[gitosisUrl]", settings['gitosisUrl'], :size => 60) %><br />
<p><label>Gitosi identity file</label> <%= text_field_tag("settings[gitosisIdentityFile]", settings['gitosisIdentityFile'], :size => 60) %><br />
<p><label>Base path</label> <%= text_field_tag("settings[basePath]", settings['basePath'], :size => 60) %><br />
<p><label>Developer base URL</label> <%= text_field_tag("settings[developerBaseUrl]", settings['developerBaseUrl'], :size => 60) %><br />
</div>
12 changes: 10 additions & 2 deletions init.rb
Expand Up @@ -9,15 +9,23 @@
name 'Redmine Gitosis plugin'
author 'Jan Schulz-Hofen'
description 'Enables Redmine to update a gitosis server.'
version '0.0.1'
settings :default => {'uri' => 'git@localhost:gitosis-admin.git', 'basePath' => '/opt/git/repositories/' }, :partial => 'redmine_gitosis'
version '0.0.2'
settings :default => {
'gitosisUrl' => 'git@localhost:gitosis-admin.git',
'gitosisIdentityFile' => '/opt/redmine/.ssh/id_rsa',
'developerBaseUrl' => 'git@localhost:',
'basePath' => '/opt/git/repositories/' }, :partial => 'redmine_gitosis'
end

# initialize hook
class GitosisPublicKeyHook < Redmine::Hook::ViewListener
render_on :view_my_account_contextual, :inline => "| <%= link_to(l(:label_public_keys), public_keys_path) %>"
end

class GitosisProjectShowHook < Redmine::Hook::ViewListener
render_on :view_projects_show_left, :partial => 'redmine_gitosis'
end

# initialize association from user -> public keys
User.send(:has_many, :gitosis_public_keys, :dependent => :destroy)

Expand Down
27 changes: 14 additions & 13 deletions lib/gitosis.rb
Expand Up @@ -3,17 +3,14 @@
require 'net/ssh'

module Gitosis
# server config
GITOSIS_URI = 'git@localhost:gitosis-admin.git'
GITOSIS_BASE_PATH = '/opt/git/repositories/'

# commands
# ENV['GIT_SSH'] = SSH_WITH_IDENTITY_FILE = File.join(RAILS_ROOT, 'vendor/plugins/redmine_gitosis/extra/ssh_with_identity_file.sh')

def self.destroy_repository(project)
path = File.join(GITOSIS_BASE_PATH, "#{project.identifier}.git")
`rm -Rf #{path}`
end
# def self.destroy_repository(project)
# path = File.join(GITOSIS_BASE_PATH, "#{project.identifier}.git")
# `rm -Rf #{path}`
# end

def self.update_repositories(projects)
projects = (projects.is_a?(Array) ? projects : [projects])
Expand All @@ -27,8 +24,17 @@ def self.update_repositories(projects)

Dir.mkdir local_dir

ssh_with_identity_file = File.join(local_dir, 'ssh_with_identity_file.sh')

File.open(ssh_with_identity_file, "w") do |f|
f.puts "#!/bin/bash"
f.puts "exec ssh -i #{Setting.plugin_redmine_gitosis['gitosisIdentityFile']} \"$@\""
end
File.chmod(0755, ssh_with_identity_file)
ENV['GIT_SSH'] = ssh_with_identity_file

# clone repo
`git clone #{GITOSIS_URI} #{local_dir}/gitosis`
`git clone #{Setting.plugin_redmine_gitosis['gitosisUrl']} #{local_dir}/gitosis`

changed = false

Expand Down Expand Up @@ -60,11 +66,6 @@ def self.update_repositories(projects)
changed = true
end

# path = File.join(GITOSIS_BASE_PATH, "#{project.identifier}.git")
# if !File.exist?(path)
# Dir.mkdir path
# `cd #{path} ; git --bare init ; chmod o-rwx -R .`
# end
end
if changed
# add, commit, push, and remove local tmp dir
Expand Down
2 changes: 1 addition & 1 deletion lib/gitosis/patches/repositories_controller_patch.rb
Expand Up @@ -13,7 +13,7 @@ def show_with_git_instructions

def edit_with_scm_settings
params[:repository] ||= {}
params[:repository][:url] = File.join(Gitosis::GITOSIS_BASE_PATH,"#{@project.identifier}.git") if params[:repository_scm] == 'Git'
params[:repository][:url] = File.join(Setting.plugin_redmine_gitosis['basePath'],"#{@project.identifier}.git") if params[:repository_scm] == 'Git'
edit_without_scm_settings
end

Expand Down

0 comments on commit de008bb

Please sign in to comment.