way_of_working 2.1.0 → 2.2.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/CLAUDE.md +48 -0
  4. data/CODE_OF_CONDUCT.md +55 -104
  5. data/CONTRIBUTING.md +4 -4
  6. data/README.md +68 -24
  7. data/exe/way_of_working +6 -1
  8. data/lib/way_of_working/audit/github/auditor.rb +3 -0
  9. data/lib/way_of_working/audit/github/generators/exec.rb +63 -12
  10. data/lib/way_of_working/audit/github/rules/base.rb +29 -4
  11. data/lib/way_of_working/audit/github/rules/registry.rb +8 -0
  12. data/lib/way_of_working/changelog/keepachangelog/generators/init.rb +1 -1
  13. data/lib/way_of_working/changelog/keepachangelog/github_audit_rule.rb +1 -1
  14. data/lib/way_of_working/changelog/keepachangelog.rb +2 -6
  15. data/lib/way_of_working/cli.rb +13 -0
  16. data/lib/way_of_working/code_of_conduct/contributor_covenant/generators/init.rb +33 -3
  17. data/lib/way_of_working/code_of_conduct/contributor_covenant/github_audit_rule.rb +3 -2
  18. data/lib/way_of_working/code_of_conduct/contributor_covenant/templates/CODE_OF_CONDUCT.md.tt +55 -105
  19. data/lib/way_of_working/code_of_conduct/contributor_covenant/templates/docs/way_of_working/code-of-conduct.md +21 -20
  20. data/lib/way_of_working/code_of_conduct/contributor_covenant.rb +3 -7
  21. data/lib/way_of_working/completion.rb +60 -0
  22. data/lib/way_of_working/config.rb +45 -0
  23. data/lib/way_of_working/decision_record/madr/github_audit_rule.rb +0 -13
  24. data/lib/way_of_working/decision_record/madr/templates/docs/way_of_working/decision-records.md +1 -1
  25. data/lib/way_of_working/decision_record/madr.rb +2 -6
  26. data/lib/way_of_working/inclusive_language/alex/generators/init.rb +25 -0
  27. data/lib/way_of_working/inclusive_language/alex/github_audit_rule.rb +12 -5
  28. data/lib/way_of_working/inclusive_language/alex/templates/.github/workflows/inclusive-language.yml +1 -1
  29. data/lib/way_of_working/inclusive_language/alex.rb +4 -6
  30. data/lib/way_of_working/pull_request_template/hdi.rb +2 -6
  31. data/lib/way_of_working/readme_badge/generators/init.rb +11 -1
  32. data/lib/way_of_working/readme_badge.rb +2 -6
  33. data/lib/way_of_working/sub_commands/base.rb +12 -0
  34. data/lib/way_of_working/sub_commands/config.rb +25 -0
  35. data/lib/way_of_working/sub_commands/init.rb +1 -1
  36. data/lib/way_of_working/version.rb +1 -1
  37. data/lib/way_of_working/versioning/semver/github_audit_rule.rb +0 -11
  38. data/lib/way_of_working/versioning/semver.rb +2 -6
  39. data/lib/way_of_working.rb +18 -11
  40. data/way_of_working.gemspec +2 -1
  41. metadata +23 -9
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # ponytail: only what Base itself needs. Every command loads this via readme_badge, so
4
+ # Octokit and the rest of ActiveSupport wait for the auditor (auditor.rb).
3
5
  require 'active_support'
4
- require 'active_support/core_ext'
6
+ require 'active_support/core_ext/string/inflections'
5
7
  require 'base64'
6
- require 'octokit'
7
- require_relative 'registry'
8
8
 
9
9
  module WayOfWorking
10
10
  module Audit
@@ -46,7 +46,8 @@ module WayOfWorking
46
46
  end
47
47
  end
48
48
 
49
- def validate
49
+ # Renaming to a predicate would break the plugin rule API (MAJOR version bump)
50
+ def validate # rubocop:disable Naming/PredicateMethod
50
51
  $stdout.puts "Rule#valid? has been deprecated, use \"validate\" in #{self.class.name}"
51
52
  valid?
52
53
  end
@@ -55,6 +56,15 @@ module WayOfWorking
55
56
  [:way_of_working]
56
57
  end
57
58
 
