format_commits

in jekyll/plugins/recently_updated_generator.rb [66:115]


  def format_commits(commits, github_repo, youtrack_project, pages_by_path, toc_by_path, toc_by_id)
    content = ''

    prev_date = ''
    commits.each do |c|

      if c[:files].any? {|f| not should_skip(f[:file]) } then

        date = c[:date].strftime('%-d %B %Y')
        content << "<hr>\n## #{date}\n" unless date == prev_date
        content << "\n"
        content << "**#{format_message(c[:subject], github_repo, youtrack_project)}** ([view diff](https://github.com/#{github_repo}/commit/#{c[:hash]}))\n"
        body = c[:body].join()
        content << "<br>#{format_message(body, github_repo, youtrack_project)}\n"

        content << "\n"
        c[:files].each do |f|
          file = f[:file]
          if not should_skip(file) then
            case f[:type]
            when 'D'
              content << "* `#{file}` (deleted)\n"
            when 'R'
                newfile = f[:newfile]
                data = format_file(newfile, pages_by_path, toc_by_path, toc_by_id)
                if data then
                  content << data + " (renamed from `#{file}`)\n"
                else
                  if pages_by_path.key?(file) then
                    data = format_file(file, pages_by_path, toc_by_path, toc_by_id)
                    content << data + " (renamed from `#{newfile}`)\n" if data
                  else
                    content << "* (Renamed `#{file}` to `#{newfile}`. Neither file exists now)\n"
                  end
                end
            else
              data = format_file(file, pages_by_path, toc_by_path, toc_by_id)
              content << data + "\n" if data
            end
          end
        end
        content << "\n"

        prev_date = date
      end
    end

    content
  end