Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release 2.3.0 #216

Merged
merged 27 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dfeae63
chore: update pizza action (#201)
nickytonline Sep 19, 2024
eec884b
feat: Add quick start section (#203)
BekahHW Sep 20, 2024
c102528
chore(minor): release 2.2.0-beta.3 on beta channel [skip ci]
BekahHW Sep 20, 2024
8d36d18
init offboard command
zeucapua Sep 24, 2024
74a6def
implement removing user from config based on name, only w specified c…
zeucapua Sep 24, 2024
8660829
remove a user based on email from config
zeucapua Sep 24, 2024
80dbb31
wip implement regenerating owners file
zeucapua Sep 25, 2024
db866b3
implement remove by name
zeucapua Sep 25, 2024
1661bad
remove users by email working
zeucapua Sep 25, 2024
bf119b9
remove logging prints
zeucapua Sep 25, 2024
649be32
rename args param
zeucapua Sep 25, 2024
34aed66
gci lint?
zeucapua Sep 25, 2024
3fdefe4
chore: update repository codeowners (#208)
github-actions[bot] Oct 2, 2024
d3684bb
add posthog telemetry
zeucapua Oct 3, 2024
bfaf37f
update offboard cmd description copy
zeucapua Oct 3, 2024
d19e8d1
make --path flag required with no default, check current path for con…
zeucapua Oct 3, 2024
c18ca72
handle persistent flag error, gci
zeucapua Oct 3, 2024
60c919a
Update cmd/offboard/offboard.go
zeucapua Oct 7, 2024
695a6ea
chore: update repository codeowners (#210)
github-actions[bot] Oct 7, 2024
5a60659
gci lint
zeucapua Oct 7, 2024
8044105
Merge pull request #207 from open-sauced/feat/offboarding-command
zeucapua Oct 7, 2024
aa7b1a4
chore: automated docs generation for release
open-sauced[bot] Oct 7, 2024
deb22a2
feat: add comment preamble to generated config (#214)
zeucapua Oct 11, 2024
e62549a
chore(minor): release 2.2.0-beta.4 on beta channel [skip ci]
zeucapua Oct 11, 2024
0e592b4
Merge branch 'beta' into main-ff
jpmcb Oct 11, 2024
227803b
Merge pull request #215 from open-sauced/main-ff
jpmcb Oct 11, 2024
cfdde7e
chore(minor): release 2.3.0-beta.1 on beta channel [skip ci]
jpmcb Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pizza.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Pizza Action
uses: open-sauced/pizza-action@v2.1.0
uses: open-sauced/pizza-action@v2.3.0
with:
cli-version: "v2.2.0"
commit-and-pr: "true"
pr-title: "chore: update repository codeowners"
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,30 @@

> All notable changes to this project will be documented in this file

## [2.3.0-beta.1](https://github.com/open-sauced/pizza-cli/compare/v2.2.0...v2.3.0-beta.1) (2024-10-11)


### 🍕 Features

* 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))
* Add quick start section ([#203](https://github.com/open-sauced/pizza-cli/issues/203)) ([eec884b](https://github.com/open-sauced/pizza-cli/commit/eec884b816404fdbbc5fb5445cb44fe211b8b0c8))

## [2.2.0](https://github.com/open-sauced/pizza-cli/compare/v2.1.0...v2.2.0) (2024-09-18)


### 🍕 Features

* 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))
* 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))
* 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))

## [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)


### 🍕 Features

* Add quick start section ([#203](https://github.com/open-sauced/pizza-cli/issues/203)) ([eec884b](https://github.com/open-sauced/pizza-cli/commit/eec884b816404fdbbc5fb5445cb44fe211b8b0c8))


## [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)

Expand Down
15 changes: 8 additions & 7 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.github/workflows/test.yaml @jpmcb @zeucapua
.golangci.yaml @jpmcb @zeucapua
.sauced.yaml @jpmcb @nickytonline @zeucapua
CHANGELOG.md @jpmcb @nickytonline @zeucapua
CHANGELOG.md @jpmcb @zeucapua @nickytonline
CODEOWNERS @jpmcb @nickytonline
Dockerfile @jpmcb @nickytonline @zeucapua
Makefile @jpmcb
Expand Down Expand Up @@ -53,7 +53,7 @@ cmd/generate/codeowners/output.go @jpmcb @zeucapua @brandonroberts
cmd/generate/codeowners/output_test.go @jpmcb @brandonroberts @zeucapua
cmd/generate/codeowners/spec.go @jpmcb
cmd/generate/codeowners/traversal.go @jpmcb
cmd/generate/config/config.go @zeucapua @zeucapua @jpmcb
cmd/generate/config/config.go @zeucapua @jpmcb @zeucapua
cmd/generate/config/output.go @zeucapua @jpmcb @zeucapua
cmd/generate/config/spec.go @zeucapua @zeucapua @jpmcb
cmd/generate/generate.go @jpmcb @zeucapua
Expand All @@ -71,7 +71,7 @@ cmd/show/dashboard.go @jpmcb
cmd/show/show.go @jpmcb
cmd/show/tui.go @jpmcb
cmd/version/version.go @jpmcb @nickytonline
docs/pizza.md @jpmcb @zeucapua @nickytonline
docs/pizza.md @jpmcb @nickytonline @zeucapua
docs/pizza_completion.md @jpmcb @nickytonline @zeucapua
docs/pizza_completion_bash.md @jpmcb @zeucapua @nickytonline
docs/pizza_completion_fish.md @jpmcb @nickytonline @zeucapua
Expand All @@ -80,16 +80,17 @@ docs/pizza_completion_zsh.md @jpmcb @nickytonline @zeucapua
docs/pizza_generate.md @jpmcb @nickytonline @zeucapua
docs/pizza_generate_codeowners.md @jpmcb
docs/pizza_generate_config.md @jpmcb
docs/pizza_generate_insight.md
docs/pizza_generate_insight.md @jpmcb
docs/pizza_insights.md @jpmcb @zeucapua @nickytonline
docs/pizza_insights_contributors.md @jpmcb @zeucapua @nickytonline
docs/pizza_insights_contributors.md @jpmcb @nickytonline @zeucapua
docs/pizza_insights_repositories.md @jpmcb @zeucapua @nickytonline
docs/pizza_insights_user-contributions.md @jpmcb @nickytonline @zeucapua
docs/pizza_login.md @jpmcb @nickytonline @zeucapua
docs/pizza_version.md @jpmcb @nickytonline @zeucapua
go.mod @jpmcb @nickytonline @zeucapua
go.sum @jpmcb @zeucapua @zeucapua
go.sum @jpmcb @zeucapua @nickytonline
justfile @jpmcb @zeucapua @nickytonline
main.go @jpmcb
npm/.gitignore @jpmcb @zeucapua
npm/README.md @jpmcb
npm/package-lock.json @jpmcb @nickytonline @zeucapua
Expand All @@ -106,5 +107,5 @@ pkg/utils/posthog.go @jpmcb @zeucapua @zeucapua
pkg/utils/root.go @jpmcb @zeucapua
pkg/utils/telemetry.go @jpmcb
pkg/utils/version.go @nickytonline @jpmcb
scripts/generate-docs.sh @jpmcb @nickytonline
scripts/generate-docs.sh @nickytonline @jpmcb
telemetry.go @jpmcb @zeucapua @zeucapua
74 changes: 73 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</a>
</div>

# 📦 Install
# 📦 [Install](#-install)

#### Homebrew

Expand Down Expand Up @@ -149,6 +149,78 @@ jobs:
how to use the Pizza command line tool and how it works with the rest of the OpenSauced
ecosystem.

# 🚀 Quickstart

Get up and running with the Pizza CLI in minutes using `npx`:

1. **Ensure you have Node.js installed**

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/).

> NOTE
> For other installation methods, see the [Install](#-Install) section.

2. **Generate a configuration file**

Navigate to your project directory and run:
```sh
npx pizza@latest generate config ./ -i
```
This will create a `.sauced.yaml` file, interactively prompting you to attribute commit emails to GitHub handles.

3. **Generate CODEOWNERS file**

In your project directory, run:
```sh
npx pizza@latest generate codeowners ./
```
This will create a `CODEOWNERS` file based on your project's git history and the `.sauced.yaml` configuration.

4. **Create OpenSauced [Contributor Insight](https://opensauced.pizza/docs/features/contributor-insights/)**

After generating the CODEOWNERS file, you can create an OpenSauced Contributor Insight:
```sh
npx pizza@latest generate insight .
```

5. **Explore repository insights**
Get metrics and insights for your repository:
```sh
npx pizza@latest insights repositories your-username/your-repo
```

6. **Set up automated CODEOWNERS updates (Optional)**
Add the [Pizza GitHub Action](https://github.com/open-sauced/pizza-action) to your repository to automate CODEOWNERS updates:
```yaml
# In .github/workflows/pizza-action.yml
name: OpenSauced Pizza Action
on:
schedule:
# Run once a week on Sunday at 00:00 UTC
- cron: "0 0 * * 0"
workflow_dispatch: # Allow manual triggering

jobs:
pizza-action:
runs-on: ubuntu-latest
steps:
- name: Pizza Action
uses: open-sauced/[email protected]
with:
# optional and default is "latest". Add this parameter if you want to use a specific version, e.g. v2.0.0
cli-version: "v2.2.0"
# optional and false by default. Set this to true if you want to have a pull request for the changes created automatically.
commit-and-pr: "true"
# optional
pr-title: "chore: update repository codeowners"

```

Now you're ready to leverage the Pizza CLI for managing code ownership and getting project insights with OpenSauced!

> Note
> 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]`.

# ✨ Usage

## Codeowners generation
Expand Down
7 changes: 7 additions & 0 deletions cmd/generate/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func generateOutputFile(outputPath string, attributionMap map[string][]string) e
}
defer file.Close()

// write the header preamble
_, 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")

if err != nil {
return fmt.Errorf("error writing to %s file: %w", outputPath, err)
}

var config config.Spec
config.Attributions = attributionMap

Expand Down
139 changes: 139 additions & 0 deletions cmd/offboard/offboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package offboard

import (
"errors"
"fmt"
"slices"
"strings"

"github.com/spf13/cobra"

"github.com/open-sauced/pizza-cli/v2/pkg/config"
"github.com/open-sauced/pizza-cli/v2/pkg/constants"
"github.com/open-sauced/pizza-cli/v2/pkg/utils"
)

type Options struct {
offboardingUsers []string

// config file path
configPath string

// repository path
path string

// from global config
ttyDisabled bool

// telemetry for capturing CLI events via PostHog
telemetry *utils.PosthogCliClient
}

const offboardLongDesc string = `CAUTION: Experimental Command. Removes users from the \".sauced.yaml\" config and \"CODEOWNERS\" files.
Requires the users' name OR email.`

func NewConfigCommand() *cobra.Command {
opts := &Options{}
cmd := &cobra.Command{
Use: "offboard <username/email> [flags]",
Short: "CAUTION: Experimental Command. Removes users from the \".sauced.yaml\" config and \"CODEOWNERS\" files.",
Long: offboardLongDesc,
Args: func(_ *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("you must provide at least one argument: the offboarding user's email/username")
}

opts.offboardingUsers = args

return nil
},
RunE: func(cmd *cobra.Command, _ []string) error {
opts.ttyDisabled, _ = cmd.Flags().GetBool("tty-disable")
opts.configPath, _ = cmd.Flags().GetString("config")
disableTelem, _ := cmd.Flags().GetBool(constants.FlagNameTelemetry)

opts.telemetry = utils.NewPosthogCliClient(!disableTelem)

opts.path, _ = cmd.Flags().GetString("path")
err := run(opts)
_ = opts.telemetry.Done()

return err
},
}

cmd.PersistentFlags().StringP("path", "p", "", "the path to the repository (required)")
if err := cmd.MarkPersistentFlagRequired("path"); err != nil {
fmt.Printf("error MarkPersistentFlagRequired: %v", err)
}
return cmd
}

func run(opts *Options) error {
var spec *config.Spec
var err error
if len(opts.configPath) != 0 {
spec, _, err = config.LoadConfig(opts.configPath)
} else {
var configPath string
if strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0 {
configPath = opts.path + ".sauced.yaml"
} else {
configPath = opts.path + "/.sauced.yaml"
}
spec, _, err = config.LoadConfig(configPath)
}

if err != nil {
_ = opts.telemetry.CaptureFailedOffboard()
return fmt.Errorf("error loading config: %v", err)
}

var offboardingNames []string
attributions := spec.Attributions
for _, user := range opts.offboardingUsers {
added := false

// deletes if the user is a name (key)
delete(attributions, user)

// delete if the user is an email (value)
for k, v := range attributions {
if slices.Contains(v, user) {
offboardingNames = append(offboardingNames, k)
delete(attributions, k)
added = true
}
}

if !added {
offboardingNames = append(offboardingNames, user)
}
}

if len(opts.configPath) != 0 {
err = generateConfigFile(opts.configPath, attributions)
} else {
var configPath string
if strings.Compare(string(opts.path[len(opts.path)-1]), "/") == 0 {
configPath = opts.path + ".sauced.yaml"
} else {
configPath = opts.path + "/.sauced.yaml"
}
err = generateConfigFile(configPath, attributions)
}

if err != nil {
_ = opts.telemetry.CaptureFailedOffboard()
return fmt.Errorf("error generating config file: %v", err)
}

err = generateOwnersFile(opts.path, offboardingNames)
if err != nil {
_ = opts.telemetry.CaptureFailedOffboard()
return fmt.Errorf("error generating owners file: %v", err)
}

_ = opts.telemetry.CaptureOffboard()
return nil
}
Loading
Loading