59
+ # The ID `audit_github --rule` accepts. Defaults to the feature path, e.g.
60
+ # "versioning/semver". Plugins may override it to give their rules shorter IDs.
61
+ # Part of the plugin API: changing a rule's ID is a breaking change.
62
+ def self.rule_id
63
+ return unless name
64
+
65
+ name.delete_prefix('WayOfWorking::').delete_suffix('::GithubAuditRule').underscore
66
+ end
67
+
58
68
  def tags
59
69
  self.class.tags
60
70
  end
@@ -68,6 +78,17 @@ module WayOfWorking
68
78
  nil
69
79
  end
70
80
 
81
+ def repo_file_contains_source_file?(path)
82
+ repo_file_contains?(path, File.read(self.class.source_root.join(path)))
83
+ end
84
+
85
+ def repo_file_contains?(path, text)
86
+ remote_content = repo_file_contents(path)
87
+ return false if remote_content.nil?
88
+
89
+ remote_content.include?(text)
90
+ end
91
+
71
92
  # This method returns the content of the README file
72
93
  def readme_content
73
94
  @readme_content ||=
@@ -89,3 +110,7 @@ module WayOfWorking
89
110
  end
90
111
  end
91
112
  end
113
+
114
+ # Required after Base is defined: registry -> unknown -> Base would otherwise be
115
+ # a circular require when a rule file loads base first.
116
+ require_relative 'registry'
@@ -13,10 +13,18 @@ module WayOfWorking
13
13
 
14
14
  def register(klass, rule_name)
15
15
  @rules ||= {}
16
+ id = id_for(klass, rule_name)
17
+ clash = @rules.find { |name, other| name != rule_name && id_for(other, name) == id }
18
+ raise ArgumentError, "Audit rule ID #{id.inspect} is already used by #{clash.last}" if clash
16
19
 
17
20
  @rules[rule_name] = klass
18
21
  end
19
22
 
23
+ # The rule's `rule_id`, or its registered name for anonymous classes (e.g. in tests)
24
+ def id_for(klass, rule_name)
25
+ klass.rule_id || rule_name.to_s
26
+ end
27
+
20
28
  def unregister(*rule_names)
21
29
  rule_names.each do |rule_name|
22
30
  @rules.delete(rule_name)
@@ -92,7 +92,7 @@ module WayOfWorking
92
92
  end
93
93
 
94
94
  def change_text(type, description, likely = false)
95
- text = "### #{type}\n\n- TODO: #{description}"
95
+ text = "### #{type}\n\n- TODO: #{description}" # DevSkim: ignore DS176209 -- placeholder, not a real todo
96
96
  text += ' (if any)' unless likely
97
97
  text += "\n\n"
98
98
  text
@@ -6,7 +6,7 @@ module WayOfWorking
6
6
  module Changelog
7
7
  # The namespace for this plugin
8
8
  module Keepachangelog
9
- # This rule checks for the Pull Request template.
9
+ # This rule checks for a Keep a Changelog CHANGELOG.md.
10
10
  class GithubAuditRule < ::WayOfWorking::Audit::Github::Rules::Base
11
11
  def validate
12
12
  @errors << 'No Keep a Changelog CHANGELOG.md found' unless keep_a_changelog_found?
@@ -2,12 +2,8 @@
2
2
 
3
3
  require_relative 'keepachangelog/generators/init'
4
4
 
5
- # If way_of_working-audit-github is used we can add a rule
6
- begin
7
- require 'way_of_working/audit/github/rules/registry'
8
- require_relative 'keepachangelog/github_audit_rule'
9
- rescue LoadError # rubocop:disable Lint/SuppressedException
10
- end
5
+ # Register the GitHub audit rule (the registry is bundled with this gem)
6
+ require_relative 'keepachangelog/github_audit_rule'
11
7
 
12
8
  module WayOfWorking
13
9
  module Changelog
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'thor'
4
4
 
5
+ require_relative 'sub_commands/config'
5
6
  require_relative 'sub_commands/exec'
6
7
  require_relative 'sub_commands/init'
7
8
  require_relative 'sub_commands/new'
@@ -9,6 +10,18 @@ require_relative 'sub_commands/new'
9
10
  module WayOfWorking
10
11
  # This class defines the top level interface
11
12
  class Cli < Thor
