whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Bazley <s...@apache.org>
Subject [whimsy.git] [1/1] Commit 565fd29: Use common json/diff output module
Date Tue, 26 Jan 2016 00:08:13 GMT
Commit 565fd297d5f19118bf8fd45dbd1647e54a9036d1:
    Use common json/diff output module


Branch: refs/heads/master
Author: Sebb <sebb@apache.org>
Committer: Sebb <sebb@apache.org>
Pusher: sebb <sebb@apache.org>

------------------------------------------------------------
www/roster/public_ldap_committees.rb                         | ++ -----------
www/roster/public_ldap_committers.rb                         | ++ --------
www/roster/public_ldap_groups.rb                             | ++ --------
------------------------------------------------------------
62 changes: 9 additions, 53 deletions.
------------------------------------------------------------


diff --git a/www/roster/public_ldap_committees.rb b/www/roster/public_ldap_committees.rb
index 57b719c..7fa06a7 100644
--- a/www/roster/public_ldap_committees.rb
+++ b/www/roster/public_ldap_committees.rb
@@ -16,11 +16,9 @@
 
 require 'bundler/setup'
 
-require 'whimsy/asf'
-
-require 'open3'
+require_relative 'public_json_common'
 
-GITINFO = ASF.library_gitinfo rescue '?'
+require 'whimsy/asf'
 
 ldap = ASF.init_ldap
 exit 1 unless ldap
@@ -48,20 +46,4 @@
   committees: entries,
 }
 
-# format as JSON
-results = JSON.pretty_generate(info)
-
-# parse arguments for output file name
-if ARGV.length == 0 or ARGV.first == '-'
-  # write to STDOUT
-  puts results
-elsif not File.exist?(ARGV.first) or File.read(ARGV.first) != results
-  puts "git_info: #{GITINFO}"
-  out, err, rc = Open3.capture3('diff', '-u', ARGV.first, '-', stdin_data: results)
-  puts out if err.empty? and rc.exitstatus == 1
-
-  # replace file as contents have changed
-  File.write(ARGV.first, results)
-else
-  puts "git_info: #{GITINFO}"
-end
+public_json_output(info)
diff --git a/www/roster/public_ldap_committers.rb b/www/roster/public_ldap_committers.rb
index da9401a..628d63b 100644
--- a/www/roster/public_ldap_committers.rb
+++ b/www/roster/public_ldap_committers.rb
@@ -20,9 +20,9 @@
 
 require 'bundler/setup'
 
-require 'whimsy/asf'
+require_relative 'public_json_common'
 
-GITINFO = ASF.library_gitinfo rescue '?'
+require 'whimsy/asf'
 
 ldap = ASF.init_ldap
 exit 1 unless ldap
@@ -67,17 +67,4 @@ def makeEntry(hash, e)
   non_committers: peo,
 }
 
-# format as JSON
-results = JSON.pretty_generate(info)
-
-# parse arguments for output file name
-if ARGV.length == 0 or ARGV.first == '-'
-  # write to STDOUT
-  puts results
-elsif not File.exist?(ARGV.first) or File.read(ARGV.first) != results
-  puts "git_info: #{GITINFO}"
-  # replace file as contents have changed
-  File.write(ARGV.first, results)
-else
-  puts "git_info: #{GITINFO}"
-end
+public_json_output(info)
diff --git a/www/roster/public_ldap_groups.rb b/www/roster/public_ldap_groups.rb
index b533ae7..1ad83f4 100644
--- a/www/roster/public_ldap_groups.rb
+++ b/www/roster/public_ldap_groups.rb
@@ -16,9 +16,9 @@
 
 require 'bundler/setup'
 
-require 'whimsy/asf'
+require_relative 'public_json_common'
 
-GITINFO = ASF.library_gitinfo rescue '?'
+require 'whimsy/asf'
 
 ldap = ASF.init_ldap
 exit 1 unless ldap
@@ -47,17 +47,4 @@
   groups: entries,
 }
 
-# format as JSON
-results = JSON.pretty_generate(info)
-
-# parse arguments for output file name
-if ARGV.length == 0 or ARGV.first == '-'
-  # write to STDOUT
-  puts results
-elsif not File.exist?(ARGV.first) or File.read(ARGV.first) != results
-  puts "git_info: #{GITINFO}"
-  # replace file as contents have changed
-  File.write(ARGV.first, results)
-else
-  puts "git_info: #{GITINFO}"
-end
+public_json_output(info)

Mime
View raw message