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 f74e01e4 Allow TLPs to be resumed in committee-info.yaml
f74e01e4 is described below
commit f74e01e4586eddaa7a0dfad4475bb78e93c1e583
Author: Sebb <[email protected]>
AuthorDate: Wed Aug 3 12:33:00 2022 +0100
Allow TLPs to be resumed in committee-info.yaml
---
lib/spec/lib/committee_spec.rb | 49 ++++++++++++++++++++++++++++++++++
lib/test/svn/board/committee-info.yaml | 12 +++++++++
lib/whimsy/asf/committee.rb | 24 ++++++++++++-----
3 files changed, 78 insertions(+), 7 deletions(-)
diff --git a/lib/spec/lib/committee_spec.rb b/lib/spec/lib/committee_spec.rb
index b31a567c..169baf38 100644
--- a/lib/spec/lib/committee_spec.rb
+++ b/lib/spec/lib/committee_spec.rb
@@ -108,6 +108,55 @@ describe ASF::Committee do
expect(abc[:description]).to eq(desc)
expect(abc[:established]).to eq(established_value)
end
+
+ it "resume should succeed for 'avalon' (no current diary)" do
+ pmc = 'avalon'
+ original = YAML.safe_load(input, permitted_classes: [Symbol])[:tlps][pmc]
+ expect(original[:retired]).not_to be_nil
+ expect(original[:diary]).to be_nil
+ date_resumed = Time.now
+ resumed_value = date_resumed.strftime('%Y-%m')
+ res = nil
+ expect { res = ASF::Committee.appendtlpmetadata(input, pmc, 'unused',
date_resumed) }.to output("").to_stderr
+ expect(res).not_to equal(input)
+ tlps = YAML.safe_load(res, permitted_classes: [Symbol])[:tlps]
+ updated = tlps[pmc]
+ expect(updated.class).to eq(Hash)
+ expect(updated[:site]).to eq(original[:site])
+ expect(updated[:retired]).to be_nil # no longer retired
+ expect(updated[:description]).to eq(original[:description])
+ expect(updated[:established]).to eq(original[:established])
+ diary = [
+ {established: original[:established]},
+ {retired: original[:retired]},
+ {resumed: resumed_value}
+ ]
+ expect(updated[:diary]).to eq(diary)
+ end
+
+ it "resume should succeed for 'jakarta' (has diary)" do
+ pmc = 'jakarta'
+ original = YAML.safe_load(input, permitted_classes: [Symbol])[:tlps][pmc]
+ expect(original[:retired]).not_to be_nil
+ expect(original[:diary]).not_to be_nil
+ date_resumed = Time.now
+ resumed_value = date_resumed.strftime('%Y-%m')
+ res = nil
+ expect { res = ASF::Committee.appendtlpmetadata(input, pmc, 'unused',
date_resumed) }.to output("").to_stderr
+ expect(res).not_to equal(input)
+ tlps = YAML.safe_load(res, permitted_classes: [Symbol])[:tlps]
+ updated = tlps[pmc]
+ expect(updated.class).to eq(Hash)
+ expect(updated[:site]).to eq(original[:site])
+ expect(updated[:retired]).to be_nil # no longer retired
+ expect(updated[:description]).to eq(original[:description])
+ expect(updated[:established]).to eq(original[:established])
+ diary = [
+ {retired: original[:retired]},
+ {resumed: resumed_value}
+ ]
+ expect(updated[:diary]).to eq(diary)
+ end
end
describe "ASF::ASF::Committee.record_termination" do
diff --git a/lib/test/svn/board/committee-info.yaml
b/lib/test/svn/board/committee-info.yaml
index c08fa1a3..c228af5b 100644
--- a/lib/test/svn/board/committee-info.yaml
+++ b/lib/test/svn/board/committee-info.yaml
@@ -10,8 +10,20 @@
:description: Resources to help people become involved with Apache projects
:tlps:
+ avalon:
+ :established: 2002-11
+ :retired: 2004-11
+ :name: Avalon
+ :description: Java software for component and container programming
httpd:
:site: http://httpd.apache.org/
:description: Apache Web Server (httpd)
+ jakarta:
+ :established: 1999-09
+ :retired: 2011-12
+ :name: Jakarta
+ :description: Diverse set of popular open source Java solutions
+ :comment: Diary is needed for unit testing
+ :diary: []
...
# ends
\ No newline at end of file
diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index 378c09f8..e6271849 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -668,16 +668,26 @@ module ASF
def self.appendtlpmetadata(input, committee, description, date_established)
YamlFile.replace_section(input, :tlps) do |section, yaml|
output = section # default no change
- if yaml[:cttees][committee]
+ if yaml[:cttees][committee] && !yaml[:cttees][committee][:retired]
Wunderbar.warn "Entry for '#{committee}' already exists under
:cttees"
- elsif yaml[:tlps][committee]
+ elsif yaml[:tlps][committee] && !yaml[:tlps][committee][:retired]
Wunderbar.warn "Entry for '#{committee}' already exists under :tlps"
else
- section[committee] = {
- site: "http://#{committee}.apache.org",
- description: description,
- established: date_established.strftime('%Y-%m'),
- }
+ if section[committee] # already exists; must be retired
+ diary = section[committee][:diary]
+ if !diary
+ diary = section[committee][:diary] = []
+ diary << {established: section[committee][:established]}
+ end
+ diary << {retired: section[committee].delete(:retired)}
+ diary << {resumed: date_established.strftime('%Y-%m')}
+ else
+ section[committee] = {
+ site: "http://#{committee}.apache.org",
+ description: description,
+ established: date_established.strftime('%Y-%m'),
+ }
+ end
output = section.sort.to_h
end
output