13
+ def self.exit_on_failure?
14
+ true
15
+ end
16
+
17
+ desc 'completion SHELL', 'Prints the bash or zsh completion script, e.g. eval "$(way_of_working completion zsh)"'
18
+ def completion(shell)
19
+ puts Completion.script(shell)
20
+ end
21
+
22
+ desc 'config [ACTION]', 'Reads or writes values in the way_of_working config file'
23
+ subcommand 'config', ::WayOfWorking::SubCommands::Config
24
+
12
25
  desc 'exec [COMPONENT]', 'Executes (runs) the specific component'
13
26
  subcommand 'exec', ::WayOfWorking::SubCommands::Exec
14
27
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'way_of_working/paths'
4
+ require 'way_of_working/config'
4
5
 
5
6
  module WayOfWorking
6
7
  module CodeOfConduct
@@ -10,28 +11,57 @@ module WayOfWorking
10
11
  class Init < Thor::Group
11
12
  include Thor::Actions
12
13
 
14
+ CONTACT_METHOD_CONFIG_KEY = 'code_of_conduct.contact_method'
15
+
13
16
  source_root WayOfWorking.root.join('lib', 'way_of_working', 'code_of_conduct', 'contributor_covenant',
14
17
  'templates')
15
18
 
16
- class_option :contact_method, required: true
19
+ class_option :contact_method
17
20
 
18
21
  # Use this method to update the cached template when required
19
22
  # def download_and_save_code_of_conduct_template
20
23
  # code_of_conduct_file = 'lib/way_of_working/templates/CODE_OF_CONDUCT.md.tt'
21
24
 
22
- # get 'https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md',
25
+ # get 'https://www.contributor-covenant.org/version/3/0/code_of_conduct/code_of_conduct.md',
23
26
  # code_of_conduct_file
24
27
  # gsub_file code_of_conduct_file, '[INSERT CONTACT METHOD]',
25
- # "<<%= options['contact_method'] %>>"
28
+ # "<<%= contact_method %>>"
26
29
  # end
27
30
 
28
31
  def add_code_of_conduct_to_project
32
+ contact_method
33
+ offer_to_remember_contact_method
29
34
  template 'CODE_OF_CONDUCT.md'
30
35
  end
31
36
 
32
37
  def add_way_of_working_documentation
33
38
  copy_file 'docs/way_of_working/code-of-conduct.md'
34
39
  end
40
+
41
+ private
42
+
43
+ # The contact method comes from --contact-method, falling back to the value
44
+ # stored under CONTACT_METHOD_CONFIG_KEY in way_of_working's config file (see
45
+ # `way_of_working config`), read fresh on every call rather than cached in the
46
+ # class_option default so config changes are picked up within a single process
47
+ # (e.g. across tests, or repeated invocations in bin/console).
48
+ def contact_method
49
+ @contact_method ||= options['contact_method'] || ::WayOfWorking::Config.get(CONTACT_METHOD_CONFIG_KEY)
50
+ @contact_method ||= raise(Thor::Error, 'No contact method provided. Pass --contact-method, or set a ' \
51
+ 'default with `way_of_working config set ' \
52
+ "#{CONTACT_METHOD_CONFIG_KEY} you@example.com`")
53
+ end
54
+
55
+ def offer_to_remember_contact_method
56
+ return unless options['contact_method']
57
+ return if options['contact_method'] == ::WayOfWorking::Config.get(CONTACT_METHOD_CONFIG_KEY)
58
+
59
+ question = "Remember '#{options['contact_method']}' as your code of conduct contact method " \
60
+ 'for next time? (y/n)'
61
+ return unless yes?(question)
62
+
63
+ ::WayOfWorking::Config.set(CONTACT_METHOD_CONFIG_KEY, options['contact_method'])
64
+ end
35
65
  end
36
66
  end
37
67
  end
@@ -6,7 +6,7 @@ module WayOfWorking
6
6
  module CodeOfConduct
7
7
  # The namespace for this plugin
8
8
  module ContributorCovenant
9
- # This rule checks for the MegaLinter workflow action and README badge.
9
+ # This rule checks for a Contributor Covenant code of conduct.
10
10
  class GithubAuditRule < ::WayOfWorking::Audit::Github::Rules::Base
