Skip to content

Commit 23d9697

Browse files
authored
Merge branch 'main' into feat/api-projects
2 parents 0a0837f + 0e650dc commit 23d9697

File tree

7 files changed

+183
-19
lines changed

7 files changed

+183
-19
lines changed

models/repo/topic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func syncTopicsInRepository(sess db.Engine, repoID int64) error {
366366
topicNames := make([]string, 0, 25)
367367
if err := sess.Table("topic").Cols("name").
368368
Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id").
369-
Where("repo_topic.repo_id = ?", repoID).Desc("topic.repo_count").Find(&topicNames); err != nil {
369+
Where("repo_topic.repo_id = ?", repoID).Asc("topic.name").Find(&topicNames); err != nil {
370370
return err
371371
}
372372

modules/markup/markdown/goldmark.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
8585
// 2. If they're not wrapped with a link they need a link wrapper
8686

8787
// Check if the destination is a real link
88-
link := v.Destination
89-
if len(link) > 0 && !markup.IsLink(link) {
90-
v.Destination = []byte(giteautil.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), string(link)))
88+
if len(v.Destination) > 0 && !markup.IsLink(v.Destination) {
89+
v.Destination = []byte(giteautil.URLJoin(
90+
ctx.Links.ResolveMediaLink(ctx.IsWiki),
91+
strings.TrimLeft(string(v.Destination), "/"),
92+
))
9193
}
9294

9395
parent := n.Parent()
@@ -103,7 +105,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
103105

104106
// Duplicate the current image node
105107
image := ast.NewImage(ast.NewLink())
106-
image.Destination = link
108+
image.Destination = v.Destination
107109
image.Title = v.Title
108110
for _, attr := range v.Attributes() {
109111
image.SetAttribute(attr.Name, attr.Value)

modules/markup/markdown/markdown_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ https://example.com/file.bin
580580
[[local link|file.bin]]
581581
[[remote link|https://example.com]]
582582
![local image](image.jpg)
583+
![local image](path/file)
584+
![local image](/path/file)
583585
![remote image](https://example.com/image.jpg)
584586
[[local image|image.jpg]]
585587
[[remote link|https://example.com/image.jpg]]
@@ -609,6 +611,8 @@ [email protected]
609611
<a href="/src/file.bin" rel="nofollow">local link</a><br/>
610612
<a href="https://example.com" rel="nofollow">remote link</a><br/>
611613
<a href="/image.jpg" target="_blank" rel="nofollow noopener"><img src="/image.jpg" alt="local image"/></a><br/>
614+
<a href="/path/file" target="_blank" rel="nofollow noopener"><img src="/path/file" alt="local image"/></a><br/>
615+
<a href="/path/file" target="_blank" rel="nofollow noopener"><img src="/path/file" alt="local image"/></a><br/>
612616
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
613617
<a href="/image.jpg" rel="nofollow"><img src="/image.jpg" title="local image" alt="local image"/></a><br/>
614618
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -634,6 +638,8 @@ space</p>
634638
<a href="/wiki/file.bin" rel="nofollow">local link</a><br/>
635639
<a href="https://example.com" rel="nofollow">remote link</a><br/>
636640
<a href="/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/wiki/raw/image.jpg" alt="local image"/></a><br/>
641+
<a href="/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/wiki/raw/path/file" alt="local image"/></a><br/>
642+
<a href="/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/wiki/raw/path/file" alt="local image"/></a><br/>
637643
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
638644
<a href="/wiki/raw/image.jpg" rel="nofollow"><img src="/wiki/raw/image.jpg" title="local image" alt="local image"/></a><br/>
639645
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -661,6 +667,8 @@ space</p>
661667
<a href="https://gitea.io/src/file.bin" rel="nofollow">local link</a><br/>
662668
<a href="https://example.com" rel="nofollow">remote link</a><br/>
663669
<a href="https://gitea.io/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/image.jpg" alt="local image"/></a><br/>
670+
<a href="https://gitea.io/path/file" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/path/file" alt="local image"/></a><br/>
671+
<a href="https://gitea.io/path/file" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/path/file" alt="local image"/></a><br/>
664672
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
665673
<a href="https://gitea.io/image.jpg" rel="nofollow"><img src="https://gitea.io/image.jpg" title="local image" alt="local image"/></a><br/>
666674
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -688,6 +696,8 @@ space</p>
688696
<a href="https://gitea.io/wiki/file.bin" rel="nofollow">local link</a><br/>
689697
<a href="https://example.com" rel="nofollow">remote link</a><br/>
690698
<a href="https://gitea.io/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/wiki/raw/image.jpg" alt="local image"/></a><br/>
699+
<a href="https://gitea.io/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/wiki/raw/path/file" alt="local image"/></a><br/>
700+
<a href="https://gitea.io/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/wiki/raw/path/file" alt="local image"/></a><br/>
691701
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
692702
<a href="https://gitea.io/wiki/raw/image.jpg" rel="nofollow"><img src="https://gitea.io/wiki/raw/image.jpg" title="local image" alt="local image"/></a><br/>
693703
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -715,6 +725,8 @@ space</p>
715725
<a href="/relative/path/src/file.bin" rel="nofollow">local link</a><br/>
716726
<a href="https://example.com" rel="nofollow">remote link</a><br/>
717727
<a href="/relative/path/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/image.jpg" alt="local image"/></a><br/>
728+
<a href="/relative/path/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/path/file" alt="local image"/></a><br/>
729+
<a href="/relative/path/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/path/file" alt="local image"/></a><br/>
718730
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
719731
<a href="/relative/path/image.jpg" rel="nofollow"><img src="/relative/path/image.jpg" title="local image" alt="local image"/></a><br/>
720732
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -742,6 +754,8 @@ space</p>
742754
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
743755
<a href="https://example.com" rel="nofollow">remote link</a><br/>
744756
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
757+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
758+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
745759
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
746760
<a href="/relative/path/wiki/raw/image.jpg" rel="nofollow"><img src="/relative/path/wiki/raw/image.jpg" title="local image" alt="local image"/></a><br/>
747761
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -770,6 +784,8 @@ space</p>
770784
<a href="/user/repo/src/branch/main/file.bin" rel="nofollow">local link</a><br/>
771785
<a href="https://example.com" rel="nofollow">remote link</a><br/>
772786
<a href="/user/repo/media/branch/main/image.jpg" target="_blank" rel="nofollow noopener"><img src="/user/repo/media/branch/main/image.jpg" alt="local image"/></a><br/>
787+
<a href="/user/repo/media/branch/main/path/file" target="_blank" rel="nofollow noopener"><img src="/user/repo/media/branch/main/path/file" alt="local image"/></a><br/>
788+
<a href="/user/repo/media/branch/main/path/file" target="_blank" rel="nofollow noopener"><img src="/user/repo/media/branch/main/path/file" alt="local image"/></a><br/>
773789
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
774790
<a href="/user/repo/media/branch/main/image.jpg" rel="nofollow"><img src="/user/repo/media/branch/main/image.jpg" title="local image" alt="local image"/></a><br/>
775791
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -798,6 +814,8 @@ space</p>
798814
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
799815
<a href="https://example.com" rel="nofollow">remote link</a><br/>
800816
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
817+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
818+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
801819
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
802820
<a href="/relative/path/wiki/raw/image.jpg" rel="nofollow"><img src="/relative/path/wiki/raw/image.jpg" title="local image" alt="local image"/></a><br/>
803821
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -826,6 +844,8 @@ space</p>
826844
<a href="/user/repo/src/sub/folder/file.bin" rel="nofollow">local link</a><br/>
827845
<a href="https://example.com" rel="nofollow">remote link</a><br/>
828846
<a href="/user/repo/image.jpg" target="_blank" rel="nofollow noopener"><img src="/user/repo/image.jpg" alt="local image"/></a><br/>
847+
<a href="/user/repo/path/file" target="_blank" rel="nofollow noopener"><img src="/user/repo/path/file" alt="local image"/></a><br/>
848+
<a href="/user/repo/path/file" target="_blank" rel="nofollow noopener"><img src="/user/repo/path/file" alt="local image"/></a><br/>
829849
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
830850
<a href="/user/repo/image.jpg" rel="nofollow"><img src="/user/repo/image.jpg" title="local image" alt="local image"/></a><br/>
831851
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -854,6 +874,8 @@ space</p>
854874
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
855875
<a href="https://example.com" rel="nofollow">remote link</a><br/>
856876
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
877+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
878+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
857879
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
858880
<a href="/relative/path/wiki/raw/image.jpg" rel="nofollow"><img src="/relative/path/wiki/raw/image.jpg" title="local image" alt="local image"/></a><br/>
859881
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -883,6 +905,8 @@ space</p>
883905
<a href="/user/repo/src/branch/main/sub/folder/file.bin" rel="nofollow">local link</a><br/>
884906
<a href="https://example.com" rel="nofollow">remote link</a><br/>
885907
<a href="/user/repo/media/branch/main/sub/folder/image.jpg" target="_blank" rel="nofollow noopener"><img src="/user/repo/media/branch/main/sub/folder/image.jpg" alt="local image"/></a><br/>
908+
<a href="/user/repo/media/branch/main/sub/folder/path/file" target="_blank" rel="nofollow noopener"><img src="/user/repo/media/branch/main/sub/folder/path/file" alt="local image"/></a><br/>
909+
<a href="/user/repo/media/branch/main/sub/folder/path/file" target="_blank" rel="nofollow noopener"><img src="/user/repo/media/branch/main/sub/folder/path/file" alt="local image"/></a><br/>
886910
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
887911
<a href="/user/repo/media/branch/main/sub/folder/image.jpg" rel="nofollow"><img src="/user/repo/media/branch/main/sub/folder/image.jpg" title="local image" alt="local image"/></a><br/>
888912
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>
@@ -912,6 +936,8 @@ space</p>
912936
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
913937
<a href="https://example.com" rel="nofollow">remote link</a><br/>
914938
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
939+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
940+
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
915941
<a href="https://example.com/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://example.com/image.jpg" alt="remote image"/></a><br/>
916942
<a href="/relative/path/wiki/raw/image.jpg" rel="nofollow"><img src="/relative/path/wiki/raw/image.jpg" title="local image" alt="local image"/></a><br/>
917943
<a href="https://example.com/image.jpg" rel="nofollow"><img src="https://example.com/image.jpg" title="remote link" alt="remote link"/></a><br/>

modules/repository/repo.go

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,18 @@ func StoreMissingLfsObjectsInRepository(ctx context.Context, repo *repo_model.Re
508508
return nil
509509
}
510510

511+
// shortRelease to reduce load memory, this struct can replace repo_model.Release
512+
type shortRelease struct {
513+
ID int64
514+
TagName string
515+
Sha1 string
516+
IsTag bool
517+
}
518+
519+
func (shortRelease) TableName() string {
520+
return "release"
521+
}
522+
511523
// pullMirrorReleaseSync is a pull-mirror specific tag<->release table
512524
// synchronization which overwrites all Releases from the repository tags. This
513525
// can be relied on since a pull-mirror is always identical to its
@@ -521,16 +533,20 @@ func pullMirrorReleaseSync(ctx context.Context, repo *repo_model.Repository, git
521533
return fmt.Errorf("unable to GetTagInfos in pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err)
522534
}
523535
err = db.WithTx(ctx, func(ctx context.Context) error {
524-
//
525-
// clear out existing releases
526-
//
527-
if _, err := db.DeleteByBean(ctx, &repo_model.Release{RepoID: repo.ID}); err != nil {
528-
return fmt.Errorf("unable to clear releases for pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err)
536+
dbReleases, err := db.Find[shortRelease](ctx, repo_model.FindReleasesOptions{
537+
RepoID: repo.ID,
538+
IncludeDrafts: true,
539+
IncludeTags: true,
540+
})
541+
if err != nil {
542+
return fmt.Errorf("unable to FindReleases in pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err)
529543
}
544+
545+
inserts, deletes, updates := calcSync(tags, dbReleases)
530546
//
531547
// make release set identical to upstream tags
532548
//
533-
for _, tag := range tags {
549+
for _, tag := range inserts {
534550
release := repo_model.Release{
535551
RepoID: repo.ID,
536552
TagName: tag.Name,
@@ -547,6 +563,25 @@ func pullMirrorReleaseSync(ctx context.Context, repo *repo_model.Repository, git
547563
return fmt.Errorf("unable insert tag %s for pull-mirror Repo[%d:%s/%s]: %w", tag.Name, repo.ID, repo.OwnerName, repo.Name, err)
548564
}
549565
}
566+
567+
// only delete tags releases
568+
if len(deletes) > 0 {
569+
if _, err := db.GetEngine(ctx).Where("repo_id=?", repo.ID).
570+
In("id", deletes).
571+
Delete(&repo_model.Release{}); err != nil {
572+
return fmt.Errorf("unable to delete tags for pull-mirror Repo[%d:%s/%s]: %w", repo.ID, repo.OwnerName, repo.Name, err)
573+
}
574+
}
575+
576+
for _, tag := range updates {
577+
if _, err := db.GetEngine(ctx).Where("repo_id = ? AND lower_tag_name = ?", repo.ID, strings.ToLower(tag.Name)).
578+
Cols("sha1").
579+
Update(&repo_model.Release{
580+
Sha1: tag.Object.String(),
581+
}); err != nil {
582+
return fmt.Errorf("unable to update tag %s for pull-mirror Repo[%d:%s/%s]: %w", tag.Name, repo.ID, repo.OwnerName, repo.Name, err)
583+
}
584+
}
550585
return nil
551586
})
552587
if err != nil {
@@ -556,3 +591,32 @@ func pullMirrorReleaseSync(ctx context.Context, repo *repo_model.Repository, git
556591
log.Trace("pullMirrorReleaseSync: done rebuilding %d releases", numTags)
557592
return nil
558593
}
594+
595+
func calcSync(destTags []*git.Tag, dbTags []*shortRelease) ([]*git.Tag, []int64, []*git.Tag) {
596+
destTagMap := make(map[string]*git.Tag)
597+
for _, tag := range destTags {
598+
destTagMap[tag.Name] = tag
599+
}
600+
dbTagMap := make(map[string]*shortRelease)
601+
for _, rel := range dbTags {
602+
dbTagMap[rel.TagName] = rel
603+
}
604+
605+
inserted := make([]*git.Tag, 0, 10)
606+
updated := make([]*git.Tag, 0, 10)
607+
for _, tag := range destTags {
608+
rel := dbTagMap[tag.Name]
609+
if rel == nil {
610+
inserted = append(inserted, tag)
611+
} else if rel.Sha1 != tag.Object.String() {
612+
updated = append(updated, tag)
613+
}
614+
}
615+
deleted := make([]int64, 0, 10)
616+
for _, tag := range dbTags {
617+
if destTagMap[tag.TagName] == nil && tag.IsTag {
618+
deleted = append(deleted, tag.ID)
619+
}
620+
}
621+
return inserted, deleted, updated
622+
}

modules/repository/repo_test.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package repository
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/modules/git"
10+
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func Test_calcSync(t *testing.T) {
15+
gitTags := []*git.Tag{
16+
/*{
17+
Name: "v0.1.0-beta", //deleted tag
18+
Object: git.MustIDFromString(""),
19+
},
20+
{
21+
Name: "v0.1.1-beta", //deleted tag but release should not be deleted because it's a release
22+
Object: git.MustIDFromString(""),
23+
},
24+
*/
25+
{
26+
Name: "v1.0.0", // keep as before
27+
Object: git.MustIDFromString("1006e6e13c73ad3d9e2d5682ad266b5016523485"),
28+
},
29+
{
30+
Name: "v1.1.0", // retagged with new commit id
31+
Object: git.MustIDFromString("bbdb7df30248e7d4a26a909c8d2598a152e13868"),
32+
},
33+
{
34+
Name: "v1.2.0", // new tag
35+
Object: git.MustIDFromString("a5147145e2f24d89fd6d2a87826384cc1d253267"),
36+
},
37+
}
38+
39+
dbReleases := []*shortRelease{
40+
{
41+
ID: 1,
42+
TagName: "v0.1.0-beta",
43+
Sha1: "244758d7da8dd1d9e0727e8cb7704ed4ba9a17c3",
44+
IsTag: true,
45+
},
46+
{
47+
ID: 2,
48+
TagName: "v0.1.1-beta",
49+
Sha1: "244758d7da8dd1d9e0727e8cb7704ed4ba9a17c3",
50+
IsTag: false,
51+
},
52+
{
53+
ID: 3,
54+
TagName: "v1.0.0",
55+
Sha1: "1006e6e13c73ad3d9e2d5682ad266b5016523485",
56+
},
57+
{
58+
ID: 4,
59+
TagName: "v1.1.0",
60+
Sha1: "53ab18dcecf4152b58328d1f47429510eb414d50",
61+
},
62+
}
63+
64+
inserts, deletes, updates := calcSync(gitTags, dbReleases)
65+
if assert.EqualValues(t, 1, len(inserts), "inserts") {
66+
assert.EqualValues(t, *gitTags[2], *inserts[0], "inserts equal")
67+
}
68+
69+
if assert.EqualValues(t, 1, len(deletes), "deletes") {
70+
assert.EqualValues(t, 1, deletes[0], "deletes equal")
71+
}
72+
73+
if assert.EqualValues(t, 1, len(updates), "updates") {
74+
assert.EqualValues(t, *gitTags[1], *updates[0], "updates equal")
75+
}
76+
}

0 commit comments

Comments
 (0)