about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-08-18 08:16:23 +0000
committerEric Wong <normalperson@yhbt.net>2012-08-18 08:16:23 +0000
commit8bf0815a595ee755d91ca013572dd7911844d5db (patch)
treed3bbcc66332ad61ca837f66e5c3f39001c7b3cae
parent9b980f521c25b2309fe2a02f84e31b82db3b4c99 (diff)
downloadlocal-openid-8bf0815a595ee755d91ca013572dd7911844d5db.tar.gz
Rakefile: update fm_update task for freecode.com
freshmeat is now freecode, and requires HTTPS
-rw-r--r--Rakefile18
1 files changed, 13 insertions, 5 deletions
diff --git a/Rakefile b/Rakefile
index 27ba42f..1b29396 100644
--- a/Rakefile
+++ b/Rakefile
@@ -76,12 +76,15 @@ task :fm_update do
   require 'net/netrc'
   require 'json'
   version = ENV['VERSION'] or abort "VERSION= needed"
-  uri = URI.parse('http://freshmeat.net/projects/local-openid/releases.json')
+  uri = URI.parse('https://freecode.com/projects/local-openid/releases.json')
   rc = Net::Netrc.locate('local-openid-fm') or abort "~/.netrc not found"
   api_token = rc.password
-  changelog = tags.find { |t| t[:tag] == "v#{version}" }[:body]
+  _, subject, body = `git cat-file tag v#{version}`.split(/\n\n/, 3)
   tmp = Tempfile.new('fm-changelog')
-  tmp.syswrite(changelog)
+  tmp.puts subject
+  tmp.puts
+  tmp.puts body
+  tmp.flush
   system(ENV["VISUAL"], tmp.path) or abort "#{ENV["VISUAL"]} failed: #$?"
   changelog = File.read(tmp.path).strip
 
@@ -93,7 +96,12 @@ task :fm_update do
       "changelog" => changelog,
     },
   }.to_json
-  Net::HTTP.start(uri.host, uri.port) do |http|
-    p http.post(uri.path, req, {'Content-Type'=>'application/json'})
+
+  if ! changelog.strip.empty? && version =~ %r{\A[\d\.]+\d+\z}
+    Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
+      p http.post(uri.path, req, {'Content-Type'=>'application/json'})
+    end
+  else
+    warn "not updating freshmeat for v#{version}"
   end
 end