Skip to content

Commit afd5b44

Browse files
committed
Support getting lastCommitMessage using contents-ext API
1 parent 662db4a commit afd5b44

File tree

7 files changed

+13
-2
lines changed

7 files changed

+13
-2
lines changed

modules/structs/repo_file.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ type ContentsResponse struct {
124124
LastCommitterDate time.Time `json:"last_committer_date"`
125125
// swagger:strfmt date-time
126126
LastAuthorDate time.Time `json:"last_author_date"`
127+
LastCommitMessage string `json:"last_commit_message"`
127128
// `type` will be `file`, `dir`, `symlink`, or `submodule`
128129
Type string `json:"type"`
129130
Size int64 `json:"size"`

services/repository/files/content.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ func getFileContentsByEntryInternal(_ context.Context, repo *repo_model.Reposito
163163
if lastCommit.Author != nil {
164164
contentsResponse.LastAuthorDate = lastCommit.Author.When
165165
}
166+
contentsResponse.LastCommitMessage = lastCommit.Message()
166167

167168
// Now populate the rest of the ContentsResponse based on entry type
168169
if entry.IsRegular() || entry.IsExecutable() {

services/repository/files/content_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
3939
LastCommitSHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
4040
LastCommitterDate: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
4141
LastAuthorDate: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
42+
LastCommitMessage: "Initial commit",
4243
Type: "file",
4344
Size: 30,
4445
Encoding: &encoding,

templates/swagger/v1_json.tmpl

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/api_repo_file_create_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func normalizeFileContentResponseCommitTime(c *api.ContentsResponse) {
5757
}
5858

5959
type apiFileResponseInfo struct {
60-
repoFullName, commitID, treePath, lastCommitSHA string
61-
lastCommitterWhen, lastAuthorWhen time.Time
60+
repoFullName, commitID, treePath, lastCommitSHA, lastCommitMessage string
61+
lastCommitterWhen, lastAuthorWhen time.Time
6262
}
6363

6464
func getExpectedFileResponseForCreate(info apiFileResponseInfo) *api.FileResponse {
@@ -77,6 +77,7 @@ func getExpectedFileResponseForCreate(info apiFileResponseInfo) *api.FileRespons
7777
LastCommitSHA: info.lastCommitSHA,
7878
LastCommitterDate: info.lastCommitterWhen,
7979
LastAuthorDate: info.lastAuthorWhen,
80+
LastCommitMessage: info.lastCommitMessage,
8081
Size: 16,
8182
Type: "file",
8283
Encoding: &encoding,
@@ -193,6 +194,7 @@ func TestAPICreateFile(t *testing.T) {
193194
lastCommitSHA: lastCommit.ID.String(),
194195
lastCommitterWhen: lastCommit.Committer.When,
195196
lastAuthorWhen: lastCommit.Author.When,
197+
lastCommitMessage: lastCommit.Message(),
196198
})
197199
var fileResponse api.FileResponse
198200
DecodeJSON(t, resp, &fileResponse)

tests/integration/api_repo_get_contents_list_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func getExpectedContentsListResponseForContents(ref, refType, lastCommitSHA stri
3838
LastCommitSHA: lastCommitSHA,
3939
LastCommitterDate: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
4040
LastAuthorDate: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
41+
LastCommitMessage: "Initial commit",
4142
Type: "file",
4243
Size: 30,
4344
URL: &selfURL,

tests/integration/api_repo_get_contents_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func getExpectedContentsResponseForContents(ref, refType, lastCommitSHA string)
3838
LastCommitSHA: lastCommitSHA,
3939
LastCommitterDate: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
4040
LastAuthorDate: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
41+
LastCommitMessage: "Initial commit",
4142
Type: "file",
4243
Size: 30,
4344
Encoding: util.ToPointer("base64"),

0 commit comments

Comments
 (0)