Skip to content

Commit e8cf97a

Browse files
chore: update codeowners to latest version (#390)
* Restructure codeowners to reduce noise * Add fallback attribution * Remove extra bullet * Add EOL char back in Co-authored-by: Nick Taylor <[email protected]> --------- Co-authored-by: Nick Taylor <[email protected]>
1 parent 45c33f3 commit e8cf97a

File tree

2 files changed

+112
-42
lines changed

2 files changed

+112
-42
lines changed

.sauced.yaml

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ attribution:
1616
1717
zeucapua:
1818
19-
bekahhw:
20-
21-
2219
BekahHW:
2320
21+
2422
adiati98:
2523
26-

docs/tools/pizza-cli/codeowners.md

+111-38
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,108 @@ Key benefits of using the codeowners command:
2020

2121
To generate a CODEOWNERS file, you need to [install the Pizza CLI](pizza-cli.md) and run the `pizza generate codeowners` command in your terminal. However, before running the command, it's important to set up proper attribution for committers in a `.sauced.yaml` file.
2222

23-
## Creating a `.sauced.yaml` file
23+
## Configuration Generation
2424

25-
The `.sauced.yaml` file is necessary for mapping commit email addresses to GitHub usernames. However, it's important to be selective about who you include in this file. Not every contributor should be a codeowner.
25+
**New in v1.4.0, the `pizza generate config` command helps you create `.sauced.yaml` configuration files for your projects:**
26+
27+
```sh
28+
pizza generate config /path/to/local/git/repo
29+
```
30+
31+
**This command will:**
32+
- Iterate through the git ref-log
33+
- Inspect email signatures for commits
34+
- In interactive mode, ask you to attribute those users with GitHub handles
35+
36+
The resulting `.sauced.yaml` file can be used to attribute owners in a `CODEOWNERS` file during `pizza generate codeowners`.
37+
38+
### Configuration Generation Flags
39+
40+
- `-i, --interactive`: Enter interactive mode to attribute each email manually
41+
- `-o, --output-path string`: Set the directory for the output file
42+
- `-h, --help`: Display help for the command
43+
44+
### Configuration Generation Examples
45+
46+
1. Generate a config file in the current directory:
47+
```sh
48+
pizza generate config ./
49+
```
50+
51+
2. Generate a config file interactively:
52+
```sh
53+
pizza generate config ./ -i
54+
```
55+
56+
3. Generate a config file from the current directory and place resulting `.sauced.yaml` in a specific output directory:
57+
```sh
58+
pizza generate config ./ -o /path/to/directory
59+
```
60+
61+
### Creating a `.sauced.yaml` File Manually
62+
63+
If you prefer to create the `.sauced.yaml` file manually, you can do so by following these steps:
2664

2765
<details>
28-
<summary>Selecting appropriate codeowners</summary>
66+
<summary>Selecting appropriate codeowners</summary>
2967

30-
When deciding who to include in your `.sauced.yaml` file, consider the following:
68+
When deciding who to include in your `.sauced.yaml` file, consider the following:
3169

32-
1. **Team members**: Include active members of your organization who are responsible for maintaining the codebase.
70+
1. **Team members**: Include active members of your organization who are responsible for maintaining the codebase.
3371

34-
2. **Expertise**: Prioritize individuals with deep knowledge of specific areas of the codebase.
72+
2. **Expertise**: Prioritize individuals with deep knowledge of specific areas of the codebase.
3573

36-
3. **GitHub team members**: Include members of the GitHub teams associated with the repository.
74+
3. **GitHub team members**: Include members of the GitHub teams associated with the repository.
3775

38-
4. **Long-term contributors**: Consider long-standing contributors who have demonstrated commitment to the project.
76+
4. **Long-term contributors**: Consider long-standing contributors who have demonstrated commitment to the project.
3977

40-
:::tip
78+
:::tip
4179

42-
Be cautious about including external contributors. Only include those who have been vetted and are trusted to review and approve changes.
80+
Be cautious about including external contributors. Only include those who have been vetted and are trusted to review and approve changes.
4381

44-
:::
82+
:::
4583

46-
Codeowners will be automatically requested for review on pull requests that modify code they own.
47-
</details>
84+
Codeowners will be automatically requested for review on pull requests that modify code they own.
4885

49-
### Tips for identifying potential codeowners
86+
<details>
87+
<summary>Tips for identifying potential codeowners</summary>
5088

51-
1. Review GitHub team memberships:
52-
```bash
53-
gh api /orgs/{org}/teams/{team}/members --jq '.[].login'
54-
```
55-
Replace `{org}` with your organization name and `{team}` with the team name.
89+
1. Review GitHub team memberships:
90+
```bash
91+
gh api /orgs/{org}/teams/{team}/members --jq '.[].login'
92+
```
93+
Replace `{org}` with your organization name and `{team}` with the team name.
5694

57-
3. Review recent active contributors:
58-
```bash
59-
git log --since='6 months ago' --pretty=format:'%an' | sort | uniq -c | sort -nr
60-
```
61-
This lists active contributors in the last 6 months.
95+
3. Review recent active contributors:
96+
```bash
97+
git log --since='6 months ago' --pretty=format:'%an' | sort | uniq -c | sort -nr
98+
```
99+
This lists active contributors in the last 6 months.
100+
</details>
62101

63-
### Mapping GitHub usernames to email addresses
102+
<details>
103+
<summary>Mapping GitHub usernames to email addresses</summary>
64104

65-
Mapping GitHub usernames to their corresponding email addresses is necessary for creating an accurate `.sauced.yaml` file. For contributors to your repository, you can use `git log` to find their email addresses:
105+
Mapping GitHub usernames to their corresponding email addresses is necessary for creating an accurate `.sauced.yaml` file. For contributors to your repository, you can use `git log` to find their email addresses:
66106

67-
```bash
68-
git log --author="GitHub_Username" --format='%ae' | sort -u
69-
```
107+
```bash
108+
git log --author="GitHub_Username" --format='%ae' | sort -u
109+
```
70110

71-
Replace `GitHub_Username` with the actual GitHub username. This command will show all email addresses used by that user in their commits to your repository.
111+
Replace `GitHub_Username` with the actual GitHub username. This command will show all email addresses used by that user in their commits to your repository.
72112

73-
Alternatively, you can run the following command to get a list of your contributors' email addresses:
113+
Alternatively, you can run the following command to get a list of your contributors' email addresses:
74114

75-
```bash
76-
git log --format='%ae' | sort -u
77-
```
115+
```bash
116+
git log --format='%ae' | sort -u
117+
```
118+
</details>
78119

79-
## Creating the `.sauced.yaml` file
120+
</details>
80121

81-
After identifying appropriate codeowners, create the `.sauced.yaml` file in your repository's root directory with the following structure:
122+
## Attribution Configuration
123+
124+
After identifying appropriate codeowners, the `.sauced.yaml` file should use the following structure:
82125

83126
```yaml
84127
attribution:
@@ -91,7 +134,38 @@ After identifying appropriate codeowners, create the `.sauced.yaml` file in your
91134
92135
Only include the GitHub usernames and email addresses of the individuals you've identified as appropriate codeowners based on the considerations mentioned above.
93136
94-
## Pizza CLI Codeowners Command
137+
### Attribution Fallback
138+
139+
There are cases where there may not be a codeowner derived from the range of commits being inspected. To handle this, you can include an `attribution-fallback` key in your config:
140+
141+
```yaml
142+
attribution:
143+
jpmcb:
144+
145+
brandonroberts:
146+
147+
attribution-fallback:
148+
- open-sauced/engineering
149+
```
150+
151+
This field in the config can be used to attribute files that don't have an active attribution.
152+
153+
Without fallback, the codeowners generation might create a CODEOWNERS file like this:
154+
155+
```codeowners
156+
/file/with/codeowner @jpmcb
157+
/file/without/codeowner
158+
```
159+
160+
**With the fallback configured, it would generate:**
161+
162+
```codeowners
163+
/file/with/codeowner @jpmcb
164+
/file/without/codeowner @open-sauced/engineering
165+
```
166+
This ensures that all files have an assigned owner, even if there were no commits in the specified time range for certain files.
167+
168+
## Codeowners Command
95169

96170
To generate the CODEOWNERS file, you need to provide the path to your repository as an argument:
97171

@@ -109,7 +183,6 @@ pizza generate codeowners .
109183
- Ensure you have the necessary permissions to read the repository and write the CODEOWNERS file.
110184
- The command requires a `.sauced.yaml` file in the repository root for accurate attribution (as described in the previous section).
111185
- If you encounter any errors, double-check that you've provided the correct path to your repository.
112-
-
113186
:::
114187

115188
The codeowners command will analyze your repository's commit history and generate a CODEOWNERS file based on contributors' activity in the last 90 days.

0 commit comments

Comments
 (0)