Feature #1406 » branch_support.diff
| app/controllers/repositories_controller.rb | ||
|---|---|---|
|
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository'
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
# check if new revisions have been committed in the repository
|
||
|
@repository.fetch_changesets if Setting.autofetch_changesets?
|
||
|
# root entries
|
||
|
@entries = @repository.entries('', @rev)
|
||
|
# latest changesets
|
||
|
@changesets = @repository.changesets.find(:all, :limit => 10, :order => "committed_on DESC")
|
||
|
show_error_not_found unless @entries || @changesets.any?
|
||
|
end
|
||
|
|
||
|
def browse
|
||
|
def show
|
||
|
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
|
||
|
@entries = @repository.entries(@path, @rev)
|
||
|
if request.xhr?
|
||
|
@entries ? render(:partial => 'dir_list_content') : render(:nothing => true)
|
||
|
else
|
||
|
show_error_not_found and return unless @entries
|
||
|
@changesets = @repository.latest_changesets(@path, @rev)
|
||
|
@properties = @repository.properties(@path, @rev)
|
||
|
render :action => 'browse'
|
||
|
render :action => 'show'
|
||
|
end
|
||
|
end
|
||
|
alias_method :browse, :show
|
||
|
|
||
|
def changes
|
||
|
@entry = @repository.entry(@path, @rev)
|
||
|
show_error_not_found and return unless @entry
|
||
|
@changesets = @repository.changesets_for_path(@path, :limit => Setting.repository_log_display_limit.to_i)
|
||
|
@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i)
|
||
|
@properties = @repository.properties(@path, @rev)
|
||
|
end
|
||
|
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
def revision
|
||
|
@changeset = @repository.changesets.find_by_revision(@rev)
|
||
|
@changeset = @repository.changesets.find(:first, :conditions => ["revision LIKE ?", @rev + '%'])
|
||
|
raise ChangesetNotFound unless @changeset
|
||
|
respond_to do |format|
|
||
| ... | ... | |
|
render_404
|
||
|
end
|
||
|
|
||
|
REV_PARAM_RE = %r{^[a-f0-9]*$}
|
||
|
|
||
|
def find_repository
|
||
|
@project = Project.find(params[:id])
|
||
|
@repository = @project.repository
|
||
|
render_404 and return false unless @repository
|
||
|
@path = params[:path].join('/') unless params[:path].nil?
|
||
|
@path ||= ''
|
||
|
@rev = params[:rev]
|
||
|
@rev = params[:rev].nil? || params[:rev].empty? ? @repository.default_branch : params[:rev].strip
|
||
|
@rev_to = params[:rev_to]
|
||
|
raise InvalidRevisionParam unless @rev.to_s.match(REV_PARAM_RE) && @rev.to_s.match(REV_PARAM_RE)
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
rescue InvalidRevisionParam
|
||
| app/models/repository.rb | ||
|---|---|---|
|
def entries(path=nil, identifier=nil)
|
||
|
scm.entries(path, identifier)
|
||
|
end
|
||
|
def branches
|
||
|
scm.branches
|
||
|
end
|
||
|
def tags
|
||
|
scm.tags
|
||
|
end
|
||
|
def default_branch
|
||
|
scm.default_branch
|
||
|
end
|
||
|
|
||
|
def properties(path, identifier=nil)
|
||
|
scm.properties(path, identifier)
|
||
| ... | ... | |
|
def latest_changeset
|
||
|
@latest_changeset ||= changesets.find(:first)
|
||
|
end
|
||
|
def latest_changesets(path,rev,limit=10)
|
||
|
@latest_changesets ||= changesets.find(:all, limit, :order => "committed_on DESC")
|
||
|
end
|
||
|
|
||
|
def scan_changesets_for_issue_ids
|
||
|
self.changesets.each(&:scan_comment_for_issue_ids)
|
||
|
end
|
||
|
|
||
|
# Returns an array of committers usernames and associated user_id
|
||
|
def committers
|
||
|
@committers ||= Changeset.connection.select_rows("SELECT DISTINCT committer, user_id FROM #{Changeset.table_name} WHERE repository_id = #{id}")
|
||
| app/models/repository/git.rb | ||
|---|---|---|
|
'Git'
|
||
|
end
|
||
|
def branches
|
||
|
scm.branches
|
||
|
end
|
||
|
def tags
|
||
|
scm.tags
|
||
|
end
|
||
|
def changesets_for_path(path, options={})
|
||
|
Change.find(:all, :include => {:changeset => :user},
|
||
|
:conditions => ["repository_id = ? AND path = ?", id, path],
|
||
|
:order => "committed_on DESC, #{Changeset.table_name}.revision DESC",
|
||
|
:limit => options[:limit]).collect(&:changeset)
|
||
|
Change.find(
|
||
|
:all,
|
||
|
:include => {:changeset => :user},
|
||
|
:conditions => ["repository_id = ? AND path = ?", id, path],
|
||
|
:order => "committed_on DESC, #{Changeset.table_name}.revision DESC",
|
||
|
:limit => options[:limit]
|
||
|
).collect(&:changeset)
|
||
|
end
|
||
|
# With SCM's that have a sequential commit numbering, redmine is able to be
|
||
|
# clever and only fetch changesets going forward from the most recent one
|
||
|
# it knows about. However, with git, you never know if people have merged
|
||
|
# commits into the middle of the repository history, so we always have to
|
||
|
# parse the entire log.
|
||
|
def fetch_changesets
|
||
|
scm_info = scm.info
|
||
|
if scm_info
|
||
|
# latest revision found in database
|
||
|
db_revision = latest_changeset ? latest_changeset.revision : nil
|
||
|
# latest revision in the repository
|
||
|
scm_revision = scm_info.lastrev.scmid
|
||
|
# Check if there are changes
|
||
|
return if scm.num_revisions == changesets.count
|
||
|
# Get all revisions by running 'git log --all'
|
||
|
revisions = scm.revisions('', nil, nil, :all => true)
|
||
|
# Find revisions that redmine knows about already
|
||
|
existing_revisions = changesets.find(:all).map!{|c| c.scmid}
|
||
|
# Clean out revisions that are no longer in git
|
||
|
Changeset.delete_all(["scmid NOT IN (?) AND repository_id = (?)", revisions.map{|r| r.scmid}, self.id])
|
||
|
# Ignore them
|
||
|
revisions.reject!{|r| existing_revisions.include?(r.scmid)}
|
||
|
# Save the remaining ones to the database
|
||
|
revisions.each{|r| r.save(self)} unless revisions.nil?
|
||
|
end
|
||
|
unless changesets.find_by_scmid(scm_revision)
|
||
|
scm.revisions('', db_revision, nil, :reverse => true) do |revision|
|
||
|
if changesets.find_by_scmid(revision.scmid.to_s).nil?
|
||
|
transaction do
|
||
|
changeset = Changeset.create!(:repository => self,
|
||
|
:revision => revision.identifier,
|
||
|
:scmid => revision.scmid,
|
||
|
:committer => revision.author,
|
||
|
:committed_on => revision.time,
|
||
|
:comments => revision.message)
|
||
|
|
||
|
revision.paths.each do |change|
|
||
|
Change.create!(:changeset => changeset,
|
||
|
:action => change[:action],
|
||
|
:path => change[:path],
|
||
|
:from_path => change[:from_path],
|
||
|
:from_revision => change[:from_revision])
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
def latest_changesets(path,rev,limit=10)
|
||
|
changesets.find(
|
||
|
:all,
|
||
|
:conditions => [
|
||
|
"scmid IN (?)",
|
||
|
scm.revisions(path, nil, rev, :limit => limit, :all => false).map!{|c| c.scmid}
|
||
|
],
|
||
|
:order => 'committed_on DESC'
|
||
|
)
|
||
|
end
|
||
|
end
|
||
| app/views/repositories/_breadcrumbs.rhtml | ||
|---|---|---|
|
<%= link_to 'root', :action => 'show', :id => @project, :path => '', :rev => @rev %>
|
||
|
<%
|
||
|
dirs = path.split('/')
|
||
|
if 'file' == kind
|
||
|
filename = dirs.pop
|
||
|
end
|
||
|
link_path = ''
|
||
|
dirs.each do |dir|
|
||
|
next if dir.blank?
|
||
|
link_path << '/' unless link_path.empty?
|
||
|
link_path << "#{dir}"
|
||
|
%>
|
||
|
/ <%= link_to h(dir), :action => 'show', :id => @project, :path => to_path_param(link_path), :rev => @rev %>
|
||
|
<% end %>
|
||
|
<% if filename %>
|
||
|
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %>
|
||
|
<% end %>
|
||
|
<%= "@ #{revision}" if revision %>
|
||
|
<% html_title(with_leading_slash(path)) -%>
|
||
| app/views/repositories/_dir_list_content.rhtml | ||
|---|---|---|
|
<tr id="<%= tr_id %>" class="<%= params[:parent_id] %> entry <%= entry.kind %>">
|
||
|
<td style="padding-left: <%=18 * depth%>px;" class="filename">
|
||
|
<% if entry.is_dir? %>
|
||
|
<span class="expander" onclick="<%= remote_function :url => {:action => 'browse', :id => @project, :path => to_path_param(entry.path), :rev => @rev, :depth => (depth + 1), :parent_id => tr_id},
|
||
|
<span class="expander" onclick="<%= remote_function :url => {:action => 'show', :id => @project, :path => to_path_param(entry.path), :rev => @rev, :depth => (depth + 1), :parent_id => tr_id},
|
||
|
:method => :get,
|
||
|
:update => { :success => tr_id },
|
||
|
:position => :after,
|
||
| ... | ... | |
|
:condition => "scmEntryClick('#{tr_id}')"%>"> </span>
|
||
|
<% end %>
|
||
|
<%= link_to h(entry.name),
|
||
|
{:action => (entry.is_dir? ? 'browse' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
|
||
|
{:action => (entry.is_dir? ? 'show' : 'changes'), :id => @project, :path => to_path_param(entry.path), :rev => @rev},
|
||
|
:class => (entry.is_dir? ? 'icon icon-folder' : "icon icon-file #{Redmine::MimeType.css_class_of(entry.name)}")%>
|
||
|
</td>
|
||
|
<td class="size"><%= (entry.size ? number_to_human_size(entry.size) : "?") unless entry.is_dir? %></td>
|
||
| app/views/repositories/_navigation.rhtml | ||
|---|---|---|
|
<%= link_to 'root', :action => 'browse', :id => @project, :path => '', :rev => @rev %>
|
||
|
<%
|
||
|
dirs = path.split('/')
|
||
|
if 'file' == kind
|
||
|
filename = dirs.pop
|
||
|
end
|
||
|
link_path = ''
|
||
|
dirs.each do |dir|
|
||
|
next if dir.blank?
|
||
|
link_path << '/' unless link_path.empty?
|
||
|
link_path << "#{dir}"
|
||
|
%>
|
||
|
/ <%= link_to h(dir), :action => 'browse', :id => @project, :path => to_path_param(link_path), :rev => @rev %>
|
||
|
<% end %>
|
||
|
<% if filename %>
|
||
|
/ <%= link_to h(filename), :action => 'changes', :id => @project, :path => to_path_param("#{link_path}/#{filename}"), :rev => @rev %>
|
||
|
<% end %>
|
||
|
<%= link_to l(:label_statistics), {:action => 'stats', :id => @project}, :class => 'icon icon-stats' %>
|
||
|
<%= "@ #{revision}" if revision %>
|
||
|
<% form_tag({:action => controller.action_name, :id => @project, :path => @path, :rev => ''}, {:method => :get, :id => 'revision_selector'}) do -%>
|
||
|
<!-- Branches Dropdown -->
|
||
|
<% if !@repository.branches.nil? && @repository.branches.length > 0 -%>
|
||
|
|
|
||
|
<% content_for :header_tags do %>
|
||
|
<%= javascript_include_tag 'repository_navigation' %>
|
||
|
<% end %>
|
||
|
<% html_title(with_leading_slash(path)) -%>
|
||
|
<%= l(:label_branch) %>:
|
||
|
<%= select_tag :branch, options_for_select([''] + @repository.branches,@rev), :id => 'branch' %>
|
||
|
<% end -%>
|
||
|
<% if !@repository.tags.nil? && @repository.tags.length > 0 -%>
|
||
|
|
|
||
|
<% content_for :header_tags do %>
|
||
|
<%= javascript_include_tag 'repository_navigation' %>
|
||
|
<% end %>
|
||
|
<%= l(:label_tag) %>:
|
||
|
<%= select_tag :tag, options_for_select([''] + @repository.tags,@rev), :id => 'tag' %>
|
||
|
<% end -%>
|
||
|
| <%= l(:label_revision) %>:
|
||
|
<%= text_field_tag 'rev', @rev, :size => 8 %>
|
||
|
<% end -%>
|
||
| app/views/repositories/annotate.rhtml | ||
|---|---|---|
|
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>
|
||
|
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
|
||
|
<div class="contextual">
|
||
|
<%= render :partial => 'navigation' %>
|
||
|
</div>
|
||
|
<h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>
|
||
|
<p><%= render :partial => 'link_to_functions' %></p>
|
||
| app/views/repositories/browse.rhtml | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<% form_tag({}, :method => :get) do %>
|
||
|
<%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %>
|
||
|
<% end %>
|
||
|
<%= render :partial => 'navigation' %>
|
||
|
</div>
|
||
|
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2>
|
||
|
<h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2>
|
||
|
<%= render :partial => 'dir_list' %>
|
||
|
<%= render_properties(@properties) %>
|
||
| app/views/repositories/changes.rhtml | ||
|---|---|---|
|
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => (@entry ? @entry.kind : nil), :revision => @rev } %></h2>
|
||
|
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
|
||
|
<div class="contextual">
|
||
|
<%= render :partial => 'navigation' %>
|
||
|
</div>
|
||
|
<h2>
|
||
|
<%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => (@entry ? @entry.kind : nil), :revision => @rev } %>
|
||
|
</h2>
|
||
|
<p><%= render :partial => 'link_to_functions' %></p>
|
||
| app/views/repositories/entry.rhtml | ||
|---|---|---|
|
<h2><%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>
|
||
|
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
|
||
|
<div class="contextual">
|
||
|
<%= render :partial => 'navigation' %>
|
||
|
</div>
|
||
|
<h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'file', :revision => @rev } %></h2>
|
||
|
<p><%= render :partial => 'link_to_functions' %></p>
|
||
| app/views/repositories/revision.rhtml | ||
|---|---|---|
|
»
|
||
|
<% form_tag({:controller => 'repositories', :action => 'revision', :id => @project, :rev => nil}, :method => :get) do %>
|
||
|
<%= text_field_tag 'rev', @rev, :size => 5 %>
|
||
|
<%= text_field_tag 'rev', @rev[0,8], :size => 8 %>
|
||
|
<%= submit_tag 'OK', :name => nil %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/repositories/revisions.rhtml | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<% form_tag({:action => 'revision', :id => @project}) do %>
|
||
|
<%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %>
|
||
|
<%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 8 %>
|
||
|
<%= submit_tag 'OK' %>
|
||
|
<% end %>
|
||
|
</div>
|
||
| app/views/repositories/show.rhtml | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
|
||
|
<%= link_to l(:label_statistics), {:action => 'stats', :id => @project}, :class => 'icon icon-stats' %>
|
||
|
<% if !@entries.nil? && authorize_for('repositories', 'browse') -%>
|
||
|
<% form_tag({:action => 'browse', :id => @project}, :method => :get) do -%>
|
||
|
| <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %>
|
||
|
<% end -%>
|
||
|
<% end -%>
|
||
|
<div class="contextual">
|
||
|
<%= render :partial => 'navigation' %>
|
||
|
</div>
|
||
|
<h2><%= l(:label_repository) %> (<%= @repository.scm_name %>)</h2>
|
||
|
<h2><%= render :partial => 'breadcrumbs', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2>
|
||
|
<% if !@entries.nil? && authorize_for('repositories', 'browse') %>
|
||
|
<%= render :partial => 'dir_list' %>
|
||
| ... | ... | |
|
<% if !@changesets.empty? && authorize_for('repositories', 'revisions') %>
|
||
|
<h3><%= l(:label_latest_revision_plural) %></h3>
|
||
|
<%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%>
|
||
|
<p><%= link_to l(:label_view_revisions), :action => 'revisions', :id => @project %></p>
|
||
|
<p><%= link_to l(:label_view_all_revisions), :action => 'revisions', :id => @project %></p>
|
||
|
<% content_for :header_tags do %>
|
||
|
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :action => 'revisions', :id => @project, :page => nil, :key => User.current.rss_key})) %>
|
||
|
<% end %>
|
||
| config/locales/bg.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/bs.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/ca.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/cs.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/da.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/de.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: "Die Wiki-Seite '{{page}}' wurde von {{author}} aktualisiert."
|
||
|
permission_add_project: Erstelle Projekt
|
||
|
setting_new_project_user_role_id: Rolle einem Nicht-Administrator zugeordnet, welcher ein Projekt erstellt
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_browse: Browse
|
||
|
label_modification: "{{count}} change"
|
||
|
label_modification_plural: "{{count}} changes"
|
||
|
label_branch: Branch
|
||
|
label_tag: Tag
|
||
|
label_revision: Revision
|
||
|
label_revision_plural: Revisions
|
||
|
label_associated_revisions: Associated revisions
|
||
| ... | ... | |
|
label_latest_revision: Latest revision
|
||
|
label_latest_revision_plural: Latest revisions
|
||
|
label_view_revisions: View revisions
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_max_size: Maximum size
|
||
|
label_sort_highest: Move to top
|
||
|
label_sort_higher: Move up
|
||
| config/locales/es.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/fi.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/fr.yml | ||
|---|---|---|
|
enumeration_doc_categories: Catégories des documents
|
||
|
enumeration_activities: Activités (suivi du temps)
|
||
|
label_greater_or_equal: ">="
|
||
|
label_less_or_equal: <=
|
||
|
label_less_or_equal: "<="
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/gl.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/he.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/hu.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: A '{{page}}' wiki oldalt {{author}} frissítette.
|
||
|
permission_add_project: Projekt létrehozása
|
||
|
setting_new_project_user_role_id: Projekt létrehozási jog nem adminisztrátor felhasználóknak
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/it.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: La pagina '{{page}}' wiki è stata aggiornata da{{author}}.
|
||
|
permission_add_project: Crea progetto
|
||
|
setting_new_project_user_role_id: Ruolo assegnato agli utenti non amministratori che creano un progetto
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
enumeration_issue_priorities: チケットの優先度
|
||
|
enumeration_doc_categories: 文書カテゴリ
|
||
|
enumeration_activities: 作業分類 (時間トラッキング)
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/ko.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: 위키페이지 '{{page}}' 가 {{author}}에 의하여 고쳐젔습니다.
|
||
|
permission_add_project: 프로젝트 생성
|
||
|
setting_new_project_user_role_id: 프로젝트를 만든 일반사용자에게 주어질 권한
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/lt.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/nl.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/no.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/pl.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/pt-BR.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: A página wiki '{{page}}' foi atualizada por {{author}}.
|
||
|
permission_add_project: Criar projeto
|
||
|
setting_new_project_user_role_id: Papel dado a um usuário não administrador que crie um projeto
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/pt.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/ro.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/ru.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: "{{author}} обновил(а) wiki-страницу '{{page}}'."
|
||
|
permission_add_project: Создание проекта
|
||
|
setting_new_project_user_role_id: Роль, назначаемая пользователю, создавшему проект
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/sk.yml | ||
|---|---|---|
|
label_wiki_content_updated: Wiki stránka aktualizovaná
|
||
|
mail_body_wiki_content_updated: Wiki stránka '{{page}}' bola aktualizovaná užívateľom {{author}}.
|
||
|
setting_repositories_encodings: Kódovanie repozitára
|
||
|
setting_new_project_user_role_id: Rola dána non-admin užívateľovi, ktorý vytvorí projekt
|
||
|
setting_new_project_user_role_id: Rola dána non-admin užívateľovi, ktorý vytvorí projekt
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/sl.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/sr.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/sv.yml | ||
|---|---|---|
|
enumeration_issue_priorities: Ärendeprioriteter
|
||
|
enumeration_doc_categories: Dokumentkategorier
|
||
|
enumeration_activities: Aktiviteter (tidsuppföljning)
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/th.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/tr.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/uk.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/vi.yml | ||
|---|---|---|
|
mail_body_wiki_content_updated: The '{{page}}' wiki page has been updated by {{author}}.
|
||
|
permission_add_project: Create project
|
||
|
setting_new_project_user_role_id: Role given to a non-admin user who creates a project
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/zh-TW.yml | ||
|---|---|---|
|
enumeration_issue_priorities: 項目優先權
|
||
|
enumeration_doc_categories: 文件分類
|
||
|
enumeration_activities: 活動 (時間追蹤)
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/locales/zh.yml | ||
|---|---|---|
|
enumeration_issue_priorities: 问题优先级
|
||
|
enumeration_doc_categories: 文档类别
|
||
|
enumeration_activities: 活动(时间跟踪)
|
||
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
| config/routes.rb | ||
|---|---|---|
|
repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
|
||
|
repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
|
||
|
repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
|
||
|
repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path'
|
||
|
repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
|
||
|
repository_views.connect 'projects/:id/repository/:action/*path'
|
||
|
end
|
||
|
|
||
| lib/diff.rb | ||
|---|---|---|
|
class Diff
|
||
|
module RedmineDiff
|
||
|
class Diff
|
||
|
VERSION = 0.3
|
||
|
VERSION = 0.3
|
||
|
def Diff.lcs(a, b)
|
||
|
astart = 0
|
||
|
bstart = 0
|
||
|
afinish = a.length-1
|
||
|
bfinish = b.length-1
|
||
|
mvector = []
|
||
|
|
||
|
# First we prune off any common elements at the beginning
|
||
|
while (astart <= afinish && bstart <= afinish && a[astart] == b[bstart])
|
||
|
mvector[astart] = bstart
|
||
|
astart += 1
|
||
|
bstart += 1
|
||
|
end
|
||
|
|
||
|
# now the end
|
||
|
while (astart <= afinish && bstart <= bfinish && a[afinish] == b[bfinish])
|
||
|
mvector[afinish] = bfinish
|
||
|
afinish -= 1
|
||
|
bfinish -= 1
|
||
|
end
|
||
|
def Diff.lcs(a, b)
|
||
|
astart = 0
|
||
|
bstart = 0
|
||
|
afinish = a.length-1
|
||
|
bfinish = b.length-1
|
||
|
mvector = []
|
||
|
|
||
|
# First we prune off any common elements at the beginning
|
||
|
while (astart <= afinish && bstart <= afinish && a[astart] == b[bstart])
|
||
|
mvector[astart] = bstart
|
||
|
astart += 1
|
||
|
bstart += 1
|
||
|
end
|
||
|
|
||
|
# now the end
|
||
|
while (astart <= afinish && bstart <= bfinish && a[afinish] == b[bfinish])
|
||
|
mvector[afinish] = bfinish
|
||
|
afinish -= 1
|
||
|
bfinish -= 1
|
||
|
end
|
||
|
bmatches = b.reverse_hash(bstart..bfinish)
|
||
|
thresh = []
|
||
|
links = []
|
||
|
|
||
|
(astart..afinish).each { |aindex|
|
||
|
aelem = a[aindex]
|
||
|
next unless bmatches.has_key? aelem
|
||
|
k = nil
|
||
|
bmatches[aelem].reverse.each { |bindex|
|
||
|
if k && (thresh[k] > bindex) && (thresh[k-1] < bindex)
|
||
|
thresh[k] = bindex
|
||
|
else
|
||
|
k = thresh.replacenextlarger(bindex, k)
|
||
|
end
|
||
|
links[k] = [ (k==0) ? nil : links[k-1], aindex, bindex ] if k
|
||
|
bmatches = b.reverse_hash(bstart..bfinish)
|
||
|
thresh = []
|
||
|
links = []
|
||
|
|
||
|
(astart..afinish).each { |aindex|
|
||
|
aelem = a[aindex]
|
||
|
next unless bmatches.has_key? aelem
|
||
|
k = nil
|
||
|
bmatches[aelem].reverse.each { |bindex|
|
||
|
if k && (thresh[k] > bindex) && (thresh[k-1] < bindex)
|
||
|
thresh[k] = bindex
|
||
|
else
|
||
|
k = thresh.replacenextlarger(bindex, k)
|
||
|
end
|
||
|
links[k] = [ (k==0) ? nil : links[k-1], aindex, bindex ] if k
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if !thresh.empty?
|
||
|
link = links[thresh.length-1]
|
||
|
while link
|
||
|
mvector[link[1]] = link[2]
|
||
|
link = link[0]
|
||
|
if !thresh.empty?
|
||
|
link = links[thresh.length-1]
|
||
|
while link
|
||
|
mvector[link[1]] = link[2]
|
||
|
link = link[0]
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return mvector
|
||
|
end
|
||
|
def makediff(a, b)
|
||
|
mvector = Diff.lcs(a, b)
|
||
|
ai = bi = 0
|
||
|
while ai < mvector.length
|
||
|
bline = mvector[ai]
|
||
|
if bline
|
||
|
while bi < bline
|
||
|
discardb(bi, b[bi])
|
||
|
bi += 1
|
||
|
end
|
||
|
match(ai, bi)
|
||
|
bi += 1
|
||
|
else
|
||
|
discarda(ai, a[ai])
|
||
|
end
|
||
|
ai += 1
|
||
|
end
|
||
|
while ai < a.length
|
||
|
discarda(ai, a[ai])
|
||
|
ai += 1
|
||
|
return mvector
|
||
|
end
|
||
|
while bi < b.length
|
||
|
def makediff(a, b)
|
||
|
mvector = Diff.lcs(a, b)
|
||
|
ai = bi = 0
|
||
|
while ai < mvector.length
|
||
|
bline = mvector[ai]
|
||
|
if bline
|
||
|
while bi < bline
|
||
|
discardb(bi, b[bi])
|
||
|
bi += 1
|
||
|
end
|
||
|
match(ai, bi)
|
||
|
1
|
||
|
end
|
||
|
def compactdiffs
|
||
|
diffs = []
|
||
|
@diffs.each { |df|
|
||
|
i = 0
|
||
|
curdiff = []
|
||
|
while i < df.length
|
||
|
whot = df[i][0]
|
||
|
s = @isstring ? df[i][2].chr : [df[i][2]]
|
||
|
p = df[i][1]
|
||
|
last = df[i][1]
|
||
|
i += 1
|
||
|
while df[i] && df[i][0] == whot && df[i][1] == last+1
|
||
|
s << df[i][2]
|
||
|
last = df[i][1]
|
||
|
i += 1
|
||
|
end
|
||
|
curdiff.push [whot, p, s]
|
||
|
bi += 1
|
||
|
else
|
||
|
discarda(ai, a[ai])
|
||
|
end
|
||
|
ai += 1
|
||
|
end
|
||
|
diffs.push curdiff
|
||
|
}
|
||
|
return diffs
|
||
|
end
|
||
|
while ai < a.length
|
||
|
discarda(ai, a[ai])
|
||
|
ai += 1
|
||
|
end
|
||
|
while bi < b.length
|
||
|
discardb(bi, b[bi])
|
||
|
bi += 1
|
||
|
end
|
||
|
match(ai, bi)
|
||
|
1
|
||
|
end
|
||
|
attr_reader :diffs, :difftype
|
||
|
def compactdiffs
|
||
|
diffs = []
|
||
|
@diffs.each { |df|
|
||
|
i = 0
|
||
|
curdiff = []
|
||
|
while i < df.length
|
||
|
whot = df[i][0]
|
||
|
s = @isstring ? df[i][2].chr : [df[i][2]]
|
||
|
p = df[i][1]
|
||
|
last = df[i][1]
|
||
|
i += 1
|
||
|
while df[i] && df[i][0] == whot && df[i][1] == last+1
|
||
|
s << df[i][2]
|
||
|
last = df[i][1]
|
||
|
i += 1
|
||
|
end
|
||
|
curdiff.push [whot, p, s]
|
||
|
end
|
||
|
diffs.push curdiff
|
||
|
}
|
||
|
return diffs
|
||
|
end
|
||
|
def initialize(diffs_or_a, b = nil, isstring = nil)
|
||
|
if b.nil?
|
||
|
@diffs = diffs_or_a
|
||
|
@isstring = isstring
|
||
|
else
|
||
|
@diffs = []
|
||
|
attr_reader :diffs, :difftype
|
||
|
def initialize(diffs_or_a, b = nil, isstring = nil)
|
||
|
if b.nil?
|
||
|
@diffs = diffs_or_a
|
||
|
@isstring = isstring
|
||
|
else
|
||
|
@diffs = []
|
||
|
@curdiffs = []
|
||
|
makediff(diffs_or_a, b)
|
||
|
@difftype = diffs_or_a.class
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def match(ai, bi)
|
||
|
@diffs.push @curdiffs unless @curdiffs.empty?
|
||
|
@curdiffs = []
|
||
|
makediff(diffs_or_a, b)
|
||
|
@difftype = diffs_or_a.class
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def match(ai, bi)
|
||
|
@diffs.push @curdiffs unless @curdiffs.empty?
|
||
|
@curdiffs = []
|
||
|
end
|
||
|
def discarda(i, elem)
|
||
|
@curdiffs.push ['-', i, elem]
|
||
|
end
|
||
|
def discarda(i, elem)
|
||
|
@curdiffs.push ['-', i, elem]
|
||
|
end
|
||
|
def discardb(i, elem)
|
||
|
@curdiffs.push ['+', i, elem]
|
||
|
end
|
||
|
def discardb(i, elem)
|
||
|
@curdiffs.push ['+', i, elem]
|
||
|
end
|
||
|
def compact
|
||
|
return Diff.new(compactdiffs)
|
||
|
end
|
||
|
def compact
|
||
|
return Diff.new(compactdiffs)
|
||
|
end
|
||
|
def compact!
|
||
|
@diffs = compactdiffs
|
||
|
end
|
||
|
def compact!
|
||
|
@diffs = compactdiffs
|
||
|
end
|
||
|
def inspect
|
||
|
@diffs.inspect
|
||
|
end
|
||
|
def inspect
|
||
|
@diffs.inspect
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
module Diffable
|
||
|
def diff(b)
|
||
|
Diff.new(self, b)
|
||
|
RedmineDiff::Diff.new(self, b)
|
||
|
end
|
||
|
# Create a hash that maps elements of the array to arrays of indices
|
||
| ... | ... | |
|
range.each { |i|
|
||
|
elem = self[i]
|
||
|
if revmap.has_key? elem
|
||
|
revmap[elem].push i
|
||
|
revmap[elem].push i
|
||
|
else
|
||
|
revmap[elem] = [i]
|
||
|
revmap[elem] = [i]
|
||
|
end
|
||
|
}
|
||
|
return revmap
|
||
| ... | ... | |
|
found = self[index]
|
||
|
return nil if value == found
|
||
|
if value > found
|
||
|
low = index + 1
|
||
|
low = index + 1
|
||
|
else
|
||
|
high = index
|
||
|
high = index
|
||
|
end
|
||
|
end
|
||
| ... | ... | |
|
bi = 0
|
||
|
diff.diffs.each { |d|
|
||
|
d.each { |mod|
|
||
|
case mod[0]
|
||
|
when '-'
|
||
|
while ai < mod[1]
|
||
|
newary << self[ai]
|
||
|
ai += 1
|
||
|
bi += 1
|
||
|
end
|
||
|
ai += 1
|
||
|
when '+'
|
||
|
while bi < mod[1]
|
||
|
newary << self[ai]
|
||
|
ai += 1
|
||
|
bi += 1
|
||
|
end
|
||
|
newary << mod[2]
|
||
|
bi += 1
|
||
|
else
|
||
|
raise "Unknown diff action"
|
||
|
end
|
||
|
case mod[0]
|
||
|
when '-'
|
||
|
while ai < mod[1]
|
||
|
newary << self[ai]
|
||
|
ai += 1
|
||
|
bi += 1
|
||
|
end
|
||
|
ai += 1
|
||
|
when '+'
|
||
|
while bi < mod[1]
|
||
|
newary << self[ai]
|
||
|
ai += 1
|
||
|
bi += 1
|
||
|
end
|
||
|
newary << mod[2]
|
||
|
bi += 1
|
||
|
else
|
||
|
raise "Unknown diff action"
|
||
|
end
|
||
|
}
|
||
|
}
|
||
|
while ai < self.length
|
||
| ... | ... | |
|
end
|
||
|
=begin
|
||
|
= Diff
|
||
|
(({diff.rb})) - computes the differences between two arrays or
|
||
|
strings. Copyright (C) 2001 Lars Christensen
|
||
|
= Diff
|
||
|
(({diff.rb})) - computes the differences between two arrays or
|
||
|
strings. Copyright (C) 2001 Lars Christensen
|
||
|
== Synopsis
|
||
|
== Synopsis
|
||
|
diff = Diff.new(a, b)
|
||
|
b = a.patch(diff)
|
||
|
diff = Diff.new(a, b)
|
||
|
b = a.patch(diff)
|
||
|
== Class Diff
|
||
|
=== Class Methods
|
||
|
--- Diff.new(a, b)
|
||
|
--- a.diff(b)
|
||
|
Creates a Diff object which represent the differences between
|
||
|
((|a|)) and ((|b|)). ((|a|)) and ((|b|)) can be either be arrays
|
||
|
of any objects, strings, or object of any class that include
|
||
|
module ((|Diffable|))
|
||
|
== Class Diff
|
||
|
=== Class Methods
|
||
|
--- Diff.new(a, b)
|
||
|
--- a.diff(b)
|
||
|
Creates a Diff object which represent the differences between
|
||
|
((|a|)) and ((|b|)). ((|a|)) and ((|b|)) can be either be arrays
|
||
|
of any objects, strings, or object of any class that include
|
||
|
module ((|Diffable|))
|
||
|
== Module Diffable
|
||
|
The module ((|Diffable|)) is intended to be included in any class for
|
||
|
which differences are to be computed. Diffable is included into String
|
||
|
and Array when (({diff.rb})) is (({require}))'d.
|
||
|
== Module Diffable
|
||
|
The module ((|Diffable|)) is intended to be included in any class for
|
||
|
which differences are to be computed. Diffable is included into String
|
||
|
and Array when (({diff.rb})) is (({require}))'d.
|
||
|
Classes including Diffable should implement (({[]})) to get element at
|
||
|
integer indices, (({<<})) to append elements to the object and
|
||
|
(({ClassName#new})) should accept 0 arguments to create a new empty
|
||
|
object.
|
||
|
Classes including Diffable should implement (({[]})) to get element at
|
||
|
integer indices, (({<<})) to append elements to the object and
|
||
|
(({ClassName#new})) should accept 0 arguments to create a new empty
|
||
|
object.
|
||
|
=== Instance Methods
|
||
|
--- Diffable#patch(diff)
|
||
|
Applies the differences from ((|diff|)) to the object ((|obj|))
|
||
|
and return the result. ((|obj|)) is not changed. ((|obj|)) and
|
||
|
can be either an array or a string, but must match the object
|
||
|
from which the ((|diff|)) was created.
|
||
|
=== Instance Methods
|
||
|
--- Diffable#patch(diff)
|
||
|
Applies the differences from ((|diff|)) to the object ((|obj|))
|
||
|
and return the result. ((|obj|)) is not changed. ((|obj|)) and
|
||
|
can be either an array or a string, but must match the object
|
||
|
from which the ((|diff|)) was created.
|
||
|
=end
|
||
| lib/redmine/scm/adapters/abstract_adapter.rb | ||
|---|---|---|
|
def entries(path=nil, identifier=nil)
|
||
|
return nil
|
||
|
end
|
||
|
def branches
|
||
|
return nil
|
||
|
end
|
||
|
def tags
|
||
|
return nil
|
||
|
end
|
||
|
def default_branch
|
||
|
return nil
|
||
|
end
|
||
|
|
||
|
def properties(path, identifier=nil)
|
||
|
return nil
|
||
| ... | ... | |
|
|
||
|
class Revision
|
||
|
attr_accessor :identifier, :scmid, :name, :author, :time, :message, :paths, :revision, :branch
|
||
|
def initialize(attributes={})
|
||
|
self.identifier = attributes[:identifier]
|
||
|
self.scmid = attributes[:scmid]
|
||
| ... | ... | |
|
self.revision = attributes[:revision]
|
||
|
self.branch = attributes[:branch]
|
||
|
end
|
||
|
|
||
|
def save(repo)
|
||
|
if repo.changesets.find_by_scmid(scmid.to_s).nil?
|
||
|
changeset = Changeset.create!(
|
||
|
:repository => repo,
|
||
|
:revision => identifier,
|
||
|
:scmid => scmid,
|
||
|
:committer => author,
|
||
|
:committed_on => time,
|
||
|
:comments => message)
|
||
|
paths.each do |file|
|
||
|
Change.create!(
|
||
|
:changeset => changeset,
|
||
|
:action => file[:action],
|
||
|
:path => file[:path])
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
class Annotate
|
||
| lib/redmine/scm/adapters/git_adapter.rb | ||
|---|---|---|
|
module Scm
|
||
|
module Adapters
|
||
|
class GitAdapter < AbstractAdapter
|
||
|
|
||
|
# Git executable name
|
||
|
GIT_BIN = "git"
|
||
|
# Get the revision of a particuliar file
|
||
|
def get_rev (rev,path)
|
||
|
|
||
|
if rev != 'latest' && !rev.nil?
|
||
|
cmd="#{GIT_BIN} --git-dir #{target('')} show --date=iso --pretty=fuller #{shell_quote rev} -- #{shell_quote path}"
|
||
|
else
|
||
|
@branch ||= shellout("#{GIT_BIN} --git-dir #{target('')} branch") { |io| io.grep(/\*/)[0].strip.match(/\* (.*)/)[1] }
|
||
|
cmd="#{GIT_BIN} --git-dir #{target('')} log --date=iso --pretty=fuller -1 #{@branch} -- #{shell_quote path}"
|
||
|
def info
|
||
|
begin
|
||
|
Info.new(:root_url => url, :lastrev => lastrev('',nil))
|
||
|
rescue
|
||
|
nil
|
||
|
end
|
||
|
rev=[]
|
||
|
i=0
|
||
|
shellout(cmd) do |io|
|
||
|
files=[]
|
||
|
changeset = {}
|
||
|
parsing_descr = 0 #0: not parsing desc or files, 1: parsing desc, 2: parsing files
|
||
|
end
|
||
|
def branches
|
||
|
branches = []
|
||
|
cmd = "cd #{target('')} && #{GIT_BIN} branch"
|
||
|
shellout(cmd) do |io|
|
||
|
io.each_line do |line|
|
||
|
if line =~ /^commit ([0-9a-f]{40})$/
|
||
|
key = "commit"
|
||
|
value = $1
|
||
|
if (parsing_descr == 1 || parsing_descr == 2)
|
||
|
parsing_descr = 0
|
||
|
rev = Revision.new({:identifier => changeset[:commit],
|
||
|
:scmid => changeset[:commit],
|
||
|
:author => changeset[:author],
|
||
|
:time => Time.parse(changeset[:date]),
|
||
|
:message => changeset[:description],
|
||
|
:paths => files
|
||
|
})
|
||
|
changeset = {}
|
||
|
files = []
|
||
|
end
|
||
|
changeset[:commit] = $1
|
||
|
elsif (parsing_descr == 0) && line =~ /^(\w+):\s*(.*)$/
|
||
|
key = $1
|
||
|
value = $2
|
||
|
if key == "Author"
|
||
|
changeset[:author] = value
|
||
|
elsif key == "CommitDate"
|
||
|
changeset[:date] = value
|
||
|
end
|
||
|
elsif (parsing_descr == 0) && line.chomp.to_s == ""
|
||
|
parsing_descr = 1
|
||
|
changeset[:description] = ""
|
||
|
elsif (parsing_descr == 1 || parsing_descr == 2) && line =~ /^:\d+\s+\d+\s+[0-9a-f.]+\s+[0-9a-f.]+\s+(\w)\s+(.+)$/
|
||
|
parsing_descr = 2
|
||
|
fileaction = $1
|
||
|
filepath = $2
|
||
|
files << {:action => fileaction, :path => filepath}
|
||
|
elsif (parsing_descr == 1) && line.chomp.to_s == ""
|
||
|
parsing_descr = 2
|
||
|
elsif (parsing_descr == 1)
|
||
|
changeset[:description] << line
|
||
|
end
|
||
|
end
|
||
|
rev = Revision.new({:identifier => changeset[:commit],
|
||
|
:scmid => changeset[:commit],
|
||
|
:author => changeset[:author],
|
||
|
:time => (changeset[:date] ? Time.parse(changeset[:date]) : nil),
|
||
|
:message => changeset[:description],
|
||
|
:paths => files
|
||
|
})
|
||
|
branches << line.match('\s*\*?\s*(.*)$')[1]
|
||
|
end
|
||
|
end
|
||
|
get_rev('latest',path) if rev == []
|
||
|
return nil if $? && $?.exitstatus != 0
|
||
|
return rev
|
||
|
branches.sort!
|
||
|
end
|
||
|
def info
|
||
|
revs = revisions(url,nil,nil,{:limit => 1})
|
||
|
if revs && revs.any?
|
||
|
Info.new(:root_url => url, :lastrev => revs.first)
|
||
|
else
|
||
|
nil
|
||
|
def tags
|
||
|
tags = []
|
||
|
cmd = "cd #{target('')} && #{GIT_BIN} tag"
|
||
|
shellout(cmd) do |io|
|
||
|
io.readlines.sort!.map{|t| t.strip}
|
||
|
end
|
||
|
rescue Errno::ENOENT => e
|
||
|
return nil
|
||
|
end
|
||
|
def default_branch
|
||
|
branches.include?('master') ? 'master' : branches.first
|
||
|
end
|
||
|
|
||
|
def entries(path=nil, identifier=nil)
|
||
| ... | ... | |
|
sha = $2
|
||
|
size = $3
|
||
|
name = $4
|
||
|
full_path = path.empty? ? name : "#{path}/#{name}"
|
||
|
entries << Entry.new({:name => name,
|
||
|
:path => (path.empty? ? name : "#{path}/#{name}"),
|
||
|
:kind => ((type == "tree") ? 'dir' : 'file'),
|
||
|
:size => ((type == "tree") ? nil : size),
|
||
|
:lastrev => get_rev(identifier,(path.empty? ? name : "#{path}/#{name}"))
|
||
|
|
||
|
}) unless entries.detect{|entry| entry.name == name}
|
||
|
:path => full_path,
|
||
|
:kind => (type == "tree") ? 'dir' : 'file',
|
||
|
:size => (type == "tree") ? nil : size,
|
||
|
:lastrev => lastrev(full_path,identifier)
|
||
|
}) unless entries.detect{|entry| entry.name == name}
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return nil if $? && $?.exitstatus != 0
|
||
|
entries.sort_by_name
|
||
|
end
|
||
|
|
||
|
def lastrev(path,rev)
|
||
|
return nil if path.nil?
|
||
|
cmd = "#{GIT_BIN} --git-dir #{target('')} log --pretty=fuller --no-merges -n 1 "
|
||
|
cmd << " #{shell_quote rev} " if rev
|
||
|
cmd << "-- #{path} " unless path.empty?
|
||
|
shellout(cmd) do |io|
|
||
|
id = io.gets.split[1]
|
||
|
author = io.gets.match('Author:\s+(.*)$')[1]
|
||
|
2.times { io.gets }
|
||
|
time = io.gets.match('CommitDate:\s+(.*)$')[1]
|
||
|
Revision.new({
|
||
|
:identifier => id,
|
||
|
:scmid => id,
|
||
|
:author => author,
|
||
|
:time => time,
|
||
|
:message => nil,
|
||
|
:paths => nil
|
||
|
})
|
||
|
end
|
||
|
end
|
||
|
def num_revisions
|
||
|
cmd = "#{GIT_BIN} --git-dir #{target('')} log --all --pretty=format:'' | wc -l"
|
||
|
shellout(cmd) {|io| io.gets.chomp.to_i + 1 }
|
||
|
end
|
||
|
def revisions(path, identifier_from, identifier_to, options={})
|
||
|
revisions = Revisions.new
|
||
|
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw --date=iso --pretty=fuller"
|
||
|
cmd = "#{GIT_BIN} --git-dir #{target('')} log --find-copies-harder --raw --date=iso --pretty=fuller"
|
||
|
cmd << " --reverse" if options[:reverse]
|
||
|
cmd << " -n #{options[:limit].to_i} " if (!options.nil?) && options[:limit]
|
||
|
cmd << " --all" if options[:all]
|
||
|
cmd << " -n #{options[:limit]} " if options[:limit]
|
||
|
cmd << " #{shell_quote(identifier_from + '..')} " if identifier_from
|
||
|
cmd << " #{shell_quote identifier_to} " if identifier_to
|
||
|
cmd << " -- #{path}" if path && !path.empty?
|
||
|
shellout(cmd) do |io|
|
||
|
files=[]
|
||
|
changeset = {}
|
||
| ... | ... | |
|
value = $1
|
||
|
if (parsing_descr == 1 || parsing_descr == 2)
|
||
|
parsing_descr = 0
|
||
|
revision = Revision.new({:identifier => changeset[:commit],
|
||
|
:scmid => changeset[:commit],
|
||