11
11
  def validate
12
12
  @errors << 'No Contributor Covenant code of conduct found' unless code_of_conduct?
@@ -18,7 +18,8 @@ module WayOfWorking
18
18
  response = @client.contents(@repo_name, path: 'CODE_OF_CONDUCT.md')
19
19
  decoded_content = Base64.decode64(response.content)
20
20
 
21
- decoded_content.include?('# Contributor Covenant Code of Conduct')
21
+ # Only v3 is accepted; previous versions (e.g. v2.1, headed "Contributor Covenant Code of Conduct") fail
22
+ decoded_content.match?(/^# Contributor Covenant 3(\.\d+)* Code of Conduct$/)
22
23
  rescue Octokit::NotFound
23
24
  false
24
25
  end
@@ -1,133 +1,83 @@
1
- # Contributor Covenant Code of Conduct
1
+ # Contributor Covenant 3.0 Code of Conduct
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, caste, color, religion, or sexual
10
- identity and orientation.
5
+ We pledge to make our community welcoming, safe, and equitable for all.
11
6
 
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
7
+ We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant.
14
8
 
15
- ## Our Standards
9
+ ## Encouraged Behaviors
16
10
 
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
11
+ While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language.
19
12
 
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not only for us as individuals, but for the overall
26
- community
13
+ With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:
27
14
 
28
- Examples of unacceptable behavior include:
15
+ 1. Respecting the **purpose of our community**, our activities, and our ways of gathering.
16
+ 2. Engaging **kindly and honestly** with others.
17
+ 3. Respecting **different viewpoints** and experiences.
18
+ 4. **Taking responsibility** for our actions and contributions.
19
+ 5. Gracefully giving and accepting **constructive feedback**.
20
+ 6. Committing to **repairing harm** when it occurs.
21
+ 7. Behaving in other ways that promote and sustain the **well-being of our community**.
29
22
 
30
- * The use of sexualized language or imagery, and sexual attention or advances of
31
- any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email address,
35
- without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
23
+ ## Restricted Behaviors
38
24
 
39
- ## Enforcement Responsibilities
25
+ We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.
40
26
 
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
27
+ 1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop.
28
+ 2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people.
29
+ 3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits.
30
+ 4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community.
31
+ 5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission.
32
+ 6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group.
33
+ 7. Behaving in other ways that **threaten the well-being** of our community.
45
34
 
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
35
+ ### Other Restrictions
50
36
 
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official e-mail address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- <<%= options['contact_method'] %>>.
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
37
+ 1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions.
38
+ 2. **Failing to credit sources.** Not properly crediting the sources of content you contribute.
39
+ 3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community.
40
+ 4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors.
70
41
 
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
42
+ ## Reporting an Issue
73
43
 
74
- ### 1. Correction
44
+ Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm.
75
45
 
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
46
+ When an incident does occur, it is important to report it promptly. To report a possible violation, contact the Community Moderators at <<%= contact_method %>>.
78
47
 
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
48
+ Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution.
82
49
 
83
- ### 2. Warning
50
+ ## Addressing and Repairing Harm
84
51
 
85
- **Community Impact**: A violation through a single incident or series of
86
- actions.
52
+ If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped.
87
53
 
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or permanent
93
- ban.
54
+ 1) Warning
55
+ 1) Event: A violation involving a single incident or series of incidents.
56
+ 2) Consequence: A private, written warning from the Community Moderators.
57
+ 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations.
58
+ 2) Temporarily Limited Activities
59
+ 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation.
60
+ 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members.
61
+ 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over.
62
+ 3) Temporary Suspension
63
+ 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation.
64
+ 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions.
65
+ 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted.
66
+ 4) Permanent Ban
67
+ 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member.
68
+ 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior.
69
+ 3) Repair: There is no possible repair in cases of this severity.
94
70
 
95
- ### 3. Temporary Ban
71
+ This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community.
96
72
 
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
73
+ ## Scope
111
74
 
112
- **Consequence**: A permanent ban from any sort of public interaction within the
113
- community.
75
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
114
76
 
115
77
  ## Attribution
116
78
 
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.1, available at
119
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
-
121
- Community Impact Guidelines were inspired by
122
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
-
124
- For answers to common questions about this code of conduct, see the FAQ at
125
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
- [https://www.contributor-covenant.org/translations][translations].
79
+ This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).
127
80
 
128
- [homepage]: https://www.contributor-covenant.org
129
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
- [Mozilla CoC]: https://github.com/mozilla/diversity
131
- [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations
81
+ Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)
133
82
 
83
+ For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion).
@@ -7,24 +7,24 @@ enforcement: manual
7
7
 
8
8
  ## Purpose
9
9
 
10
- We adopt the [Contributor Covenant v2.1][covenant] to establish clear behavioural expectations, create safe inclusive environments, prevent discrimination/harassment, and reduce conflicts.
10
+ We adopt the [Contributor Covenant v3][covenant] to establish clear behavioural expectations, create safe inclusive environments, prevent discrimination/harassment, and reduce conflicts.
11
11
 
12
12
  {: .important }
13
- Adoption requires more than adding `CODE_OF_CONDUCT.md`. Please read the [enforcement guidelines][enforcement] and discuss with your team.
13
+ Adoption requires more than adding `CODE_OF_CONDUCT.md`. Please read the [Addressing and Repairing Harm][enforcement] section and discuss with your team.
14
14
 
15
15
  ## Scope
16
16
 
17
17
  Applies to all project spaces and community interactions.
18
18
 
19
- **Promotes:** Respectful communication, collaboration, inclusive language, professional conduct
19
+ **Promotes:** Respectful communication, collaboration, inclusive language, professional conduct, repairing harm
20
20
 
21
- **Prevents:** Discrimination, harassment, unprofessional behaviour
21
+ **Prevents:** Harassment, character attacks, stereotyping/discrimination, sexualization, violating confidentiality, endangerment
22
22
 
23
23
  ## Requirements
24
24
 
25
25
  1. Contact method for reports (email address)
26
- 2. Enforcement responsibilities and process
27
- 3. Consequences framework
26
+ 2. Community Moderators responsible for investigation and enforcement
27
+ 3. Enforcement ladder (consequences and repair)
28
28
 
29
29
  {: .note }
30
30
  Use HDI Code of Conduct email address as contact method.
@@ -41,38 +41,39 @@ Command creates `CODE_OF_CONDUCT.md` in repository root.
41
41
 
42
42
  **Post-setup:**
43
43
 
44
- 1. Review enforcement guidelines with team
45
- 2. Assign enforcement responsibilities
44
+ 1. Review the enforcement ladder with team (edit it if your community has its own established process)
45
+ 2. Assign Community Moderators
46
46
  3. Communicate adoption to contributors
47
47
  4. Link from README and CONTRIBUTING
48
48
 
49
49
  **Enforcement process:**
50
- Report → Review → Investigate → Apply consequence → Document
50
+ Report → Investigate → Apply consequence → Repair → Document
51
51
 
52
52
  ## Enforcement
53
53
 
54
- **Consequences:**
54
+ **Enforcement ladder:**
55
55
 
56
- - **Warning:** First offense, minor issue
57
- - **Temporary ban:** Sustained inappropriate behavior
58
- - **Permanent ban:** Severe violations or repeat offenses
56
+ - **Warning:** Single incident or series of incidents
57
+ - **Temporarily limited activities:** Repeated violation after a warning, or a more serious first violation
58
+ - **Temporary suspension:** Pattern of repeated violation, or a single serious violation
59
+ - **Permanent ban:** Violations other steps have failed to resolve, or too serious to keep the community safe
59
60
 
60
61
  **Requirements:**
61
62
 
62
- - Consistent enforcement by leadership
63
+ - Consistent enforcement by Community Moderators
63
64
  - Confidential handling, 5-day response
64
65
  - Document incidents, annual review
65
66
 
66
67
  ## Examples
67
68
 
68
- **Acceptable:** Welcoming language, respect differing views, accept criticism, focus on community benefit
69
+ **Encouraged:** Respecting community purpose, engaging kindly and honestly, respecting different viewpoints, taking responsibility, constructive feedback, repairing harm
69
70
 
70
- **Unacceptable:** Sexualized content, trolling/insults, harassment, publishing private info, unprofessional conduct
71
+ **Restricted:** Harassment, character attacks, stereotyping or discrimination, sexualization, violating confidentiality, endangerment, misleading identity, failing to credit sources
71
72
 
