Sha256: 6b5a635a22ca7e0f86e723813b05325e1ad930dc94ec59bb8dccec8ef0aa6b74

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 KB

Contents

module Churn

  # Analyzes SVN SCM to find recently changed files, and what lines have been altered
  class SvnAnalyzer < SourceControl

    # @return [Boolean]
    def self.supported?
      File.exist?(".svn")
    end

    # @return [Array]
    def get_logs
      `svn log --verbose#{date_range}#{svn_credentials}`.split(/\n/).map { |line| clean_up_svn_line(line) }.compact
    end

    # @raise RunTimeError Currently, the generate history option does not support Subversion
    def generate_history(starting_point)
      raise NotImplementedError, "currently the generate history option does not support subversion"
    end

    # This method is not supported by SVN
    # @return [Array]
    def get_revisions
      []
    end

    # This method is not supported by SVN
    # @return [Hash]
    def get_updated_files_change_info(revision, revisions)
      {}
    end

    private

    def svn_credentials
      " --username #{ENV['SVN_USR']} --password #{ENV['SVN_PWD']}" if ENV['SVN_PWD'] && ENV['SVN_USR']
    end

    def date_range
      if @start_date
        date = Chronic.parse(@start_date)
        " --revision {#{date.strftime('%Y-%m-%d')}}:{#{Time.now.strftime('%Y-%m-%d')}}"
      end
    end

    def clean_up_svn_line(line)
      match = line.match(/\W*[A,M]\W+(\/.*)\b/)
      match ? match[1] : nil
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
churn-1.0.8 lib/churn/scm/svn_analyzer.rb
churn-1.0.7 lib/churn/scm/svn_analyzer.rb
churn-1.0.6 lib/churn/scm/svn_analyzer.rb
churn-1.0.5 lib/churn/scm/svn_analyzer.rb
churn-1.0.4 lib/churn/scm/svn_analyzer.rb