Skip to content

Commit 8acaed3

Browse files
authored
Merge pull request #216 from open-sauced/beta
chore: release 2.3.0
2 parents e99679b + cfdde7e commit 8acaed3

File tree

13 files changed

+395
-12
lines changed

13 files changed

+395
-12
lines changed

.github/workflows/pizza.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Pizza Action
14-
uses: open-sauced/pizza-action@v2.1.0
14+
uses: open-sauced/pizza-action@v2.3.0
1515
with:
16+
cli-version: "v2.2.0"
1617
commit-and-pr: "true"
18+
pr-title: "chore: update repository codeowners"

CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,30 @@
55

66
> All notable changes to this project will be documented in this file
77
8+
## [2.3.0-beta.1](https://github.com/open-sauced/pizza-cli/compare/v2.2.0...v2.3.0-beta.1) (2024-10-11)
9+
10+
11+
### 🍕 Features
12+
13+
* add comment preamble to generated config ([#214](https://github.com/open-sauced/pizza-cli/issues/214)) ([deb22a2](https://github.com/open-sauced/pizza-cli/commit/deb22a247f6aa3f1a64e1ed13f6554060e67a533))
14+
* Add quick start section ([#203](https://github.com/open-sauced/pizza-cli/issues/203)) ([eec884b](https://github.com/open-sauced/pizza-cli/commit/eec884b816404fdbbc5fb5445cb44fe211b8b0c8))
15+
816
## [2.2.0](https://github.com/open-sauced/pizza-cli/compare/v2.1.0...v2.2.0) (2024-09-18)
917

1018

1119
### 🍕 Features
1220

1321
* shortcut to skip rest of emails for `pizza generate config` ([#197](https://github.com/open-sauced/pizza-cli/issues/197)) ([6e96fff](https://github.com/open-sauced/pizza-cli/commit/6e96fffb3d8bec5384118f3dedc499d164384ca5))
1422
* Upgrades to v2 packages to track with v2 git tag ([#198](https://github.com/open-sauced/pizza-cli/issues/198)) ([5a0995d](https://github.com/open-sauced/pizza-cli/commit/5a0995d8fb1405ab1d405aef0fd0f20327e2fd53))
23+
* add comment preamble to generated config ([#214](https://github.com/open-sauced/pizza-cli/issues/214)) ([deb22a2](https://github.com/open-sauced/pizza-cli/commit/deb22a247f6aa3f1a64e1ed13f6554060e67a533))
24+
25+
## [2.2.0-beta.3](https://github.com/open-sauced/pizza-cli/compare/v2.2.0-beta.2...v2.2.0-beta.3) (2024-09-20)
26+
27+
28+
### 🍕 Features
29+
30+
* Add quick start section ([#203](https://github.com/open-sauced/pizza-cli/issues/203)) ([eec884b](https://github.com/open-sauced/pizza-cli/commit/eec884b816404fdbbc5fb5445cb44fe211b8b0c8))
31+
1532

1633
## [2.2.0-beta.2](https://github.com/open-sauced/pizza-cli/compare/v2.2.0-beta.1...v2.2.0-beta.2) (2024-09-18)
1734

CODEOWNERS

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.github/workflows/test.yaml @jpmcb @zeucapua
1414
.golangci.yaml @jpmcb @zeucapua
1515
.sauced.yaml @jpmcb @nickytonline @zeucapua
16-
CHANGELOG.md @jpmcb @nickytonline @zeucapua
16+
CHANGELOG.md @jpmcb @zeucapua @nickytonline
1717
CODEOWNERS @jpmcb @nickytonline
1818
Dockerfile @jpmcb @nickytonline @zeucapua
1919
Makefile @jpmcb
@@ -53,7 +53,7 @@ cmd/generate/codeowners/output.go @jpmcb @zeucapua @brandonroberts
5353
cmd/generate/codeowners/output_test.go @jpmcb @brandonroberts @zeucapua
5454
cmd/generate/codeowners/spec.go @jpmcb
5555
cmd/generate/codeowners/traversal.go @jpmcb
56-
cmd/generate/config/config.go @zeucapua @zeucapua @jpmcb
56+
cmd/generate/config/config.go @zeucapua @jpmcb @zeucapua
5757
cmd/generate/config/output.go @zeucapua @jpmcb @zeucapua
5858
cmd/generate/config/spec.go @zeucapua @zeucapua @jpmcb
5959
cmd/generate/generate.go @jpmcb @zeucapua
@@ -71,7 +71,7 @@ cmd/show/dashboard.go @jpmcb
7171
cmd/show/show.go @jpmcb
7272
cmd/show/tui.go @jpmcb
7373
cmd/version/version.go @jpmcb @nickytonline
74-
docs/pizza.md @jpmcb @zeucapua @nickytonline
74+
docs/pizza.md @jpmcb @nickytonline @zeucapua
7575
docs/pizza_completion.md @jpmcb @nickytonline @zeucapua
7676
docs/pizza_completion_bash.md @jpmcb @zeucapua @nickytonline
7777
docs/pizza_completion_fish.md @jpmcb @nickytonline @zeucapua
@@ -80,16 +80,17 @@ docs/pizza_completion_zsh.md @jpmcb @nickytonline @zeucapua
8080
docs/pizza_generate.md @jpmcb @nickytonline @zeucapua
8181
docs/pizza_generate_codeowners.md @jpmcb
8282
docs/pizza_generate_config.md @jpmcb
83-
docs/pizza_generate_insight.md
83+
docs/pizza_generate_insight.md @jpmcb
8484
docs/pizza_insights.md @jpmcb @zeucapua @nickytonline
85-
docs/pizza_insights_contributors.md @jpmcb @zeucapua @nickytonline
85+
docs/pizza_insights_contributors.md @jpmcb @nickytonline @zeucapua
8686
docs/pizza_insights_repositories.md @jpmcb @zeucapua @nickytonline
8787
docs/pizza_insights_user-contributions.md @jpmcb @nickytonline @zeucapua
8888
docs/pizza_login.md @jpmcb @nickytonline @zeucapua
8989
docs/pizza_version.md @jpmcb @nickytonline @zeucapua
9090
go.mod @jpmcb @nickytonline @zeucapua
91-
go.sum @jpmcb @zeucapua @zeucapua
91+
go.sum @jpmcb @zeucapua @nickytonline
9292
justfile @jpmcb @zeucapua @nickytonline
93+
main.go @jpmcb
9394
npm/.gitignore @jpmcb @zeucapua
9495
npm/README.md @jpmcb
9596
npm/package-lock.json @jpmcb @nickytonline @zeucapua
@@ -106,5 +107,5 @@ pkg/utils/posthog.go @jpmcb @zeucapua @zeucapua
106107
pkg/utils/root.go @jpmcb @zeucapua
107108
pkg/utils/telemetry.go @jpmcb
108109
pkg/utils/version.go @nickytonline @jpmcb
109-
scripts/generate-docs.sh @jpmcb @nickytonline
110+
scripts/generate-docs.sh @nickytonline @jpmcb
110111
telemetry.go @jpmcb @zeucapua @zeucapua

README.md

+73-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</a>
3131
</div>
3232

33-
# 📦 Install
33+
# 📦 [Install](#-install)
3434

3535
#### Homebrew
3636

@@ -149,6 +149,78 @@ jobs:
149149
how to use the Pizza command line tool and how it works with the rest of the OpenSauced
150150
ecosystem.
151151
152+
# 🚀 Quickstart
153+
154+
Get up and running with the Pizza CLI in minutes using `npx`:
155+
156+
1. **Ensure you have Node.js installed**
157+
158+
Pizza CLI can be run using `npx`, which comes with Node.js. If you don't have Node.js installed, download it from [nodejs.org](https://nodejs.org/).
159+
160+
> NOTE
161+
> For other installation methods, see the [Install](#-Install) section.
162+
163+
2. **Generate a configuration file**
164+
165+
Navigate to your project directory and run:
166+
```sh
167+
npx pizza@latest generate config ./ -i
168+
```
169+
This will create a `.sauced.yaml` file, interactively prompting you to attribute commit emails to GitHub handles.
170+
171+
3. **Generate CODEOWNERS file**
172+
173+
In your project directory, run:
174+
```sh
175+
npx pizza@latest generate codeowners ./
176+
```
177+
This will create a `CODEOWNERS` file based on your project's git history and the `.sauced.yaml` configuration.
178+
179+
4. **Create OpenSauced [Contributor Insight](https://opensauced.pizza/docs/features/contributor-insights/)**
180+
181+
After generating the CODEOWNERS file, you can create an OpenSauced Contributor Insight:
182+
```sh
183+
npx pizza@latest generate insight .
184+
```
185+
186+
5. **Explore repository insights**
187+
Get metrics and insights for your repository:
188+
```sh
189+
npx pizza@latest insights repositories your-username/your-repo
190+
```
191+
192+
6. **Set up automated CODEOWNERS updates (Optional)**
193+
Add the [Pizza GitHub Action](https://github.com/open-sauced/pizza-action) to your repository to automate CODEOWNERS updates:
194+
```yaml
195+
# In .github/workflows/pizza-action.yml
196+
name: OpenSauced Pizza Action
197+
on:
198+
schedule:
199+
# Run once a week on Sunday at 00:00 UTC
200+
- cron: "0 0 * * 0"
201+
workflow_dispatch: # Allow manual triggering
202+
203+
jobs:
204+
pizza-action:
205+
runs-on: ubuntu-latest
206+
steps:
207+
- name: Pizza Action
208+
uses: open-sauced/[email protected]
209+
with:
210+
# optional and default is "latest". Add this parameter if you want to use a specific version, e.g. v2.0.0
211+
cli-version: "v2.2.0"
212+
# optional and false by default. Set this to true if you want to have a pull request for the changes created automatically.
213+
commit-and-pr: "true"
214+
# optional
215+
pr-title: "chore: update repository codeowners"
216+
217+
```
218+
219+
Now you're ready to leverage the Pizza CLI for managing code ownership and getting project insights with OpenSauced!
220+
221+
> Note
222+
> Using `npx pizza@latest` ensures you're always running the most recent version of Pizza CLI. If you prefer to use a specific version, you can replace `@latest` with a version number, e.g., `npx [email protected]`.
223+
152224
# ✨ Usage
153225
154226
## Codeowners generation

cmd/generate/config/output.go

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ func generateOutputFile(outputPath string, attributionMap map[string][]string) e
1515
}
1616
defer file.Close()
1717

18+
// write the header preamble
19+
_, err = file.WriteString("# Configuration for attributing commits with emails to GitHub user profiles\n# Used during codeowners generation.\n\n# List the emails associated with the given username\n# The commits associated with these emails will be attributed to\n# the username in this yaml map. Any number of emails may be listed\n\n")
20+
21+
if err != nil {
22+
return fmt.Errorf("error writing to %s file: %w", outputPath, err)
23+
}
24+
1825
var config config.Spec
1926
config.Attributions = attributionMap
2027

cmd/offboard/offboard.go

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
package offboard
2+
3+
import (
4+
"errors"
5+
"fmt"
6+
"slices"
7+
"strings"
8+
9+
"github.com/spf13/cobra"
10+
11+
"github.com/open-sauced/pizza-cli/v2/pkg/config"
12+
"github.com/open-sauced/pizza-cli/v2/pkg/constants"
13+
"github.com/open-sauced/pizza-cli/v2/pkg/utils"
14+
)
15+
16+
type Options struct {
17+
offboardingUsers []string
18+
19+
// config file path
20+
configPath string
21+
22+
// repository path
23+
path string
24+
25+
// from global config
26+
ttyDisabled bool
27+
28+
// telemetry for capturing CLI events via PostHog
29+
telemetry *utils.PosthogCliClient
30+
}
31+
32+
const offboardLongDesc string = `CAUTION: Experimental Command. Removes users from the \".sauced.yaml\" config and \"CODEOWNERS\" files.
33+
Requires the users' name OR email.`
34+
35+
func NewConfigCommand() *cobra.Command {
36+
opts := &Options{}
37+
cmd := &cobra.Command{
38+
Use: "offboard <username/email> [flags]",
39+
Short: "CAUTION: Experimental Command. Removes users from the \".sauced.yaml\" config and \"CODEOWNERS\" files.",
40+
Long: offboardLongDesc,
41+
Args: func(_ *cobra.Command, args []string) error {
42+
if len(args) == 0 {
43+
return errors.New("you must provide at least one argument: the offboarding user's email/username")
44+
}
45+
46+
opts.offboardingUsers = args
47+
48+
return nil
49+
},
50+
RunE: func(cmd *cobra.Command, _ []string) error {
51+
opts.ttyDisabled, _ = cmd.Flags().GetBool("tty-disable")
52+
opts.configPath, _ = cmd.Flags().GetString("config")
53+
disableTelem, _ := cmd.Flags().GetBool(constants.FlagNameTelemetry)
54+
55+
opts.telemetry = utils.NewPosthogCliClient(!disableTelem)
56+
57+
opts.path, _ = cmd.Flags().GetString("path")
58+
err := run(opts)
59+
_ = opts.telemetry.Done()
60+
61+
return err
62+
},
63+
}
64+
65+
cmd.PersistentFlags().StringP("path", "p", "", "the path to the repository (required)")
66+
if err := cmd.MarkPersistentFlagRequired("path"); err != nil {
67+
fmt.Printf("error MarkPersistentFlagRequired: %v", err)
68+
}
69+
return cmd
70+
}
71+
72+
func run(opts *Options) error {
73+
var spec *config.Spec
74+
var err error
75+
if len(opts.configPath) != 0 {
76+
spec, _, err = config.LoadConfig(opts.configPath)
77+
} else {
78+
var configPath string
79+
if strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0 {
80+
configPath = opts.path + ".sauced.yaml"
81+
} else {
82+
configPath = opts.path + "/.sauced.yaml"
83+
}
84+
spec, _, err = config.LoadConfig(configPath)
85+
}
86+
87+
if err != nil {
88+
_ = opts.telemetry.CaptureFailedOffboard()
89+
return fmt.Errorf("error loading config: %v", err)
90+
}
91+
92+
var offboardingNames []string
93+
attributions := spec.Attributions
94+
for _, user := range opts.offboardingUsers {
95+
added := false
96+
97+
// deletes if the user is a name (key)
98+
delete(attributions, user)
99+
100+
// delete if the user is an email (value)
101+
for k, v := range attributions {
102+
if slices.Contains(v, user) {
103+
offboardingNames = append(offboardingNames, k)
104+
delete(attributions, k)
105+
added = true
106+
}
107+
}
108+
109+
if !added {
110+
offboardingNames = append(offboardingNames, user)
111+
}
112+
}
113+
114+
if len(opts.configPath) != 0 {
115+
err = generateConfigFile(opts.configPath, attributions)
116+
} else {
117+
var configPath string
118+
if strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0 {
119+
configPath = opts.path + ".sauced.yaml"
120+
} else {
121+
configPath = opts.path + "/.sauced.yaml"
122+
}
123+
err = generateConfigFile(configPath, attributions)
124+
}
125+
126+
if err != nil {
127+
_ = opts.telemetry.CaptureFailedOffboard()
128+
return fmt.Errorf("error generating config file: %v", err)
129+
}
130+
131+
err = generateOwnersFile(opts.path, offboardingNames)
132+
if err != nil {
133+
_ = opts.telemetry.CaptureFailedOffboard()
134+
return fmt.Errorf("error generating owners file: %v", err)
135+
}
136+
137+
_ = opts.telemetry.CaptureOffboard()
138+
return nil
139+
}

0 commit comments

Comments
 (0)