cleo_codeowners 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95dabb73fd9d44328c2c7baed5ffbf4f91996ef2bad026d2f79175b98ba252f9
4
- data.tar.gz: 4a65dca6d6efef99d01587612451b72293283a30aa0a99f3ada7f192b05added
3
+ metadata.gz: 3da6d91b323d359c5906252cef6cf83727342be78baca1dcf576f5d43ac01be7
4
+ data.tar.gz: d4092679171b3762a76ac338546cf31c02a0b158fb50eecb7d1c8d818ef9b239
5
5
  SHA512:
6
- metadata.gz: 55b1e75f9bfbf6affb08442adb631c5fb96ab8a7ac3a1a31a433fc44235f5875964a98d4d77038965cd7c20db7cf022c5a8989db3c7a1acdfe80f32a864c792a
7
- data.tar.gz: c69046a48d695beb1129a005fff5b87163b0cd4935fbb625017a123b1bc2f1ed291ee02d833cf6a2ee4ef0448d14a388a2f5324547cb7fb5fe79bfbe680b3f98
6
+ metadata.gz: 2c847488207f368367a95244a5cd025449961b1df3f8454658144898d552761463bf5d97c07018c1813ccb89e088a1360fa7d9c3614ac9368aa5aa3decedcf93
7
+ data.tar.gz: e2b9f252b9054559deb915e2f68ed6d526b4953438d5457ae6249cdd189daae688cc329ac3c37b8b52994efc81bffb06a889239f99b94e2981c0310847f556cf
data/README.md CHANGED
@@ -60,27 +60,35 @@ Create YAML files under `.cleo/codeowners/`.
60
60
  # .cleo/codeowners/features.yml
61
61
  features:
62
62
  session management:
63
+ session administration:
63
64
  session expiry:
64
65
  billing:
65
66
  ```
66
67
 
68
+ Child features inherit their parent's owners, or can override with their own.
69
+ An owner can be one or more teams.
70
+
67
71
  ```yaml
68
72
  # .cleo/codeowners/owners.yml
69
73
  owners:
74
+ session administration:
75
+ - operations
70
76
  session management: identity-platform
71
- billing: payments
77
+ billing:
78
+ - payments
79
+ - finance
72
80
  ```
73
81
 
74
- Child features inherit their parent owner unless they define one.
75
-
76
82
  ```yaml
77
83
  # .cleo/codeowners/files/session_management.yml
78
84
  files:
85
+ session administration:
86
+ - /app/controllers/admin/sessions/
87
+ session expiry:
88
+ - /app/services/session_expiry/
79
89
  session management:
80
90
  - /app/controllers/sessions/
81
91
  - /app/models/session.rb
82
- session expiry:
83
- - /app/services/session_expiry/
84
92
 
85
93
  # .cleo/codeowners/files/billing.yml
86
94
  files:
@@ -3,5 +3,5 @@
3
3
  ##
4
4
  # Root module for this gem
5
5
  module CleoCodeowners
6
- VERSION = '0.4.0'
6
+ VERSION = '0.5.0'
7
7
  end
@@ -1,6 +1,7 @@
1
1
  # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'active_support/core_ext/array/conversions'
4
5
  require 'pathname'
5
6
 
6
7
  module Codeowners
@@ -59,15 +60,18 @@ module Codeowners
59
60
  @files ||= definitions_file.file_config
60
61
  end
61
62
 
62
- def calculate_owners_and_output_in_human_format(features:, current_owner: nil, depth: 0)
63
+ def calculate_owners_and_output_in_human_format(features:, current_owners: [], depth: 0)
63
64
  return unless present?(features)
64
65
 
65
66
  features.sort_by(&:first).each do |feature, children|
66
67
  output(feature.upcase, depth:)
67
- owner = owners.fetch(feature, current_owner)
68
+ feature_owners = Array(
69
+ owners.fetch(feature, current_owners)
70
+ ).reject { |owner| blank?(owner) }
71
+
68
72
  feature_files = files[feature]
69
73
 
70
- if blank?(owner)
74
+ if feature_owners.empty?
71
75
  raise "Please assign an owner for #{feature} in owners.yaml!"
72
76
  elsif blank?(feature_files) && blank?(children)
73
77
  raise "Please assign files or child features to #{feature}, or remove it!"
@@ -75,20 +79,22 @@ module Codeowners
75
79
  all_features << feature
76
80
  end
77
81
 
78
- if owner == 'unowned'
82
+ long_names = feature_owners.map { |owner| Owner.new(owner).long_name }.uniq
83
+
84
+ if feature_owners == ['unowned']
79
85
  output('Currently unowned', depth:)
80
86
  else
81
- output("Currently owned by @meetcleo/#{owner}", depth:)
87
+ output("Currently owned by #{long_names.to_sentence}", depth:)
82
88
  end
83
89
 
84
90
  if present?(feature_files)
85
91
  feature_files.sort.uniq.each do |file|
86
- record_calculated_owner(file, Owner.new(owner).long_name)
87
- output("#{file} #{Owner.new(owner).long_name}", depth:, comment: false)
92
+ long_names.each { |long_name| record_calculated_owner(file, long_name) }
93
+ output("#{file} #{long_names.join(' ')}", depth:, comment: false)
88
94
  end
89
95
  end
90
96
 
91
- calculate_owners_and_output_in_human_format(features: children, current_owner: owner, depth: depth + 1)
97
+ calculate_owners_and_output_in_human_format(features: children, current_owners: feature_owners, depth: depth + 1)
92
98
  end
93
99
  end
94
100
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cleo_codeowners
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@agentAngelope"