Skip to content

Commit 78edbfd

Browse files
authored
Add source control URL for module and plugin commit info (#3980)
1 parent 6a3d0bf commit 78edbfd

File tree

11 files changed

+31
-24
lines changed

11 files changed

+31
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Update exclude types to remove unused options reducing the size of generated code.
66
- Add `gitlab-code-quality` error format to print errors in the GitLab Code Quality format
77
for `buf lint` and `buf breaking`.
8+
- Add `source_control_url` to `json` outputs for `buf registry {module, plugin} commit` commands.
89

910
## [v1.56.0] - 2025-07-31
1011

private/buf/bufprint/bufprint.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,19 @@ func NewLabelEntity(label interface {
224224

225225
// NewCommitEntity returns a new commit entity to print. It takes a commit as
226226
// an interface to allow for modulev1.Commit and pluginv1beta1.Commit to be passed.
227-
func NewCommitEntity(commit interface {
228-
GetId() string
229-
GetCreateTime() *timestamppb.Timestamp
230-
}, moduleFullName bufparse.FullName) Entity {
227+
func NewCommitEntity(
228+
commit interface {
229+
GetId() string
230+
GetCreateTime() *timestamppb.Timestamp
231+
},
232+
moduleFullName bufparse.FullName,
233+
sourceControlURL string,
234+
) Entity {
231235
return outputCommit{
232-
Commit: commit.GetId(),
233-
CreateTime: commit.GetCreateTime().AsTime(),
234-
entityFullName: moduleFullName,
236+
Commit: commit.GetId(),
237+
CreateTime: commit.GetCreateTime().AsTime(),
238+
SourceControlURL: sourceControlURL,
239+
entityFullName: moduleFullName,
235240
}
236241
}
237242

@@ -475,8 +480,9 @@ func (l outputLabel) fullName() string {
475480
}
476481

477482
type outputCommit struct {
478-
Commit string `json:"commit,omitempty" bufprint:"Commit"`
479-
CreateTime time.Time `json:"create_time,omitempty" bufprint:"Create Time"`
483+
Commit string `json:"commit,omitempty" bufprint:"Commit"`
484+
CreateTime time.Time `json:"create_time,omitempty" bufprint:"Create Time"`
485+
SourceControlURL string `json:"source_control_url,omitempty"`
480486

481487
entityFullName bufparse.FullName
482488
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@ func run(
124124
return bufprint.PrintEntity(
125125
container.Stdout(),
126126
format,
127-
bufprint.NewCommitEntity(commits[0], moduleRef.FullName()),
127+
bufprint.NewCommitEntity(commits[0], moduleRef.FullName(), commits[0].GetSourceControlUrl()),
128128
)
129129
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func run(
169169
format,
170170
"",
171171
"",
172-
[]bufprint.Entity{bufprint.NewCommitEntity(commit, moduleRef.FullName())},
172+
[]bufprint.Entity{bufprint.NewCommitEntity(commit, moduleRef.FullName(), commit.GetSourceControlUrl())},
173173
)
174174
}
175175
if resource.GetModule() != nil {
@@ -208,7 +208,7 @@ func run(
208208
resp.Msg.NextPageToken,
209209
nextPageCommand(container, flags, resp.Msg.NextPageToken),
210210
xslices.Map(resp.Msg.Commits, func(commit *modulev1.Commit) bufprint.Entity {
211-
return bufprint.NewCommitEntity(commit, moduleRef.FullName())
211+
return bufprint.NewCommitEntity(commit, moduleRef.FullName(), commit.GetSourceControlUrl())
212212
}),
213213
)
214214
}
@@ -261,7 +261,7 @@ func run(
261261
resp.Msg.NextPageToken,
262262
nextPageCommand(container, flags, resp.Msg.NextPageToken),
263263
xslices.Map(commits, func(commit *modulev1.Commit) bufprint.Entity {
264-
return bufprint.NewCommitEntity(commit, moduleRef.FullName())
264+
return bufprint.NewCommitEntity(commit, moduleRef.FullName(), commit.GetSourceControlUrl())
265265
}),
266266
)
267267
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ func run(
123123
return bufprint.PrintNames(
124124
container.Stdout(),
125125
format,
126-
bufprint.NewCommitEntity(commit, moduleRef.FullName()),
126+
bufprint.NewCommitEntity(commit, moduleRef.FullName(), commit.GetSourceControlUrl()),
127127
)
128128
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@ func run(
124124
return bufprint.PrintEntity(
125125
container.Stdout(),
126126
format,
127-
bufprint.NewCommitEntity(commits[0], pluginRef.FullName()),
127+
bufprint.NewCommitEntity(commits[0], pluginRef.FullName(), commits[0].GetSourceControlUrl()),
128128
)
129129
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func run(
173173
format,
174174
"",
175175
"",
176-
[]bufprint.Entity{bufprint.NewCommitEntity(commit, pluginRef.FullName())},
176+
[]bufprint.Entity{bufprint.NewCommitEntity(commit, pluginRef.FullName(), commit.GetSourceControlUrl())},
177177
)
178178
}
179179
if resource.GetPlugin() != nil {
@@ -212,7 +212,7 @@ func run(
212212
resp.Msg.NextPageToken,
213213
nextPageCommand(container, flags, resp.Msg.NextPageToken),
214214
xslices.Map(resp.Msg.Commits, func(commit *pluginv1beta1.Commit) bufprint.Entity {
215-
return bufprint.NewCommitEntity(commit, pluginRef.FullName())
215+
return bufprint.NewCommitEntity(commit, pluginRef.FullName(), commit.GetSourceControlUrl())
216216
}),
217217
)
218218
}
@@ -265,7 +265,7 @@ func run(
265265
resp.Msg.NextPageToken,
266266
nextPageCommand(container, flags, resp.Msg.NextPageToken),
267267
xslices.Map(commits, func(commit *pluginv1beta1.Commit) bufprint.Entity {
268-
return bufprint.NewCommitEntity(commit, pluginRef.FullName())
268+
return bufprint.NewCommitEntity(commit, pluginRef.FullName(), commit.GetSourceControlUrl())
269269
}),
270270
)
271271
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ func run(
123123
return bufprint.PrintNames(
124124
container.Stdout(),
125125
format,
126-
bufprint.NewCommitEntity(commit, pluginRef.FullName()),
126+
bufprint.NewCommitEntity(commit, pluginRef.FullName(), commit.GetSourceControlUrl()),
127127
)
128128
}

private/buf/cmd/buf/command/registry/policy/policycommit/policycommitinfo/policycommitinfo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,6 @@ func run(
124124
return bufprint.PrintEntity(
125125
container.Stdout(),
126126
format,
127-
bufprint.NewCommitEntity(commits[0], policyRef.FullName()),
127+
bufprint.NewCommitEntity(commits[0], policyRef.FullName(), ""), // No source control URL for policy commits
128128
)
129129
}

private/buf/cmd/buf/command/registry/policy/policycommit/policycommitlist/policycommitlist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func run(
167167
format,
168168
"",
169169
"",
170-
[]bufprint.Entity{bufprint.NewCommitEntity(commit, policyRef.FullName())},
170+
[]bufprint.Entity{bufprint.NewCommitEntity(commit, policyRef.FullName(), "")}, // No source control URL for policy commits
171171
)
172172
}
173173
if resource.GetPolicy() != nil {
@@ -206,7 +206,7 @@ func run(
206206
resp.Msg.NextPageToken,
207207
nextPageCommand(container, flags, resp.Msg.NextPageToken),
208208
xslices.Map(resp.Msg.Commits, func(commit *policyv1beta1.Commit) bufprint.Entity {
209-
return bufprint.NewCommitEntity(commit, policyRef.FullName())
209+
return bufprint.NewCommitEntity(commit, policyRef.FullName(), "") // No source control URL for policy commits
210210
}),
211211
)
212212
}
@@ -258,7 +258,7 @@ func run(
258258
resp.Msg.NextPageToken,
259259
nextPageCommand(container, flags, resp.Msg.NextPageToken),
260260
xslices.Map(commits, func(commit *policyv1beta1.Commit) bufprint.Entity {
261-
return bufprint.NewCommitEntity(commit, policyRef.FullName())
261+
return bufprint.NewCommitEntity(commit, policyRef.FullName(), "") // No source control URL for policy commits
262262
}),
263263
)
264264
}

0 commit comments

Comments
 (0)