mirror of
https://github.com/redmine/redmine.git
synced 2026-03-03 19:11:28 +01:00
scm browser commit before merge
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@104 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1,39 +1,42 @@
|
||||
class RepositoriesController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project
|
||||
before_filter :find_project, :authorize
|
||||
|
||||
def show
|
||||
@entries = @repository.scm.entries('')
|
||||
show_error and return unless @entries
|
||||
@latest_revision = @entries.revisions.latest
|
||||
end
|
||||
|
||||
def browse
|
||||
@entries = @repository.scm.entries(@path, @rev)
|
||||
redirect_to :action => 'show', :id => @project and return unless @entries
|
||||
show_error and return unless @entries
|
||||
end
|
||||
|
||||
def entry_revisions
|
||||
def revisions
|
||||
@entry = @repository.scm.entry(@path, @rev)
|
||||
@revisions = @repository.scm.revisions(@path, @rev)
|
||||
redirect_to :action => 'show', :id => @project and return unless @entry && @revisions
|
||||
show_error and return unless @entry && @revisions
|
||||
end
|
||||
|
||||
def entry
|
||||
if 'raw' == params[:format]
|
||||
content = @repository.scm.cat(@path, @rev)
|
||||
redirect_to :action => 'show', :id => @project and return unless content
|
||||
show_error and return unless content
|
||||
send_data content, :filename => @path.split('/').last
|
||||
end
|
||||
end
|
||||
|
||||
def revision
|
||||
@revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true
|
||||
redirect_to :action => 'show', :id => @project and return unless @revisions
|
||||
show_error and return unless @revisions
|
||||
@revision = @revisions.first
|
||||
end
|
||||
|
||||
def diff
|
||||
@rev_to = params[:rev_to] || (@rev-1)
|
||||
@diff = @repository.scm.diff(params[:path], @rev, @rev_to)
|
||||
redirect_to :action => 'show', :id => @project and return unless @diff
|
||||
show_error and return unless @diff
|
||||
end
|
||||
|
||||
private
|
||||
@@ -44,4 +47,9 @@ private
|
||||
@path ||= ''
|
||||
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
|
||||
end
|
||||
|
||||
def show_error
|
||||
flash.now[:notice] = l(:notice_scm_error)
|
||||
render :nothing => true, :layout => true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,6 +30,7 @@ class Permission < ActiveRecord::Base
|
||||
1100 => :label_news_plural,
|
||||
1200 => :label_document_plural,
|
||||
1300 => :label_attachment_plural,
|
||||
1400 => :label_repository
|
||||
}.freeze
|
||||
|
||||
@@cached_perms_for_public = nil
|
||||
|
||||
@@ -58,7 +58,7 @@ module SvnRepos
|
||||
path ||= ''
|
||||
identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
|
||||
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
|
||||
revisions = []
|
||||
revisions = Revisions.new
|
||||
cmd = "svn log --xml -r #{identifier_from}:#{identifier_to} "
|
||||
cmd << "--verbose " if options[:with_paths]
|
||||
cmd << target(path)
|
||||
@@ -128,7 +128,7 @@ module SvnRepos
|
||||
|
||||
private
|
||||
def target(path)
|
||||
" \"" << "#{@url}/#{path}".gsub(/["'<>]/, '') << "\""
|
||||
" \"" << "#{@url}/#{path}".gsub(/["'?<>\*]/, '') << "\""
|
||||
end
|
||||
|
||||
def logger
|
||||
@@ -153,6 +153,10 @@ module SvnRepos
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def revisions
|
||||
revisions ||= Revisions.new(collect{|entry| entry.lastrev})
|
||||
end
|
||||
end
|
||||
|
||||
class Entry
|
||||
@@ -174,6 +178,12 @@ module SvnRepos
|
||||
end
|
||||
end
|
||||
|
||||
class Revisions < Array
|
||||
def latest
|
||||
sort {|x,y| x.time <=> y.time}.last
|
||||
end
|
||||
end
|
||||
|
||||
class Revision
|
||||
attr_accessor :identifier, :author, :time, :message, :paths
|
||||
def initialize(attributes={})
|
||||
|
||||
@@ -30,9 +30,7 @@
|
||||
<%= hidden_field_tag "repository_enabled", 0 %>
|
||||
<div id="repository">
|
||||
<% fields_for :repository, @project.repository, { :builder => TabularFormBuilder, :lang => current_language} do |repository| %>
|
||||
<p><%= repository.text_field :url, :size => 60, :required => true %></p>
|
||||
<p><%= repository.text_field :login %></p>
|
||||
<p><%= repository.password_field :password %></p>
|
||||
<p><%= repository.text_field :url, :size => 60, :required => true %><br />(http://, https://, svn://)</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %>
|
||||
|
||||
23
scm/app/views/repositories/_dir_list.rhtml
Normal file
23
scm/app/views/repositories/_dir_list.rhtml
Normal file
@@ -0,0 +1,23 @@
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th><%= l(:field_filesize) %></th>
|
||||
<th><%= l(:label_revision) %></th>
|
||||
<th><%= l(:field_author) %></th>
|
||||
<th><%= l(:label_date) %></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% total_size = 0
|
||||
@entries.each do |entry| %>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td><%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => "icon " + (entry.is_dir? ? 'folder' : 'file') %></td>
|
||||
<td align="right"><%= human_size(entry.size) unless entry.is_dir? %></td>
|
||||
<td align="right"><%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %></td>
|
||||
<td align="center"><em><%=h entry.lastrev.author %></em></td>
|
||||
<td align="center"><%= format_time(entry.lastrev.time) %></td>
|
||||
</tr>
|
||||
<% total_size += entry.size
|
||||
end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<p align="right"><em><%= l(:label_total) %>: <%= human_size(total_size) %></em></p>
|
||||
@@ -12,7 +12,7 @@ dirs.each do |dir|
|
||||
/ <%= link_to h(dir), :action => 'browse', :id => @project, :path => link_path, :rev => @rev %>
|
||||
<% end %>
|
||||
<% if filename %>
|
||||
/ <%= link_to h(filename), :action => 'entry_revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %>
|
||||
/ <%= link_to h(filename), :action => 'revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %>
|
||||
<% end %>
|
||||
|
||||
<%= "@ #{revision}" if revision %>
|
||||
@@ -8,26 +8,4 @@
|
||||
|
||||
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2>
|
||||
|
||||
<table class="list">
|
||||
<thead><tr>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th><%= l(:field_filesize) %></th>
|
||||
<th><%= l(:label_revision) %></th>
|
||||
<th><%= l(:field_author) %></th>
|
||||
<th><%= l(:label_date) %></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% total_size = 0
|
||||
@entries.each do |entry| %>
|
||||
<tr class="<%= cycle 'odd', 'even' %>">
|
||||
<td><%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'entry_revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => "icon " + (entry.is_dir? ? 'folder' : 'file') %></td>
|
||||
<td align="right"><%= human_size(entry.size) unless entry.is_dir? %></td>
|
||||
<td align="right"><%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %></td>
|
||||
<td align="center"><em><%=h entry.lastrev.author %></em></td>
|
||||
<td align="center"><%= format_time(entry.lastrev.time) %></td>
|
||||
</tr>
|
||||
<% total_size += entry.size
|
||||
end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<p align="right"><em><%= l(:label_total) %>: <%= human_size(total_size) %></em></p>
|
||||
<%= render :partial => 'dir_list' %>
|
||||
@@ -8,8 +8,10 @@
|
||||
|
||||
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => @entry.kind, :revision => @rev } %></h2>
|
||||
|
||||
<% if @entry.is_file? %>
|
||||
<h3><%=h @entry.name %></h3>
|
||||
<p><%= link_to 'Download', {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }, :class => "icon file" %> (<%= human_size @entry.size %>)</p>
|
||||
<% end %>
|
||||
|
||||
<h3>Revisions</h3>
|
||||
|
||||
@@ -28,7 +30,7 @@
|
||||
<td align="center"><em><%=h revision.author %></em></td>
|
||||
<td align="center"><%= format_time(revision.time) %></td>
|
||||
<td width="70%"><%= simple_format(h(revision.message)) %></td>
|
||||
<td align="center"><%= link_to 'Diff', :action => 'diff', :id => @project, :path => @path, :rev => revision.identifier unless revision == @revisions.last %></td>
|
||||
<td align="center"><%= link_to 'Diff', :action => 'diff', :id => @project, :path => @path, :rev => revision.identifier if @entry.is_file? && revision != @revisions.last %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
@@ -1,3 +1,15 @@
|
||||
<%= stylesheet_link_tag "scm" %>
|
||||
|
||||
<h2><%= l(:label_repository) %></h2>
|
||||
|
||||
<%= link_to l(:label_browse), :action => 'browse', :id => @project %>
|
||||
<h3><%= l(:label_revision_plural) %></h3>
|
||||
<% if @latest_revision %>
|
||||
<p><%= l(:label_latest_revision) %>:
|
||||
<%= link_to @latest_revision.identifier, :action => 'revision', :id => @project, :rev => @latest_revision.identifier %><br />
|
||||
<em><%= @latest_revision.author %>, <%= format_time(@latest_revision.time) %></em></p>
|
||||
<% end %>
|
||||
<p><%= link_to l(:label_view_revisions), :action => 'revisions', :id => @project %></p>
|
||||
|
||||
|
||||
<h3><%= l(:label_browse) %></h3>
|
||||
<%= render :partial => 'dir_list' %>
|
||||
12
scm/db/migrate/015_create_repositories.rb
Normal file
12
scm/db/migrate/015_create_repositories.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateRepositories < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :repositories, :force => true do |t|
|
||||
t.column "project_id", :integer, :default => 0, :null => false
|
||||
t.column "url", :string, :default => "", :null => false
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :repositories
|
||||
end
|
||||
end
|
||||
19
scm/db/migrate/016_add_repositories_permissions.rb
Normal file
19
scm/db/migrate/016_add_repositories_permissions.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class AddRepositoriesPermissions < ActiveRecord::Migration
|
||||
def self.up
|
||||
Permission.create :controller => "repositories", :action => "show", :description => "button_view", :sort => 1450, :is_public => true
|
||||
Permission.create :controller => "repositories", :action => "browse", :description => "label_browse", :sort => 1460, :is_public => true
|
||||
Permission.create :controller => "repositories", :action => "entry", :description => "entry", :sort => 1462, :is_public => true
|
||||
Permission.create :controller => "repositories", :action => "revisions", :description => "label_view_revisions", :sort => 1470, :is_public => true
|
||||
Permission.create :controller => "repositories", :action => "revision", :description => "label_view_revisions", :sort => 1472, :is_public => true
|
||||
Permission.create :controller => "repositories", :action => "diff", :description => "diff", :sort => 1480, :is_public => true
|
||||
end
|
||||
|
||||
def self.down
|
||||
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'show']).destroy
|
||||
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'browse']).destroy
|
||||
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'entry']).destroy
|
||||
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revisions']).destroy
|
||||
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revision']).destroy
|
||||
Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'diff']).destroy
|
||||
end
|
||||
end
|
||||
@@ -63,6 +63,7 @@ notice_successful_delete: Erfolgreiche Auslassung.
|
||||
notice_successful_connection: Erfolgreicher Anschluß.
|
||||
notice_file_not_found: Erbetene Akte besteht nicht oder ist gelöscht worden.
|
||||
notice_locking_conflict: Data have been updated by another user.
|
||||
notice_scm_error: Eintragung und/oder Neuausgabe besteht nicht im Behälter.
|
||||
|
||||
mail_subject_lost_password: Dein redMine Kennwort
|
||||
mail_subject_register: redMine Kontoaktivierung
|
||||
@@ -284,6 +285,16 @@ label_contains: enthält
|
||||
label_not_contains: enthält nicht
|
||||
label_day_plural: Tage
|
||||
label_repository: SVN Behälter
|
||||
label_browse: Grasen
|
||||
label_modification: %d änderung
|
||||
label_modification_plural: %d änderungen
|
||||
label_revision: Neuausgabe
|
||||
label_revision_plural: Neuausgaben
|
||||
label_added: hinzugefügt
|
||||
label_modified: geändert
|
||||
label_deleted: gelöscht
|
||||
label_latest_revision: Neueste Neuausgabe
|
||||
label_view_revisions: Die Neuausgaben ansehen
|
||||
|
||||
button_login: Einloggen
|
||||
button_submit: Einreichen
|
||||
|
||||
@@ -63,6 +63,7 @@ notice_successful_delete: Successful deletion.
|
||||
notice_successful_connection: Successful connection.
|
||||
notice_file_not_found: Requested file doesn't exist or has been deleted.
|
||||
notice_locking_conflict: Data have been updated by another user.
|
||||
notice_scm_error: Entry and/or revision doesn't exist in the repository.
|
||||
|
||||
mail_subject_lost_password: Your redMine password
|
||||
mail_subject_register: redMine account activation
|
||||
@@ -284,6 +285,16 @@ label_contains: contains
|
||||
label_not_contains: doesn't contain
|
||||
label_day_plural: days
|
||||
label_repository: SVN Repository
|
||||
label_browse: Browse
|
||||
label_modification: %d change
|
||||
label_modification_plural: %d changes
|
||||
label_revision: Revision
|
||||
label_revision_plural: Revisions
|
||||
label_added: added
|
||||
label_modified: modified
|
||||
label_deleted: deleted
|
||||
label_latest_revision: Latest revision
|
||||
label_view_revisions: View revisions
|
||||
|
||||
button_login: Login
|
||||
button_submit: Submit
|
||||
|
||||
@@ -63,6 +63,7 @@ notice_successful_delete: Successful deletion.
|
||||
notice_successful_connection: Successful connection.
|
||||
notice_file_not_found: Requested file doesn't exist or has been deleted.
|
||||
notice_locking_conflict: Data have been updated by another user.
|
||||
notice_scm_error: La entrada y/o la revisión no existe en el depósito.
|
||||
|
||||
mail_subject_lost_password: Tu contraseña del redMine
|
||||
mail_subject_register: Activación de la cuenta del redMine
|
||||
@@ -284,6 +285,16 @@ label_contains: contiene
|
||||
label_not_contains: no contiene
|
||||
label_day_plural: días
|
||||
label_repository: Depósito SVN
|
||||
label_browse: Hojear
|
||||
label_modification: %d modificación
|
||||
label_modification_plural: %d modificaciones
|
||||
label_revision: Revisión
|
||||
label_revision_plural: Revisiones
|
||||
label_added: agregado
|
||||
label_modified: modificado
|
||||
label_deleted: suprimido
|
||||
label_latest_revision: La revisión más última
|
||||
label_view_revisions: Ver las revisiones
|
||||
|
||||
button_login: Conexión
|
||||
button_submit: Someter
|
||||
|
||||
@@ -63,6 +63,7 @@ notice_successful_delete: Suppression effectuée avec succès.
|
||||
notice_successful_connection: Connection réussie.
|
||||
notice_file_not_found: Le fichier demandé n'existe pas ou a été supprimé.
|
||||
notice_locking_conflict: Les données ont été mises à jour par un autre utilisateur. Mise à jour impossible.
|
||||
notice_scm_error: L'entrée et/ou la révision demandée n'existe pas dans le dépôt.
|
||||
|
||||
mail_subject_lost_password: Votre mot de passe redMine
|
||||
mail_subject_register: Activation de votre compte redMine
|
||||
@@ -289,9 +290,12 @@ label_browse: Parcourir
|
||||
label_modification: %d modification
|
||||
label_modification_plural: %d modifications
|
||||
label_revision: Révision
|
||||
label_revision_plural: Révisions
|
||||
label_added: ajouté
|
||||
label_modified: modifié
|
||||
label_deleted: supprimé
|
||||
label_latest_revision: Dernière révision
|
||||
label_view_revisions: Voir les révisions
|
||||
|
||||
button_login: Connexion
|
||||
button_submit: Soumettre
|
||||
|
||||
Reference in New Issue
Block a user