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 2020/10/17 16:24:49 UTC

[whimsy] branch master updated: += record_termination method

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 3e6025e  += record_termination method
3e6025e is described below

commit 3e6025ec88e8a21088044df2774889d9a39af4fa
Author: Sebb <se...@apache.org>
AuthorDate: Sat Oct 17 17:24:40 2020 +0100

    += record_termination method
---
 lib/spec/lib/committee_spec.rb | 32 ++++++++++++++++++++++++++++++++
 lib/whimsy/asf/committee.rb    | 19 +++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/lib/spec/lib/committee_spec.rb b/lib/spec/lib/committee_spec.rb
index 149b8b5..9d8cfa2 100644
--- a/lib/spec/lib/committee_spec.rb
+++ b/lib/spec/lib/committee_spec.rb
@@ -91,4 +91,36 @@ describe ASF::Committee do
       expect(abc[:description]).to eq(desc)
     end
   end
+
+  describe "ASF::ASF::Committee.record_termination" do
+    cinfoy = File.join(ASF::SVN['board'], 'committee-info.yaml')
+    yyyymm = '2020-10'
+    data = File.read cinfoy
+    yaml = YAML.safe_load(data, [Symbol])
+    it "should contain Whimsy, but not retired" do
+      para = yaml[:tlps]['whimsy']
+      expect(para).not_to eql(nil)
+      expect(para[:retired]).to eql(nil)
+    end
+    it "should add retired tag to Whimsy" do
+      data = ASF::Committee.record_termination(data, 'whimsy', yyyymm)
+      yaml = YAML.safe_load(data, [Symbol])
+      para = yaml[:tlps]['whimsy']
+      expect(para).not_to eql(nil)
+      expect(para[:retired]).to eql(yyyymm)
+    end
+    yaml = YAML.safe_load(data, [Symbol])
+    pmc = 'xyzxyz' # must be downcased
+    it "should not contain XYZXYZ" do
+      para = yaml[:tlps][pmc]
+      expect(para).to eql(nil)
+    end
+    it "should now contain XYZXYZ" do
+      data = ASF::Committee.record_termination(data, pmc, yyyymm)
+      yaml = YAML.safe_load(data, [Symbol])
+      para = yaml[:tlps][pmc]
+      expect(para).not_to eql(nil)
+      expect(para[:retired]).to eql(yyyymm)
+    end
+  end
 end
diff --git a/lib/whimsy/asf/committee.rb b/lib/whimsy/asf/committee.rb
index 70fb8c1..785f153 100644
--- a/lib/whimsy/asf/committee.rb
+++ b/lib/whimsy/asf/committee.rb
@@ -270,6 +270,25 @@ module ASF
       contents
     end
 
+    # record termination date in committee-info.yml
+    # Params:
+    # - input: the contents of committee-info.yml
+    # - pmc: the pmc name
+    # - yyyymm: YYYY-MM retirement date
+    #  Returns: the updated contents
+    def self.record_termination(input, pmc, yyyymm)
+      YamlFile.replace_section(input, :tlps) do |section, yaml|
+        key = pmc.downcase.strip
+        key = yaml[:name2id][key] || key
+        if section[key]
+          section[key][:retired] = yyyymm
+        else
+          section[key] = {retired: yyyymm}
+        end
+        section.sort.to_h
+      end
+    end
+
     # remove committee from committee-info.txt
     def self.terminate(contents, pmc)
       ########################################################################