Permalink
Browse files

create changes in redmine only when filesystem scm has been patched...

  • Loading branch information...
1 parent bd77d69 commit 6a36276efda823578f343ead23c201c150d8834e @amartel committed Feb 6, 2012
Showing with 25 additions and 18 deletions.
  1. +25 −18 lib/scm_extensions_filesystem_adapter_patch.rb
@@ -38,24 +38,28 @@ def scm_extensions_upload(repository, folder_path, attachments, comments, identi
if container
error = false
- rev = -1
- rev = repository.latest_changeset.revision.to_i if repository.latest_changeset
- rev = rev + 1
- changeset = Changeset.create(:repository => repository,
+ if repository.supports_all_revisions?
+ rev = -1
+ rev = repository.latest_changeset.revision.to_i if repository.latest_changeset
+ rev = rev + 1
+ changeset = Changeset.create(:repository => repository,
:revision => rev,
:committer => User.current.login,
:committed_on => Time.now,
:comments => comments)
+ end
attachments.each_value do |attachment|
file = attachment['file']
next unless file && file.size > 0 && !error
filename = File.basename(file.original_filename)
next if scm_extensions_invalid_path(filename)
begin
- action = "A"
- action = "M" if File.exists?(File.join(repository.url, folder_path, filename))
- Change.create( :changeset => changeset, :action => action, :path => File.join("/", folder_path, filename))
+ if repository.supports_all_revisions?
+ action = "A"
+ action = "M" if File.exists?(File.join(repository.url, folder_path, filename))
+ Change.create( :changeset => changeset, :action => action, :path => File.join("/", folder_path, filename))
+ end
File.open(File.join(repository.url, folder_path, filename), "wb") do |f|
buffer = ""
while (buffer = file.read(8192))
@@ -95,15 +99,17 @@ def scm_extensions_delete(repository, path, comments, identifier)
error = false
begin
- rev = -1
- rev = repository.latest_changeset.revision.to_i if repository.latest_changeset
- rev = rev + 1
- changeset = Changeset.create(:repository => repository,
+ if repository.supports_all_revisions?
+ rev = -1
+ rev = repository.latest_changeset.revision.to_i if repository.latest_changeset
+ rev = rev + 1
+ changeset = Changeset.create(:repository => repository,
:revision => rev,
:committer => User.current.login,
:committed_on => Time.now,
:comments => comments)
- Change.create( :changeset => changeset, :action => 'D', :path => File.join("/", path))
+ Change.create( :changeset => changeset, :action => 'D', :path => File.join("/", path))
+ end
FileUtils.remove_entry_secure File.join(repository.url, path)
if metapath
@@ -124,16 +130,17 @@ def scm_extensions_mkdir(repository, path, comments, identifier)
error = false
begin
- rev = -1
- rev = repository.latest_changeset.revision.to_i if repository.latest_changeset
- rev = rev + 1
- changeset = Changeset.create(:repository => repository,
+ if repository.supports_all_revisions?
+ rev = -1
+ rev = repository.latest_changeset.revision.to_i if repository.latest_changeset
+ rev = rev + 1
+ changeset = Changeset.create(:repository => repository,
:revision => rev,
:committer => User.current.login,
:committed_on => Time.now,
:comments => "created folder: #{path}")
- Change.create( :changeset => changeset, :action => 'A', :path => File.join("/", path))
-
+ Change.create( :changeset => changeset, :action => 'A', :path => File.join("/", path))
+ end
Dir.mkdir(File.join(repository.url, path))
rescue
error = true

0 comments on commit 6a36276

Please sign in to comment.