Follow-up to r29036: Now that the "mergeinfo" transaction file is no
[svn.git] / tools / examples / svnlog2html.rb
blob77923deb24604140c19c7b5df547e3faeafb598b
1 #!/usr/bin/env ruby
3 require "erb"
4 require "svn/client"
6 include ERB::Util
8 path = File.expand_path(ARGV.shift || Dir.pwd)
10 html = <<-HEADER
11 <?xml version="1.0" encoding="utf-8"?>
12 <!DOCTYPE html
13     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
14     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
15 <html xmlns="http://www.w3.org/1999/xhtml">
16 <head>
17   <style type="text/css">
18 div.entry
20   border: 1px solid red;
21   border-width: 1px 0 0 1px;
22   margin: 2em 2em 2em 3em;
23   padding: 0 2em;
26 pre.message
28   border-left: 1px solid red;
29   margin: 1em 2em;
30   padding-left: 1em;
33 div.info
35   text-align: right;
38 span.info
40   border-bottom: 1px solid red;
41   padding: 0 5px 1px 1em;
44 span.author
46   font-style: italic;
49 span.date
51   color: #999;
54 li.action-A
56   color: blue;
59 li.action-M
61   color: green;
64 li.action-D
66   color: red;
67   text-decoration: line-through;
69   </style>
70   <title>#{h path}</title>
71 </head>
72 <body>
73 <h1>#{h path}</h1>
74 HEADER
76 ctx = Svn::Client::Context.new
77 ctx.log(path, "HEAD", 0, 40, true, true) do
78   |changed_paths, rev, author, date, message|
80   html << <<-ENTRY_HEADER
82 <div class="entry">
83   <h2>r#{h rev}</h2>
84   <pre class="message">#{h message}</pre>
85   <div class="info">
86     <span class="info">
87       by <span class="author">#{h author}</span>
88       at <span class="date">#{date}</span>
89     </span>
90   </div>
91   <div class="changed-path">
92 ENTRY_HEADER
94   changed_paths.sort.each do |path, changed_path|
95     action = changed_path.action
96     html << <<-ENTRY_PATH
97     <ul>
98       <li class="action-#{h action}">
99         <span class="action">#{h action}</span>:
100         <span class="changed-path">#{h path}</span>
101       </li>
102     </ul>
103 ENTRY_PATH
104   end
106   html << <<-ENTRY_FOOTER
107   </div>
108 </div>
110 ENTRY_FOOTER
113 html << <<-FOOTER
114 </body>
115 </html>
116 FOOTER
118 puts html