You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2023/04/30 12:45:39 UTC
[whimsy] branch master updated: Allow for different field offsets
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 1ea09584 Allow for different field offsets
1ea09584 is described below
commit 1ea09584ed8b61b56fe807b197ed5966730e4c6b
Author: Sebb <se...@apache.org>
AuthorDate: Sun Apr 30 13:45:32 2023 +0100
Allow for different field offsets
---
lib/whimsy/asf/committee.rb | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index e6271849..f2e89ae4 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -252,15 +252,24 @@ module ASF
# split block into lines
lines = block.strip.split("\n")
-
+ # get the first line and use that to calculate the offsets to use
+ # Note: this only affects new entries
+ sample = lines[1]
+ namelen = 26 # original
+ nameaddrlen = 59 # original
+ # N.B. 4 spaces are assumed at the start
+ if sample =~ %r{^ (\S.+) (<\S+?>\s+)\[}
+ namelen = $1.size
+ nameaddrlen = namelen + $2.size
+ end
# add or remove people
people.each do |person|
id = person.id
if action == 'add'
unless lines.any? {|line| line.include? "<#{...@apache.org>"}
- name = "#{person.public_name.ljust(26)} <#{...@apache.org>"
+ name = "#{person.public_name.ljust(namelen)} <#{...@apache.org>"
time = Time.new.gmtime.strftime('%Y-%m-%d')
- lines << " #{name.ljust(59)} [#{time}]"
+ lines << " #{name.ljust(nameaddrlen)} [#{time}]"
end
elsif action == 'remove'
lines.reject! {|line| line.include? "<#{...@apache.org>"}