Use gitrepo.GetTreePathLatestCommit to get file lastest commit instead from latest commit cache (#32987) (#33046)

This commit is contained in:
Giteabot 2024-12-30 13:17:07 +08:00 committed by GitHub
parent 0858a36016
commit 610b2fb88d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 21 deletions

View file

@ -25,3 +25,18 @@ func TestSubTree_Issue29101(t *testing.T) {
assert.True(t, IsErrNotExist(err))
}
}
func Test_GetTreePathLatestCommit(t *testing.T) {
repo, err := openRepositoryWithDefaultContext(filepath.Join(testReposDir, "repo6_blame"))
assert.NoError(t, err)
defer repo.Close()
commitID, err := repo.GetBranchCommitID("master")
assert.NoError(t, err)
assert.EqualValues(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
commit, err := repo.GetTreePathLatestCommit("master", "blame.txt")
assert.NoError(t, err)
assert.NotNil(t, commit)
assert.EqualValues(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())
}