]> git.draconx.ca Git - homepage.git/blobdiff - lib/project-readme.rb
Release slotifier-1.
[homepage.git] / lib / project-readme.rb
index 1e1fa874631a1cef261ff0eaa8d8dcb1e2fa7232..74691716065c476adc841d665c341d4b5f3a9270 100644 (file)
 
 def project_readme(item = @item)
     tag = item.fetch(:release, "HEAD")
-    shortname = item.fetch(:shortname, item[:title].downcase)
+    shortname = item.fetch(:shortname, item[:module])
 
     data, status = Open3.capture2("git", "submodule", "foreach", "--quiet",
       "case $sm_path in */" + item[:module] + ")" +
-      "git remote get-url origin || echo;" +
-      "git show " + tag + ":README.md ;;" +
+      "git fetch --quiet --tags;" +
+      "git log --max-count=1 --format=%cI #{tag}; printf '\\35';" +
+      "git show #{tag}:NEWS 2>/dev/null; printf '\\35';" +
+      "git remote get-url origin; printf '\\35';" +
+      "git show #{tag}:README.md ;;" +
       "esac")
     raise "git submodule foreach failed" if status != 0
 
-    gituri, contents = data.split("\n", 2)
+    date, news, gituri, contents = data.split("\35", 4)
     intro, contents = contents.split("#", 2)
     contents = if contents.nil? then "" else "\n#" + contents end
 
+    gituri.strip!
     gitweb = gituri.sub(%r{^[^/]*(.*)(/.*)}, '\1/gitweb\2')
+    date = Date.iso8601(date).to_time
 
     obtaining = <<~EOF
         # Obtaining #{item[:title]}
     EOF
 
     if item[:release].nil?
-        obtaining += <<~EOF
+        obtaining += "\n" + <<~EOF
             There are presently no released versions of #{shortname}.
         EOF
     else
-        # TODO
+        newsver, news = news.split("\n", 2)
+        newsver.sub!(/^.*([[:digit:]][^:]*).*$/, '\1')
+
+        targz = "#{shortname}-#{newsver}.tar.gz"
+        distbase = "/archive/#{shortname}"
+        obtaining += <<~EOF
+            [archive]: #{distbase}
+
+            All released files are available from the [#{shortname} archive
+            directory][archive].
+        EOF
     end
 
     obtaining += <<~EOF
@@ -51,5 +66,39 @@ def project_readme(item = @item)
         <kbd>git clone #{gituri}</kbd>
     EOF
 
-    return intro + obtaining + contents
+    unless item[:release].nil?
+        obtaining += "\n" + <<~EOF
+            [targz]: #{distbase}/#{targz}
+            [targzsig]: #{distbase}/#{targz}.sig
+
+            The most recent release is version #{newsver}, released on
+            #{date.getutc.strftime("%Y-%m-%d")}.  Source code for this version
+            is available in [#{targz}][targz] ([signature][targzsig]).
+            Noteworthy changes in this release:
+        EOF
+        obtaining += "\n"
+        news.each_line do |line|
+            break if line =~ /^[^[:space:]]/
+            obtaining += line.lstrip
+        end
+
+        obtaining += "\n\n" + <<~EOF
+            [gpg]: https://gnupg.org/
+
+            Use the signature file to verify that the corresponding source
+            bundle is intact.  After downloading both files, if [GnuPG][gpg]
+            is installed, the signature can be verified with a command like:
+
+            <kbd>gpg --verify #{targz}.sig</kbd>
+
+            If the verification fails because you don't have the required
+            public key, that key can be imported with a command such as:
+
+            <kbd>gpg --keyserver keys.gnupg.net --recv-keys 5B45D3D185B8E1F6</kbd>
+
+            Then run the verify command again.
+        EOF
+    end
+
+    return "#{intro}\n\n#{obtaining}\n\n#{contents}"
 end