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
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
package structs
|
package structs
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
// FileOptions options for all file APIs
|
// FileOptions options for all file APIs
|
||||||
type FileOptions struct {
|
type FileOptions struct {
|
||||||
// message (optional) for the commit of this file. if not supplied, a default message will be used
|
// message (optional) for the commit of this file. if not supplied, a default message will be used
|
||||||
|
@ -121,6 +123,8 @@ type ContentsResponse struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
SHA string `json:"sha"`
|
SHA string `json:"sha"`
|
||||||
LastCommitSHA string `json:"last_commit_sha"`
|
LastCommitSHA string `json:"last_commit_sha"`
|
||||||
|
// swagger:strfmt date-time
|
||||||
|
LastCommitWhen time.Time `json:"last_commit_when"`
|
||||||
// `type` will be `file`, `dir`, `symlink`, or `submodule`
|
// `type` will be `file`, `dir`, `symlink`, or `submodule`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Size int64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
|
|
|
@ -178,12 +178,13 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref
|
||||||
|
|
||||||
// All content types have these fields in populated
|
// All content types have these fields in populated
|
||||||
contentsResponse := &api.ContentsResponse{
|
contentsResponse := &api.ContentsResponse{
|
||||||
Name: entry.Name(),
|
Name: entry.Name(),
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
SHA: entry.ID.String(),
|
SHA: entry.ID.String(),
|
||||||
LastCommitSHA: lastCommit.ID.String(),
|
LastCommitSHA: lastCommit.ID.String(),
|
||||||
Size: entry.Size(),
|
LastCommitWhen: lastCommit.Committer.When,
|
||||||
URL: &selfURLString,
|
Size: entry.Size(),
|
||||||
|
URL: &selfURLString,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURLString,
|
Self: &selfURLString,
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,7 @@ package files
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"forgejo.org/models/db"
|
"forgejo.org/models/db"
|
||||||
repo_model "forgejo.org/models/repo"
|
repo_model "forgejo.org/models/repo"
|
||||||
|
@ -33,18 +34,19 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
|
||||||
gitURL := "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/" + sha
|
gitURL := "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/" + sha
|
||||||
downloadURL := "https://try.gitea.io/user2/repo1/raw/branch/master/" + treePath
|
downloadURL := "https://try.gitea.io/user2/repo1/raw/branch/master/" + treePath
|
||||||
return &api.ContentsResponse{
|
return &api.ContentsResponse{
|
||||||
Name: treePath,
|
Name: treePath,
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f",
|
SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f",
|
||||||
LastCommitSHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
|
LastCommitSHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
|
||||||
Type: "file",
|
LastCommitWhen: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
|
||||||
Size: 30,
|
Type: "file",
|
||||||
Encoding: &encoding,
|
Size: 30,
|
||||||
Content: &content,
|
Encoding: &encoding,
|
||||||
URL: &selfURL,
|
Content: &content,
|
||||||
HTMLURL: &htmlURL,
|
URL: &selfURL,
|
||||||
GitURL: &gitURL,
|
HTMLURL: &htmlURL,
|
||||||
DownloadURL: &downloadURL,
|
GitURL: &gitURL,
|
||||||
|
DownloadURL: &downloadURL,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURL,
|
Self: &selfURL,
|
||||||
GitURL: &gitURL,
|
GitURL: &gitURL,
|
||||||
|
|
5
templates/swagger/v1_json.tmpl
generated
5
templates/swagger/v1_json.tmpl
generated
|
@ -22022,6 +22022,11 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "LastCommitSHA"
|
"x-go-name": "LastCommitSHA"
|
||||||
},
|
},
|
||||||
|
"last_commit_when": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time",
|
||||||
|
"x-go-name": "LastCommitWhen"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Name"
|
"x-go-name": "Name"
|
||||||
|
|
|
@ -177,6 +177,8 @@ func TestAPICreateFile(t *testing.T) {
|
||||||
expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String())
|
||||||
var fileResponse api.FileResponse
|
var fileResponse api.FileResponse
|
||||||
DecodeJSON(t, resp, &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.Content, fileResponse.Content)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||||
|
@ -296,6 +298,8 @@ func TestAPICreateFile(t *testing.T) {
|
||||||
latestCommit, _ := gitRepo.GetCommitByPath(treePath)
|
latestCommit, _ := gitRepo.GetCommitByPath(treePath)
|
||||||
expectedFileResponse := getExpectedFileResponseForCreate("user2/"+reponame, commitID, treePath, latestCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForCreate("user2/"+reponame, commitID, treePath, latestCommit.ID.String())
|
||||||
DecodeJSON(t, resp, &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.Content, fileResponse.Content)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||||
|
|
|
@ -140,6 +140,8 @@ func TestAPIUpdateFile(t *testing.T) {
|
||||||
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String())
|
||||||
var fileResponse api.FileResponse
|
var fileResponse api.FileResponse
|
||||||
DecodeJSON(t, resp, &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.Content, fileResponse.Content)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
|
||||||
|
|
|
@ -104,6 +104,10 @@ func TestAPIChangeFiles(t *testing.T) {
|
||||||
var filesResponse api.FilesResponse
|
var filesResponse api.FilesResponse
|
||||||
DecodeJSON(t, resp, &filesResponse)
|
DecodeJSON(t, resp, &filesResponse)
|
||||||
|
|
||||||
|
// Testify cannot assert time.Time correctly.
|
||||||
|
expectedCreateFileResponse.Content.LastCommitWhen = filesResponse.Files[0].LastCommitWhen
|
||||||
|
expectedUpdateFileResponse.Content.LastCommitWhen = filesResponse.Files[1].LastCommitWhen
|
||||||
|
|
||||||
// check create file
|
// check create file
|
||||||
assert.Equal(t, expectedCreateFileResponse.Content, filesResponse.Files[0])
|
assert.Equal(t, expectedCreateFileResponse.Content, filesResponse.Files[0])
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
auth_model "forgejo.org/models/auth"
|
auth_model "forgejo.org/models/auth"
|
||||||
repo_model "forgejo.org/models/repo"
|
repo_model "forgejo.org/models/repo"
|
||||||
|
@ -32,16 +33,17 @@ func getExpectedContentsListResponseForContents(ref, refType, lastCommitSHA stri
|
||||||
downloadURL := setting.AppURL + "user2/repo1/raw/" + refType + "/" + ref + "/" + treePath
|
downloadURL := setting.AppURL + "user2/repo1/raw/" + refType + "/" + ref + "/" + treePath
|
||||||
return []*api.ContentsResponse{
|
return []*api.ContentsResponse{
|
||||||
{
|
{
|
||||||
Name: filepath.Base(treePath),
|
Name: filepath.Base(treePath),
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
SHA: sha,
|
SHA: sha,
|
||||||
LastCommitSHA: lastCommitSHA,
|
LastCommitSHA: lastCommitSHA,
|
||||||
Type: "file",
|
LastCommitWhen: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
|
||||||
Size: 30,
|
Type: "file",
|
||||||
URL: &selfURL,
|
Size: 30,
|
||||||
HTMLURL: &htmlURL,
|
URL: &selfURL,
|
||||||
GitURL: &gitURL,
|
HTMLURL: &htmlURL,
|
||||||
DownloadURL: &downloadURL,
|
GitURL: &gitURL,
|
||||||
|
DownloadURL: &downloadURL,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURL,
|
Self: &selfURL,
|
||||||
GitURL: &gitURL,
|
GitURL: &gitURL,
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
auth_model "forgejo.org/models/auth"
|
auth_model "forgejo.org/models/auth"
|
||||||
repo_model "forgejo.org/models/repo"
|
repo_model "forgejo.org/models/repo"
|
||||||
|
@ -33,18 +34,19 @@ func getExpectedContentsResponseForContents(ref, refType, lastCommitSHA string)
|
||||||
gitURL := setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha
|
gitURL := setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha
|
||||||
downloadURL := setting.AppURL + "user2/repo1/raw/" + refType + "/" + ref + "/" + treePath
|
downloadURL := setting.AppURL + "user2/repo1/raw/" + refType + "/" + ref + "/" + treePath
|
||||||
return &api.ContentsResponse{
|
return &api.ContentsResponse{
|
||||||
Name: treePath,
|
Name: treePath,
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
SHA: sha,
|
SHA: sha,
|
||||||
LastCommitSHA: lastCommitSHA,
|
LastCommitSHA: lastCommitSHA,
|
||||||
Type: "file",
|
LastCommitWhen: time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400)),
|
||||||
Size: 30,
|
Type: "file",
|
||||||
Encoding: &encoding,
|
Size: 30,
|
||||||
Content: &content,
|
Encoding: &encoding,
|
||||||
URL: &selfURL,
|
Content: &content,
|
||||||
HTMLURL: &htmlURL,
|
URL: &selfURL,
|
||||||
GitURL: &gitURL,
|
HTMLURL: &htmlURL,
|
||||||
DownloadURL: &downloadURL,
|
GitURL: &gitURL,
|
||||||
|
DownloadURL: &downloadURL,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURL,
|
Self: &selfURL,
|
||||||
GitURL: &gitURL,
|
GitURL: &gitURL,
|
||||||
|
|
|
@ -108,7 +108,7 @@ func getExpectedFileResponseForRepofilesDelete() *api.FileResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *api.FileResponse {
|
func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string, lastCommitWhen time.Time) *api.FileResponse {
|
||||||
treePath := "new/file.txt"
|
treePath := "new/file.txt"
|
||||||
encoding := "base64"
|
encoding := "base64"
|
||||||
content := "VGhpcyBpcyBhIE5FVyBmaWxl"
|
content := "VGhpcyBpcyBhIE5FVyBmaWxl"
|
||||||
|
@ -118,18 +118,19 @@ func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *
|
||||||
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + treePath
|
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + treePath
|
||||||
return &api.FileResponse{
|
return &api.FileResponse{
|
||||||
Content: &api.ContentsResponse{
|
Content: &api.ContentsResponse{
|
||||||
Name: filepath.Base(treePath),
|
Name: filepath.Base(treePath),
|
||||||
Path: treePath,
|
Path: treePath,
|
||||||
SHA: "103ff9234cefeee5ec5361d22b49fbb04d385885",
|
SHA: "103ff9234cefeee5ec5361d22b49fbb04d385885",
|
||||||
LastCommitSHA: lastCommitSHA,
|
LastCommitSHA: lastCommitSHA,
|
||||||
Type: "file",
|
LastCommitWhen: lastCommitWhen,
|
||||||
Size: 18,
|
Type: "file",
|
||||||
Encoding: &encoding,
|
Size: 18,
|
||||||
Content: &content,
|
Encoding: &encoding,
|
||||||
URL: &selfURL,
|
Content: &content,
|
||||||
HTMLURL: &htmlURL,
|
URL: &selfURL,
|
||||||
GitURL: &gitURL,
|
HTMLURL: &htmlURL,
|
||||||
DownloadURL: &downloadURL,
|
GitURL: &gitURL,
|
||||||
|
DownloadURL: &downloadURL,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURL,
|
Self: &selfURL,
|
||||||
GitURL: &gitURL,
|
GitURL: &gitURL,
|
||||||
|
@ -177,7 +178,7 @@ func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA string) *api.FileResponse {
|
func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA string, lastCommitWhen time.Time) *api.FileResponse {
|
||||||
encoding := "base64"
|
encoding := "base64"
|
||||||
content := "VGhpcyBpcyBVUERBVEVEIGNvbnRlbnQgZm9yIHRoZSBSRUFETUUgZmlsZQ=="
|
content := "VGhpcyBpcyBVUERBVEVEIGNvbnRlbnQgZm9yIHRoZSBSRUFETUUgZmlsZQ=="
|
||||||
selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + filename + "?ref=master"
|
selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + filename + "?ref=master"
|
||||||
|
@ -186,18 +187,19 @@ func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA
|
||||||
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + filename
|
downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + filename
|
||||||
return &api.FileResponse{
|
return &api.FileResponse{
|
||||||
Content: &api.ContentsResponse{
|
Content: &api.ContentsResponse{
|
||||||
Name: filename,
|
Name: filename,
|
||||||
Path: filename,
|
Path: filename,
|
||||||
SHA: "dbf8d00e022e05b7e5cf7e535de857de57925647",
|
SHA: "dbf8d00e022e05b7e5cf7e535de857de57925647",
|
||||||
LastCommitSHA: lastCommitSHA,
|
LastCommitSHA: lastCommitSHA,
|
||||||
Type: "file",
|
LastCommitWhen: lastCommitWhen,
|
||||||
Size: 43,
|
Type: "file",
|
||||||
Encoding: &encoding,
|
Size: 43,
|
||||||
Content: &content,
|
Encoding: &encoding,
|
||||||
URL: &selfURL,
|
Content: &content,
|
||||||
HTMLURL: &htmlURL,
|
URL: &selfURL,
|
||||||
GitURL: &gitURL,
|
HTMLURL: &htmlURL,
|
||||||
DownloadURL: &downloadURL,
|
GitURL: &gitURL,
|
||||||
|
DownloadURL: &downloadURL,
|
||||||
Links: &api.FileLinksResponse{
|
Links: &api.FileLinksResponse{
|
||||||
Self: &selfURL,
|
Self: &selfURL,
|
||||||
GitURL: &gitURL,
|
GitURL: &gitURL,
|
||||||
|
@ -264,7 +266,7 @@ func TestChangeRepoFiles(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
lastCommit, err := gitRepo.GetCommitByPath("new/file.txt")
|
lastCommit, err := gitRepo.GetCommitByPath("new/file.txt")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesCreate(commitID, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesCreate(commitID, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||||
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||||
|
@ -282,7 +284,7 @@ func TestChangeRepoFiles(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
lastCommit, err := commit.GetCommitByPath(opts.Files[0].TreePath)
|
lastCommit, err := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||||
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
|
||||||
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
|
||||||
|
@ -303,7 +305,7 @@ func TestChangeRepoFiles(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
lastCommit, err := commit.GetCommitByPath(opts.Files[0].TreePath)
|
lastCommit, err := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
|
|
||||||
// assert that the old file no longer exists in the last commit of the branch
|
// assert that the old file no longer exists in the last commit of the branch
|
||||||
fromEntry, err := commit.GetTreeEntryByPath(opts.Files[0].FromTreePath)
|
fromEntry, err := commit.GetTreeEntryByPath(opts.Files[0].FromTreePath)
|
||||||
|
@ -339,7 +341,7 @@ func TestChangeRepoFiles(t *testing.T) {
|
||||||
|
|
||||||
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
|
||||||
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
|
||||||
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
|
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String(), lastCommit.Committer.When)
|
||||||
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue