lib/scm/svn.rb in scm-0.1.0.pre1 vs lib/scm/svn.rb in scm-0.1.0.pre2

- old
+ new

@@ -424,11 +424,11 @@ # The commits in the repository. # def commits(options={}) return enum_for(:commits,options) unless block_given? - arguments = [] + arguments = ['-v'] if options[:commit] arguments << '--revision' << options[:commit] end @@ -441,39 +441,62 @@ end revision = nil date = nil author = nil - summary = '' + message = '' + files = [] io = popen('svn log',*arguments) # eat the first LOG_SEPARATOR io.readline until io.eof? - line = io.readline - line.chomp! + line = io.readline.chomp revision, author, date, changes = line.split(' | ',4) revision = revision[1..-1].to_i - date = Time.parse(date) + date = Time.parse(date) - # eat the empty line separating the metadata from the summary - line.readline + # eat the next line separating the metadata from the summary + line = io.readline.chomp - loop do - line = io.readline - break if line == LOG_SEPARATOR - - summary << line + if line == 'Changed paths:' + files = readlines_until(io) end - yield Commits::SVN.new(revision,date,author,summary) + description = readlines_until(io,LOG_SEPARATOR) + summary = description[0] + message = description.join($/) + yield Commits::SVN.new(revision,date,author,summary,message,files) + revision = date = author = nil - summary = '' + message = '' + files = [] end + end + + # + # Lists the files of the SVN repository. + # + # @yield [file] + # The given block will be passed each file. + # + # @yieldparam [String] file + # A path of a file tracked by SVN. + # + # @return [Enumerator] + # If no block is given, an Enumerator will be returned. + # + def files + return enum_for(:files) unless block_given? + + popen('svn','ls','-R') do |file| + yield file if File.file?(File.join(@path,file)) + end + return nil end protected #