Skip to content

Commit 584ec1c

Browse files
authored
Merge branch 'main' into add-label-archived-to-user-metric
2 parents ef19948 + e67f74e commit 584ec1c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

modules/structs/repo_tag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ type Tag struct {
1111
Message string `json:"message"`
1212
ID string `json:"id"`
1313
Commit *CommitMeta `json:"commit"`
14-
ZipballURL string `json:"zipball_url"`
15-
TarballURL string `json:"tarball_url"`
14+
ZipballURL string `json:"zipball_url,omitempty"`
15+
TarballURL string `json:"tarball_url,omitempty"`
1616
}
1717

1818
// AnnotatedTag represents an annotated tag

services/convert/convert.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,22 @@ func ToBranchProtection(ctx context.Context, bp *git_model.ProtectedBranch, repo
197197

198198
// ToTag convert a git.Tag to an api.Tag
199199
func ToTag(repo *repo_model.Repository, t *git.Tag) *api.Tag {
200+
tarballURL := util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz")
201+
zipballURL := util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip")
202+
203+
// Archive URLs are "" if the download feature is disabled
204+
if setting.Repository.DisableDownloadSourceArchives {
205+
tarballURL = ""
206+
zipballURL = ""
207+
}
208+
200209
return &api.Tag{
201210
Name: t.Name,
202211
Message: strings.TrimSpace(t.Message),
203212
ID: t.ID.String(),
204213
Commit: ToCommitMeta(repo, t),
205-
ZipballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".zip"),
206-
TarballURL: util.URLJoin(repo.HTMLURL(), "archive", t.Name+".tar.gz"),
214+
ZipballURL: zipballURL,
215+
TarballURL: tarballURL,
207216
}
208217
}
209218

0 commit comments

Comments
 (0)