Skip to content

Commit df0c3db

Browse files
TimurTimur
authored andcommitted
feat: add patch field to MinimalCommitFile
Include the patch/diff content for each file in commit responses. This allows consumers to see the actual code changes without needing to make additional API calls. The patch field is included when include_diff is true (the default).
1 parent 1820a0f commit df0c3db

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

pkg/github/minimal_types.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type MinimalCommitFile struct {
7575
Additions int `json:"additions,omitempty"`
7676
Deletions int `json:"deletions,omitempty"`
7777
Changes int `json:"changes,omitempty"`
78+
Patch string `json:"patch,omitempty"`
7879
}
7980

8081
// MinimalCommit is the trimmed output type for commit objects.
@@ -236,13 +237,14 @@ func convertToMinimalCommit(commit *github.RepositoryCommit, includeDiffs bool)
236237
if len(commit.Files) > 0 {
237238
minimalCommit.Files = make([]MinimalCommitFile, 0, len(commit.Files))
238239
for _, file := range commit.Files {
239-
minimalFile := MinimalCommitFile{
240-
Filename: file.GetFilename(),
241-
Status: file.GetStatus(),
242-
Additions: file.GetAdditions(),
243-
Deletions: file.GetDeletions(),
244-
Changes: file.GetChanges(),
245-
}
240+
minimalFile := MinimalCommitFile{
241+
Filename: file.GetFilename(),
242+
Status: file.GetStatus(),
243+
Additions: file.GetAdditions(),
244+
Deletions: file.GetDeletions(),
245+
Changes: file.GetChanges(),
246+
Patch: file.GetPatch(),
247+
}
246248
minimalCommit.Files = append(minimalCommit.Files, minimalFile)
247249
}
248250
}

0 commit comments

Comments
 (0)