Compare commits

...

5 Commits

Author SHA1 Message Date
techknowlogick
919348665b Add ability for local makefile with personal customizations that wouldnt affect remote repo (#35836)
This would allow developers to keep a local file that'd add personal
makefile targets for niche convenience customization without having to
have the git workspace polluted with uncommitted changes.

---------

Signed-off-by: techknowlogick <techknowlogick@gitea.com>
2025-11-08 20:23:55 +00:00
silverwind
c12bc4aa30 Add toolchain directive to go.mod (#35901)
From [docs](https://go.dev/doc/toolchain#config):

> The go line declares the minimum required Go version for using the
module or workspace. For compatibility reasons, if the go line is
omitted from a go.mod file, the module is considered to have an implicit
go 1.16 line, and if the go line is omitted from a go.work file, the
workspace is considered to have an implicit go 1.18 line.

> The toolchain line declares a suggested toolchain to use with the
module or workspace. As described in “[Go toolchain
selection](https://go.dev/doc/toolchain#select)” below, the go command
may run this specific toolchain when operating in that module or
workspace if the default toolchain’s version is less than the suggested
toolchain’s version. If the toolchain line is omitted, the module or
workspace is considered to have an implicit toolchain goV line, where V
is the Go version from the go line.

This is better than setting `go` to the latest version which may break
builds when that go version is unavailable, for example with
`GOTOOLCHAIN=local` in the official go docker images.
2025-11-08 19:48:16 +00:00
鲁汀
367a289b29 Display source code downloads last for release attachments (#35897) 2025-11-08 16:08:59 +00:00
Luohao Wang
bfaddbcd0d Fix conda null depend issue (#35900)
Fix #35895
2025-11-08 23:29:17 +08:00
wxiaoguang
0ce7d66368 Fix avatar upload error handling (#35887)
Fix #35884
2025-11-07 09:44:09 +08:00
10 changed files with 36 additions and 24 deletions

1
.gitattributes vendored
View File

@@ -8,3 +8,4 @@
/vendor/** -text -eol linguist-vendored
/web_src/js/vendor/** -text -eol linguist-vendored
Dockerfile.* linguist-language=Dockerfile
Makefile.* linguist-language=Makefile

3
.gitignore vendored
View File

@@ -127,3 +127,6 @@ prime/
# Ignore worktrees when working on multiple branches
.worktrees/
# A Makefile for custom make targets
Makefile.local

View File

@@ -198,6 +198,10 @@ TEST_MSSQL_DBNAME ?= gitea
TEST_MSSQL_USERNAME ?= sa
TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
# Include local Makefile
# Makefile.local is listed in .gitignore
sinclude Makefile.local
.PHONY: all
all: build

4
go.mod
View File

@@ -1,6 +1,8 @@
module code.gitea.io/gitea
go 1.25.4
go 1.25.0
toolchain go1.25.4
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
// But some CAs use negative serial number, just relax the check. related:

View File

@@ -148,7 +148,7 @@ func EnumeratePackages(ctx *context.Context) {
Timestamp: fileMetadata.Timestamp,
Build: fileMetadata.Build,
BuildNumber: fileMetadata.BuildNumber,
Dependencies: fileMetadata.Dependencies,
Dependencies: util.SliceNilAsEmpty(fileMetadata.Dependencies),
License: versionMetadata.License,
LicenseFamily: versionMetadata.LicenseFamily,
HashMD5: pfd.Blob.HashMD5,

View File

@@ -105,9 +105,7 @@ func (source *Source) Authenticate(ctx context.Context, user *user_model.User, u
}
}
if source.AttributeAvatar != "" {
if err := user_service.UploadAvatar(ctx, user, sr.Avatar); err != nil {
return user, err
}
_ = user_service.UploadAvatar(ctx, user, sr.Avatar)
}
}

View File

@@ -21,7 +21,7 @@ import (
func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte) error {
avatarData, err := avatar.ProcessAvatarImage(data)
if err != nil {
return err
return fmt.Errorf("UploadAvatar: failed to process repo avatar image: %w", err)
}
newAvatar := avatar.HashAvatar(repo.ID, data)
@@ -36,19 +36,19 @@ func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte)
// Then repo will be removed - only it avatar file will be removed
repo.Avatar = newAvatar
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "avatar"); err != nil {
return fmt.Errorf("UploadAvatar: Update repository avatar: %w", err)
return fmt.Errorf("UploadAvatar: failed to update repository avatar: %w", err)
}
if err := storage.SaveFrom(storage.RepoAvatars, repo.CustomAvatarRelativePath(), func(w io.Writer) error {
_, err := w.Write(avatarData)
return err
}); err != nil {
return fmt.Errorf("UploadAvatar %s failed: Failed to remove old repo avatar %s: %w", repo.RelativePath(), newAvatar, err)
return fmt.Errorf("UploadAvatar: failed to save repo avatar %s: %w", newAvatar, err)
}
if len(oldAvatarPath) > 0 {
if err := storage.RepoAvatars.Delete(oldAvatarPath); err != nil {
return fmt.Errorf("UploadAvatar: Failed to remove old repo avatar %s: %w", oldAvatarPath, err)
return fmt.Errorf("UploadAvatar: failed to remove old repo avatar %s: %w", oldAvatarPath, err)
}
}
return nil

View File

@@ -21,21 +21,21 @@ import (
func UploadAvatar(ctx context.Context, u *user_model.User, data []byte) error {
avatarData, err := avatar.ProcessAvatarImage(data)
if err != nil {
return err
return fmt.Errorf("UploadAvatar: failed to process user avatar image: %w", err)
}
return db.WithTx(ctx, func(ctx context.Context) error {
u.UseCustomAvatar = true
u.Avatar = avatar.HashAvatar(u.ID, data)
if err = user_model.UpdateUserCols(ctx, u, "use_custom_avatar", "avatar"); err != nil {
return fmt.Errorf("updateUser: %w", err)
return fmt.Errorf("UploadAvatar: failed to update user avatar: %w", err)
}
if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {
_, err := w.Write(avatarData)
return err
}); err != nil {
return fmt.Errorf("Failed to create dir %s: %w", u.CustomAvatarRelativePath(), err)
return fmt.Errorf("UploadAvatar: failed to save user avatar %s: %w", u.CustomAvatarRelativePath(), err)
}
return nil

View File

@@ -78,18 +78,6 @@
{{ctx.Locale.Tr "repo.release.downloads"}}
</summary>
<ul class="ui divided list attachment-list">
{{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
<li class="item">
<a class="archive-link" download href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow">
<strong class="flex-text-inline">{{svg "octicon-file-zip" 16 "download-icon"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong>
</a>
</li>
<li class="item">
<a class="archive-link" download href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">
<strong class="flex-text-inline">{{svg "octicon-file-zip" 16 "download-icon"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)</strong>
</a>
</li>
{{end}}
{{range $att := $release.Attachments}}
<li class="item">
<a target="_blank" class="tw-flex-1 gt-ellipsis" rel="nofollow" download href="{{$att.DownloadURL}}">
@@ -105,6 +93,18 @@
</div>
</li>
{{end}}
{{if and (not $.DisableDownloadSourceArchives) (not $release.IsDraft) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
<li class="item">
<a class="archive-link" download href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.zip" rel="nofollow">
<strong class="flex-text-inline">{{svg "octicon-file-zip" 16 "download-icon"}}{{ctx.Locale.Tr "repo.release.source_code"}} (ZIP)</strong>
</a>
</li>
<li class="item">
<a class="archive-link" download href="{{$.RepoLink}}/archive/{{$release.TagName | PathEscapeSegments}}.tar.gz" rel="nofollow">
<strong class="flex-text-inline">{{svg "octicon-file-zip" 16 "download-icon"}}{{ctx.Locale.Tr "repo.release.source_code"}} (TAR.GZ)</strong>
</a>
</li>
{{end}}
</ul>
</details>
</div>

View File

@@ -237,6 +237,8 @@ func TestPackageConda(t *testing.T) {
assert.Equal(t, pd.Files[0].Blob.HashMD5, packageInfo.HashMD5)
assert.Equal(t, pd.Files[0].Blob.HashSHA256, packageInfo.HashSHA256)
assert.Equal(t, pd.Files[0].Blob.Size, packageInfo.Size)
assert.NotNil(t, packageInfo.Dependencies)
assert.Empty(t, packageInfo.Dependencies)
})
t.Run(".conda", func(t *testing.T) {
@@ -268,6 +270,8 @@ func TestPackageConda(t *testing.T) {
assert.Equal(t, pd.Files[0].Blob.HashMD5, packageInfo.HashMD5)
assert.Equal(t, pd.Files[0].Blob.HashSHA256, packageInfo.HashSHA256)
assert.Equal(t, pd.Files[0].Blob.Size, packageInfo.Size)
assert.NotNil(t, packageInfo.Dependencies)
assert.Empty(t, packageInfo.Dependencies)
})
})
}