about summary refs log tree commit homepage
path: root/lib/wrongdoc/changelog.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wrongdoc/changelog.rb')
-rw-r--r--lib/wrongdoc/changelog.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/wrongdoc/changelog.rb b/lib/wrongdoc/changelog.rb
new file mode 100644
index 0000000..f16bfbf
--- /dev/null
+++ b/lib/wrongdoc/changelog.rb
@@ -0,0 +1,25 @@
+# helper method for generating the ChangeLog in RDoc format atomically
+module Wrongdoc::Changelog
+  include Wrongdoc::History
+
+  def changelog
+    fp = Tempfile.new('ChangeLog', '.')
+    fp.write "ChangeLog from #@cgit_uri"
+    cmd = %w(git log)
+    if @changelog_start && tags[0]
+      range = "#@changelog_start..#{tags[0][:tag]}"
+      fp.write(" (#{range})")
+      cmd << range
+    end
+    fp.write("\n\n")
+    prefix = "   "
+    IO.popen(cmd.join(' ')) do |io|
+      io.each { |line|
+        fp.write prefix
+        fp.write line
+      }
+    end
+    File.rename(fp.path, 'ChangeLog')
+    fp.close!
+  end
+end