From: zuber Date: Tue, 29 Sep 2009 21:34:42 +0000 (+0200) Subject: Merge branch 'master' of stigma.nowoczesnapolska.org.pl:platforma X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/b12e3cd743360720e18e35f77ece2ba355d99d55?hp=935076367b73bf9506751fe215cacc09c3d6e417 Merge branch 'master' of stigma.nowoczesnapolska.org.pl:platforma --- diff --git a/lib/wlrepo/mercurial_backend/__init__.py b/lib/wlrepo/mercurial_backend/__init__.py index f0d3d076..6dd3c11b 100644 --- a/lib/wlrepo/mercurial_backend/__init__.py +++ b/lib/wlrepo/mercurial_backend/__init__.py @@ -72,10 +72,8 @@ class MercurialRevision(wlrepo.Revision): a = self._changectx.ancestor(other._changectx) return (a.branch() == self._changectx.branch()) - def has_children(self): - children = self._library._hgrepo.changelog.children(self.hgrev()) - print "C:", children, bool(children) - return bool(children) + def children(self): + return bool(self._library._hgrepo.changelog.children(self.hgrev())) def merge_with(self, other, user, message): lock = self._library.lock(True) diff --git a/lib/wlrepo/mercurial_backend/document.py b/lib/wlrepo/mercurial_backend/document.py index fcfd14c4..a579fb75 100644 --- a/lib/wlrepo/mercurial_backend/document.py +++ b/lib/wlrepo/mercurial_backend/document.py @@ -50,6 +50,10 @@ class MercurialDocument(wlrepo.Document): ops(self._library, entry_path) message, user = commit_info(self) + + message = self._library._sanitize_string(message) + user = self._library._sanitize_string(user) + self._library._commit(message, user) try: return self._library.document(docid=self.id, user=user) diff --git a/redmine/redmine_publications/app/controllers/publications_controller.rb b/redmine/redmine_publications/app/controllers/publications_controller.rb index ebf735b9..c7a11948 100644 --- a/redmine/redmine_publications/app/controllers/publications_controller.rb +++ b/redmine/redmine_publications/app/controllers/publications_controller.rb @@ -13,34 +13,29 @@ class PublicationsController < ApplicationController end def refresh - @match_status = [] - regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern]) - Publication.delete_all() - repos = Repository.all - if repos - repos.each do |repo| - repo_status = [] - if repo.entries - repo.entries.each do |entry| - match = entry.path.match(regexp) - if match - Publication.find_or_create_by_name(:name => match[1], - :source_file => entry.path, :repository_id => repo.id) - repo_status += [{:path => entry.path, :match => match[1], :matched => true}] - else - repo_status += [{:path => entry.path, :match =>nil, :matched => false}] - end - end - @match_status += [{:repo => repo, :status => repo_status}] + repo = Repository.find(:first, :conditions => ['project_id = ?', Setting.plugin_redmine_publications[:project]] ) + + Rails.logger.info('[INFO] Importing changes from ' << repo.url) + Rails.logger.info('[INFO] Change list: ' << repo.changes.find(:all).inspect ) + + @repo_status = [] + repo.changes.find(:all).each do |change| + Rails.logger.info('[INFO] Importing change ' << change.path) + match = change.path.match(regexp) + if match + Publication.find_or_create_by_name(:name => match[1], + :source_file => change.path, :repository_id => repo.id) + @repo_status += [{:path => change.path, :match => match[1], :matched => true}] + else + @repo_status += [{:path => change.path, :match => nil, :matched => false}] end - end + end - respond_to do |format| + respond_to do |format| format.html - format.xml { render :xml => @match_status} - format.json { render :json => @match_status } - end + format.xml { render :xml => @repo_status} + format.json { render :json => @repo_status } end end diff --git a/redmine/redmine_publications/app/views/publications/refresh.erb b/redmine/redmine_publications/app/views/publications/refresh.erb index 1968a926..311ed33e 100644 --- a/redmine/redmine_publications/app/views/publications/refresh.erb +++ b/redmine/redmine_publications/app/views/publications/refresh.erb @@ -1,9 +1,6 @@ -<% @match_status.each do |repo_status| %> -

Repozytorium: <%= repo_status[:repo].url %>

- -<% repo_status[:status].each do |status| %> +<% @repo_status.each do |status| %> @@ -11,4 +8,3 @@ <% end %>
Ścieżka zasobuRozpoznanoID zasobu
<%= status[:path] %> <%= (status[:matched] && 'Tak') || 'Nie' %>
-<% end %> diff --git a/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb b/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb index 8ab2a7b7..255460e9 100644 --- a/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb +++ b/redmine/redmine_publications/app/views/settings/_publications_settings.html.erb @@ -1,9 +1,8 @@ -<% @tracker = Tracker.find(@settings[:tracker] || 1) %> - +<% @project = Project.find(:first, :conditions => ["id = ?", @settings[:project]]) %>

- - <%= collection_select(:tracker, :id, Tracker.all, :id, :name, {}, {:name => "settings[tracker]"}) %> + + <%= collection_select(:project, :id, Project.all, :id, :name, {}, {:name => "settings[project]"}) %>

diff --git a/redmine/redmine_publications/init.rb b/redmine/redmine_publications/init.rb index 4298f606..01afeab6 100644 --- a/redmine/redmine_publications/init.rb +++ b/redmine/redmine_publications/init.rb @@ -28,7 +28,7 @@ Redmine::Plugin.register :redmine_publications do # permission :view_issues_for_publication, :publications => :issues settings :partial => 'settings/publications_settings', - :default => { :tracker => '1', :pattern => '.*/[a-z_].xml', :editorurl => 'http://localhost/:pubid'} + :default => { :project => '0', :pattern => '[^\$].xml', :editorurl => 'http://localhost/:pubid'} menu :application_menu, :publications, { :controller => 'publications', :action => 'index' }, :caption => 'Publikacje' diff --git a/redmine/redmine_publications/lib/issue_publication_hook.rb b/redmine/redmine_publications/lib/issue_publication_hook.rb index 6d2101cf..788a72f4 100644 --- a/redmine/redmine_publications/lib/issue_publication_hook.rb +++ b/redmine/redmine_publications/lib/issue_publication_hook.rb @@ -21,7 +21,7 @@ class IssuesPublicationHook < Redmine::Hook::ViewListener end def is_pticket?(context) - context[:issue].tracker_id == Setting.plugin_redmine_publications[:tracker].to_i + context[:issue].project_id == Setting.plugin_redmine_publications[:project].to_i end public diff --git a/redmine/redmine_publications/lib/redmine_publications/change_patch.rb b/redmine/redmine_publications/lib/redmine_publications/change_patch.rb index 41ea9596..b8e5c4b6 100644 --- a/redmine/redmine_publications/lib/redmine_publications/change_patch.rb +++ b/redmine/redmine_publications/lib/redmine_publications/change_patch.rb @@ -21,12 +21,14 @@ module RedminePublications module InstanceMethods def update_publication - if self.action == 'A' + if (self.action == 'A') and (self.changeset.repository.project_id == Setting.plugin_redmine_publications[:project].to_i) regexp = Regexp.new(Setting.plugin_redmine_publications[:pattern]) match = self.path.match(regexp) - Rails.logger.info('[INFO] Adding publication: "' << match[1]) - Publication.find_or_create_by_name(:name => match[1], - :source_file => self.path, :repository_id => self.changeset.repository.id ) + if match + Rails.logger.info('[INFO] Adding publication: "' << match[1]) + Publication.find_or_create_by_name(:name => match[1], + :source_file => self.path, :repository_id => self.changeset.repository.id ) + end end end