Skip to content

Commit

Permalink
Add flag --digest-changes-only to filter commits for modules and plug…
Browse files Browse the repository at this point in the history
…ins (#3560)
  • Loading branch information
emcfarlane authored Jan 2, 2025
1 parent 3fc317c commit e03f5be
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## [Unreleased]

- Fix `buf plugin push --label` to allow pushing a plugin with a label.
- Add `--digest-changes-only` flag to `buf registry {module,plugin} commit list` to filter
out commits that have no digest changes.

## [v1.48.0] - 2024-12-19

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import (
)

const (
pageSizeFlagName = "page-size"
pageTokenFlagName = "page-token"
reverseFlagName = "reverse"
formatFlagName = "format"
pageSizeFlagName = "page-size"
pageTokenFlagName = "page-token"
reverseFlagName = "reverse"
formatFlagName = "format"
digestChangesOnlyFlagName = "digest-changes-only"

defaultPageSize = 10
)
Expand Down Expand Up @@ -67,10 +68,11 @@ If no reference is specified, it lists all commits in this module.
}

type flags struct {
Format string
PageSize uint32
PageToken string
Reverse bool
Format string
PageSize uint32
PageToken string
Reverse bool
DigestChangesOnly bool
}

func newFlags() *flags {
Expand Down Expand Up @@ -99,6 +101,12 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
bufprint.FormatText.String(),
fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString),
)
flagSet.BoolVar(
&f.DigestChangesOnly,
digestChangesOnlyFlagName,
false,
`Only commits that have changed digests. By default, all commits are listed`,
)
}

func run(
Expand Down Expand Up @@ -229,7 +237,8 @@ func run(
},
},
},
Order: labelHistoryOrder,
Order: labelHistoryOrder,
OnlyCommitsWithChangedDigests: flags.DigestChangesOnly,
},
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import (
)

const (
pageSizeFlagName = "page-size"
pageTokenFlagName = "page-token"
reverseFlagName = "reverse"
formatFlagName = "format"
pageSizeFlagName = "page-size"
pageTokenFlagName = "page-token"
reverseFlagName = "reverse"
formatFlagName = "format"
digestChangesOnlyFlagName = "digest-changes-only"

defaultPageSize = 10
)
Expand Down Expand Up @@ -67,28 +68,32 @@ If no reference is specified, it lists all commits in this plugin.
}

type flags struct {
Format string
PageSize uint32
PageToken string
Reverse bool
Format string
PageSize uint32
PageToken string
Reverse bool
DigestChangesOnly bool
}

func newFlags() *flags {
return &flags{}
}

func (f *flags) Bind(flagSet *pflag.FlagSet) {
flagSet.Uint32Var(&f.PageSize,
flagSet.Uint32Var(
&f.PageSize,
pageSizeFlagName,
defaultPageSize,
`The page size`,
)
flagSet.StringVar(&f.PageToken,
flagSet.StringVar(
&f.PageToken,
pageTokenFlagName,
"",
`The page token. If more results are available, a "next_page" key is present in the --format=json output`,
)
flagSet.BoolVar(&f.Reverse,
flagSet.BoolVar(
&f.Reverse,
reverseFlagName,
false,
`Reverse the results. By default, they are ordered with the newest first`,
Expand All @@ -99,6 +104,12 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
bufprint.FormatText.String(),
fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString),
)
flagSet.BoolVar(
&f.DigestChangesOnly,
digestChangesOnlyFlagName,
false,
`Only commits that have changed digests. By default, all commits are listed`,
)
}

func run(
Expand Down Expand Up @@ -230,7 +241,8 @@ func run(
},
},
},
Order: labelHistoryOrder,
Order: labelHistoryOrder,
OnlyCommitsWithChangedDigests: flags.DigestChangesOnly,
},
),
)
Expand Down

0 comments on commit e03f5be

Please sign in to comment.