72
73
  ## Resources
73
74
 
74
- - [Contributor Covenant v2.1][covenant]
75
- - [Enforcement Guidelines][enforcement]
75
+ - [Contributor Covenant v3][covenant]
76
+ - [Addressing and Repairing Harm][enforcement]
76
77
 
77
- [covenant]: https://www.contributor-covenant.org/version/2/1/code_of_conduct/
78
- [enforcement]: https://www.contributor-covenant.org/version/2/1/code_of_conduct/#enforcement-guidelines
78
+ [covenant]: https://www.contributor-covenant.org/version/3/0/code_of_conduct/
79
+ [enforcement]: https://www.contributor-covenant.org/version/3/0/code_of_conduct/#addressing-and-repairing-harm
@@ -2,12 +2,8 @@
2
2
 
3
3
  require_relative 'contributor_covenant/generators/init'
4
4
 
5
- # If way_of_working-audit-github is used we can add a rule
6
- begin
7
- require 'way_of_working/audit/github/rules/registry'
8
- require_relative 'contributor_covenant/github_audit_rule'
9
- rescue LoadError # rubocop:disable Lint/SuppressedException
10
- end
5
+ # Register the GitHub audit rule (the registry is bundled with this gem)
6
+ require_relative 'contributor_covenant/github_audit_rule'
11
7
 
12
8
  module WayOfWorking
13
9
  module CodeOfConduct
@@ -23,7 +19,7 @@ module WayOfWorking
23
19
  'code_of_conduct --contact-method [CONTACT METHOD]',
24
20
  <<~LONGDESC)
25
21
  Description:
26
- This adds the Contributor Covenant v2.1 code of conduct to the project
22
+ This adds the Contributor Covenant v3 code of conduct to the project
27
23
 
28
24
  Example:
29
25
  way_of_working init code_of_conduct --contact-method "foo@bar.com"
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WayOfWorking
4
+ # Shell completion. The shell scripts are thin: on every Tab they call
5
+ # `way_of_working __complete <words>`, which walks the live Thor command tree,
6
+ # so commands from plugins and opt-in features always show up.
7
+ module Completion
8
+ SCRIPTS = {
9
+ 'bash' => <<~'BASH',
10
+ _way_of_working() {
11
+ local IFS=$'\n'
12
+ COMPREPLY=($(way_of_working __complete "${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
13
+ }
14
+ complete -F _way_of_working way_of_working
15
+ BASH
16
+ 'zsh' => <<~ZSH
17
+ _way_of_working() {
18
+ local -a candidates
19
+ candidates=(${(f)"$(way_of_working __complete "${(@)words[2,CURRENT]}" 2>/dev/null)"})
20
+ compadd -a candidates
21
+ }
22
+ compdef _way_of_working way_of_working
23
+ ZSH
24
+ }.freeze
25
+
26
+ def self.script(shell)
27
+ SCRIPTS.fetch(shell) { raise Thor::Error, "Unsupported shell #{shell.inspect}, use bash or zsh" }
28
+ end
29
+
30
+ # words: everything typed after `way_of_working`, the last being the word being completed.
31
+ # ponytail: completes command names and option switches only, not option values.
32
+ def self.candidates(words)
33
+ *typed, current = words
34
+ klass, command = resolve(typed)
35
+ return [] unless klass
36
+
37
+ names = if command
38
+ command.options.values.flat_map { |option| [option.switch_name, *option.aliases] }
39
+ else
40
+ klass.all_commands.reject { |_name, cmd| cmd.hidden? }.keys
41
+ end
42
+ names.select { |name| name.start_with?(current.to_s) }.sort
43
+ end
44
+
45
+ # Walks the typed words down the Thor tree to the innermost class and, once one
46
+ # is typed, its command. Returns nil for an unknown word.
47
+ def self.resolve(typed)
48
+ klass = Cli
49
+ typed.reject { |word| word.start_with?('-') }.each do |word|
50
+ unless klass.subcommand_classes.key?(word)
51
+ command = klass.all_commands[word]
52
+ return command && [klass, command]
53
+ end
54
+
55
+ klass = klass.subcommand_classes[word]
56
+ end
57
+ [klass, nil]
58
+ end
59
+ end
60
+ end