fix: make syncronize tags to database handle annoted tags

- When an admin wants syncronize tags in the Git data to the database
via the admin dashboard all annoted tags loses their title. This was
caused because the code didn't correctly handle annoted tags. Annoted
tags have their own objectID to store the annoted message, unlike
'normal' tags which point to the commitID. While the function was being
run for annoted tags, the code thought it found a mismatch in the
objectIDs, because the stored version was actually correct which pointed
to the commitID but the code found the objectID of the annoted tag.
- Make `SyncReleasesWithTags` corectly handle annoted tags.
- Added unit and integration tests.
- Resolves #5628
This commit is contained in:
Gusted 2024-10-21 15:48:22 +02:00
parent ea70757fc7
commit 6da194fae8
4 changed files with 94 additions and 3 deletions

View file

@ -101,3 +101,40 @@ func TestRepository_CommitsBetweenIDs(t *testing.T) {
assert.Len(t, commits, c.ExpectedCommits, "case %d", i)
}
}
func TestGetTagCommit(t *testing.T) {
t.Setenv("GIT_COMMITTER_DATE", "2006-01-01 13:37")
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
clonedPath, err := cloneRepo(t, bareRepo1Path)
require.NoError(t, err)
bareRepo1, err := openRepositoryWithDefaultContext(clonedPath)
require.NoError(t, err)
defer bareRepo1.Close()
lTagCommitID := "6fbd69e9823458e6c4a2fc5c0f6bc022b2f2acd1"
lTagName := "lightweightTag"
bareRepo1.CreateTag(lTagName, lTagCommitID)
aTagCommitID := "8006ff9adbf0cb94da7dad9e537e53817f9fa5c0"
aTagName := "annotatedTag"
aTagMessage := "my annotated message"
bareRepo1.CreateAnnotatedTag(aTagName, aTagMessage, aTagCommitID)
aTagID, err := bareRepo1.GetTagCommitID(aTagName)
require.NoError(t, err)
assert.NotEqualValues(t, aTagCommitID, aTagID)
lTagID, err := bareRepo1.GetTagCommitID(lTagName)
require.NoError(t, err)
assert.EqualValues(t, lTagCommitID, lTagID)
aTag, err := bareRepo1.GetTagCommit(aTagName)
require.NoError(t, err)
assert.EqualValues(t, aTagCommitID, aTag.ID.String())
lTag, err := bareRepo1.GetTagCommit(lTagName)
require.NoError(t, err)
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
}