Skip to content

Commit e03f5be

Browse files
authored
Add flag --digest-changes-only to filter commits for modules and plugins (#3560)
1 parent 3fc317c commit e03f5be

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## [Unreleased]
44

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

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

private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitlist/modulecommitlist.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ import (
3232
)
3333

3434
const (
35-
pageSizeFlagName = "page-size"
36-
pageTokenFlagName = "page-token"
37-
reverseFlagName = "reverse"
38-
formatFlagName = "format"
35+
pageSizeFlagName = "page-size"
36+
pageTokenFlagName = "page-token"
37+
reverseFlagName = "reverse"
38+
formatFlagName = "format"
39+
digestChangesOnlyFlagName = "digest-changes-only"
3940

4041
defaultPageSize = 10
4142
)
@@ -67,10 +68,11 @@ If no reference is specified, it lists all commits in this module.
6768
}
6869

6970
type flags struct {
70-
Format string
71-
PageSize uint32
72-
PageToken string
73-
Reverse bool
71+
Format string
72+
PageSize uint32
73+
PageToken string
74+
Reverse bool
75+
DigestChangesOnly bool
7476
}
7577

7678
func newFlags() *flags {
@@ -99,6 +101,12 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
99101
bufprint.FormatText.String(),
100102
fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString),
101103
)
104+
flagSet.BoolVar(
105+
&f.DigestChangesOnly,
106+
digestChangesOnlyFlagName,
107+
false,
108+
`Only commits that have changed digests. By default, all commits are listed`,
109+
)
102110
}
103111

104112
func run(
@@ -229,7 +237,8 @@ func run(
229237
},
230238
},
231239
},
232-
Order: labelHistoryOrder,
240+
Order: labelHistoryOrder,
241+
OnlyCommitsWithChangedDigests: flags.DigestChangesOnly,
233242
},
234243
),
235244
)

private/buf/cmd/buf/command/registry/plugin/plugincommit/plugincommitlist/plugincommitlist.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ import (
3232
)
3333

3434
const (
35-
pageSizeFlagName = "page-size"
36-
pageTokenFlagName = "page-token"
37-
reverseFlagName = "reverse"
38-
formatFlagName = "format"
35+
pageSizeFlagName = "page-size"
36+
pageTokenFlagName = "page-token"
37+
reverseFlagName = "reverse"
38+
formatFlagName = "format"
39+
digestChangesOnlyFlagName = "digest-changes-only"
3940

4041
defaultPageSize = 10
4142
)
@@ -67,28 +68,32 @@ If no reference is specified, it lists all commits in this plugin.
6768
}
6869

6970
type flags struct {
70-
Format string
71-
PageSize uint32
72-
PageToken string
73-
Reverse bool
71+
Format string
72+
PageSize uint32
73+
PageToken string
74+
Reverse bool
75+
DigestChangesOnly bool
7476
}
7577

7678
func newFlags() *flags {
7779
return &flags{}
7880
}
7981

8082
func (f *flags) Bind(flagSet *pflag.FlagSet) {
81-
flagSet.Uint32Var(&f.PageSize,
83+
flagSet.Uint32Var(
84+
&f.PageSize,
8285
pageSizeFlagName,
8386
defaultPageSize,
8487
`The page size`,
8588
)
86-
flagSet.StringVar(&f.PageToken,
89+
flagSet.StringVar(
90+
&f.PageToken,
8791
pageTokenFlagName,
8892
"",
8993
`The page token. If more results are available, a "next_page" key is present in the --format=json output`,
9094
)
91-
flagSet.BoolVar(&f.Reverse,
95+
flagSet.BoolVar(
96+
&f.Reverse,
9297
reverseFlagName,
9398
false,
9499
`Reverse the results. By default, they are ordered with the newest first`,
@@ -99,6 +104,12 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
99104
bufprint.FormatText.String(),
100105
fmt.Sprintf(`The output format to use. Must be one of %s`, bufprint.AllFormatsString),
101106
)
107+
flagSet.BoolVar(
108+
&f.DigestChangesOnly,
109+
digestChangesOnlyFlagName,
110+
false,
111+
`Only commits that have changed digests. By default, all commits are listed`,
112+
)
102113
}
103114

104115
func run(
@@ -230,7 +241,8 @@ func run(
230241
},
231242
},
232243
},
233-
Order: labelHistoryOrder,
244+
Order: labelHistoryOrder,
245+
OnlyCommitsWithChangedDigests: flags.DigestChangesOnly,
234246
},
235247
),
236248
)

0 commit comments

Comments
 (0)