mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-04 05:11:48 +02:00
feat(api): add last_commit_when
to contents response (#7418)
- Add a new field `last_commit_when` to the `ContentResponse` type, which is populated with the last commit's commiter date. This can be used to determine when the last edit of the content was. - This field is compatible with what Gitea will likely add, https://github.com/go-gitea/gitea/pull/32921. There's no field for this information in the Github API, so no way to be compatible with that (this API endpoint is otherwise fully compatible with Github's API). - Ref: gitnex/GitNex#1225 - Integration test adjusted. The API tests cannot test the actual output, as `testify` tries to 'deep equal' the `time.Time` structs which will differ due how the `time.Time` struct is created. Unit tests still verify the output. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7418 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
813eabc340
commit
23cc1fdbbe
10 changed files with 98 additions and 70 deletions
|
@ -140,6 +140,8 @@ func TestAPIUpdateFile(t *testing.T) {
|
|||
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String())
|
||||
var fileResponse api.FileResponse
|
||||
DecodeJSON(t, resp, &fileResponse)
|
||||
// Testify cannot assert time.Time correctly.
|
||||
expectedFileResponse.Content.LastCommitWhen = fileResponse.Content.LastCommitWhen
|
||||
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
|
||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue