Revision 1298:4f746d8966dd lib/redmine/scm

View differences:

lib/redmine/scm/adapters/abstract_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
17 17

  
18 18
require 'cgi'
19 19

  
20
if RUBY_VERSION < '1.9'
21
  require 'iconv'
22
end
23

  
20 24
module Redmine
21 25
  module Scm
22 26
    module Adapters
......
214 218
          Rails.logger
215 219
        end
216 220

  
221
        # Path to the file where scm stderr output is logged
222
        # Returns nil if the log file is not writable
223
        def self.stderr_log_file
224
          if @stderr_log_file.nil?
225
            writable = false
226
            path = Redmine::Configuration['scm_stderr_log_file'].presence
227
            path ||= Rails.root.join("log/#{Rails.env}.scm.stderr.log").to_s
228
            if File.exists?(path)
229
              if File.file?(path) && File.writable?(path) 
230
                writable = true
231
              else
232
                logger.warn("SCM log file (#{path}) is not writable")
233
              end
234
            else
235
              begin
236
                File.open(path, "w") {}
237
                writable = true
238
              rescue => e
239
                logger.warn("SCM log file (#{path}) cannot be created: #{e.message}")
240
              end
241
            end
242
            @stderr_log_file = writable ? path : false
243
          end
244
          @stderr_log_file || nil
245
        end
246

  
217 247
        def self.shellout(cmd, options = {}, &block)
218 248
          if logger && logger.debug?
219 249
            logger.debug "Shelling out: #{strip_credential(cmd)}"
220
          end
221
          if Rails.env == 'development'
222
            # Capture stderr when running in dev environment
223
            cmd = "#{cmd} 2>>#{shell_quote(Rails.root.join('log/scm.stderr.log').to_s)}"
250
            # Capture stderr in a log file
251
            if stderr_log_file
252
              cmd = "#{cmd} 2>>#{shell_quote(stderr_log_file)}"
253
            end
224 254
          end
225 255
          begin
226 256
            mode = "r+"
lib/redmine/scm/adapters/bazaar_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
104 104
            re = %r{^V\s+(#{Regexp.escape(prefix)})?(\/?)([^\/]+)(\/?)\s+(\S+)\r?$}
105 105
            io.each_line do |line|
106 106
              next unless line =~ re
107
              name_locale = $3.strip
107
              name_locale, slash, revision = $3.strip, $4, $5.strip
108 108
              name = scm_iconv('UTF-8', @path_encoding, name_locale)
109 109
              entries << Entry.new({:name => name,
110 110
                                    :path => ((path.empty? ? "" : "#{path}/") + name),
111
                                    :kind => ($4.blank? ? 'file' : 'dir'),
111
                                    :kind => (slash.blank? ? 'file' : 'dir'),
112 112
                                    :size => nil,
113
                                    :lastrev => Revision.new(:revision => $5.strip)
113
                                    :lastrev => Revision.new(:revision => revision)
114 114
                                  })
115 115
            end
116 116
          end
lib/redmine/scm/adapters/darcs_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
lib/redmine/scm/adapters/filesystem_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# FileSystem adapter
5 5
# File written by Paul Rivier, at Demotera.
lib/redmine/scm/adapters/git_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
lib/redmine/scm/adapters/mercurial_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
lib/redmine/scm/adapters/subversion_adapter.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
lib/redmine/scm/base.rb
4 4
      class << self
5 5

  
6 6
        def all
7
          @scms
7
          @scms || []
8 8
        end
9 9

  
10 10
        # Add a new SCM adapter and repository

Also available in: Unified diff