0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-05 21:16:11 +01:00

Merge branch 'main' into dependabot-trial

This commit is contained in:
techknowlogick 2025-08-08 12:48:57 -04:00 committed by GitHub
commit 63c9ccd226
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 132 additions and 27 deletions

View File

@ -48,6 +48,17 @@ ifeq ($(HAS_GO), yes)
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS) CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
endif endif
CGO_ENABLED ?= 0
ifneq (,$(findstring sqlite,$(TAGS))$(findstring pam,$(TAGS)))
CGO_ENABLED = 1
endif
STATIC ?=
EXTLDFLAGS ?=
ifneq ($(STATIC),)
EXTLDFLAGS = -extldflags "-static"
endif
ifeq ($(GOOS),windows) ifeq ($(GOOS),windows)
IS_WINDOWS := yes IS_WINDOWS := yes
else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows) else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows)
@ -746,7 +757,10 @@ security-check:
go run $(GOVULNCHECK_PACKAGE) -show color ./... go run $(GOVULNCHECK_PACKAGE) -show color ./...
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ) $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ ifneq ($(and $(STATIC),$(findstring pam,$(TAGS))),)
$(error pam support set via TAGS doesn't support static builds)
endif
CGO_ENABLED="$(CGO_ENABLED)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(EXTLDFLAGS) $(LDFLAGS)' -o $@
.PHONY: release .PHONY: release
release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-check release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-check

View File

@ -11,33 +11,45 @@
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in in
{ {
devShells.default = pkgs.mkShell { devShells.default =
buildInputs = with pkgs; [ with pkgs;
# generic let
git # only bump toolchain versions here
git-lfs go = go_1_24;
gnumake nodejs = nodejs_24;
gnused python3 = python312;
gnutar in
gzip pkgs.mkShell {
buildInputs = [
# generic
git
git-lfs
gnumake
gnused
gnutar
gzip
# frontend # frontend
nodejs_22 nodejs
# linting # linting
python312 python3
uv uv
# backend # backend
go_1_24 go
gofumpt glibc.static
sqlite gofumpt
]; sqlite
shellHook = '' ];
export GO="${pkgs.go_1_24}/bin/go" CFLAGS = "-I${glibc.static.dev}/include";
export GOROOT="${pkgs.go_1_24}/share/go" LDFLAGS = "-L ${glibc.static}/lib";
''; GO = "${go}/bin/go";
}; GOROOT = "${go}/share/go";
TAGS = "sqlite sqlite_unlock_notify";
STATIC = "true";
};
} }
); );
} }

2
go.mod
View File

@ -1,6 +1,6 @@
module code.gitea.io/gitea module code.gitea.io/gitea
go 1.24.5 go 1.24.6
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate." // 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: // But some CAs use negative serial number, just relax the check. related:

View File

@ -84,6 +84,7 @@ type Repository struct {
Updated time.Time `json:"updated_at"` Updated time.Time `json:"updated_at"`
ArchivedAt time.Time `json:"archived_at"` ArchivedAt time.Time `json:"archived_at"`
Permissions *Permission `json:"permissions,omitempty"` Permissions *Permission `json:"permissions,omitempty"`
HasCode bool `json:"has_code"`
HasIssues bool `json:"has_issues"` HasIssues bool `json:"has_issues"`
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"` InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"` ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
@ -170,6 +171,8 @@ type EditRepoOption struct {
Private *bool `json:"private,omitempty"` Private *bool `json:"private,omitempty"`
// either `true` to make this repository a template or `false` to make it a normal repository // either `true` to make this repository a template or `false` to make it a normal repository
Template *bool `json:"template,omitempty"` Template *bool `json:"template,omitempty"`
// either `true` to enable code for this repository or `false` to disable it.
HasCode *bool `json:"has_code,omitempty"`
// either `true` to enable issues for this repository or `false` to disable them. // either `true` to enable issues for this repository or `false` to disable them.
HasIssues *bool `json:"has_issues,omitempty"` HasIssues *bool `json:"has_issues,omitempty"`
// set this structure to configure internal issue tracker // set this structure to configure internal issue tracker

View File

@ -1322,7 +1322,7 @@ commit_graph.color=Couleur
commit.contained_in=Cette révision appartient à : commit.contained_in=Cette révision appartient à :
commit.contained_in_default_branch=Cette révision appartient à la branche par défaut commit.contained_in_default_branch=Cette révision appartient à la branche par défaut
commit.load_referencing_branches_and_tags=Charger les branches et étiquettes référençant cette révision commit.load_referencing_branches_and_tags=Charger les branches et étiquettes référençant cette révision
commit.merged_in_pr=Cette révision a été fusionnée dans la demande dajour %s. commit.merged_in_pr=Cette révision a été fusionnée dans la demande dajout %s.
blame=Annotations blame=Annotations
download_file=Télécharger le fichier download_file=Télécharger le fichier
normal_view=Vue normale normal_view=Vue normale

View File

@ -1322,6 +1322,7 @@ commit_graph.color=Dath
commit.contained_in=Tá an tiomantas seo le fáil i: commit.contained_in=Tá an tiomantas seo le fáil i:
commit.contained_in_default_branch=Tá an tiomantas seo mar chuid den bhrainse réamhshocraithe commit.contained_in_default_branch=Tá an tiomantas seo mar chuid den bhrainse réamhshocraithe
commit.load_referencing_branches_and_tags=Luchtaigh brainsí agus clibeanna a thagraíonn an tiomantas commit.load_referencing_branches_and_tags=Luchtaigh brainsí agus clibeanna a thagraíonn an tiomantas
commit.merged_in_pr=Cuireadh an tiomantas seo le chéile san iarratas tarraingthe %s.
blame=An milleán blame=An milleán
download_file=Íoslódáil comhad download_file=Íoslódáil comhad
normal_view=Amharc Gnáth normal_view=Amharc Gnáth

View File

@ -869,6 +869,18 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
} }
} }
if opts.HasCode != nil && !unit_model.TypeCode.UnitGlobalDisabled() {
if *opts.HasCode {
units = append(units, repo_model.RepoUnit{
RepoID: repo.ID,
Type: unit_model.TypeCode,
Config: &repo_model.UnitConfig{},
})
} else {
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeCode)
}
}
if opts.HasPullRequests != nil && !unit_model.TypePullRequests.UnitGlobalDisabled() { if opts.HasPullRequests != nil && !unit_model.TypePullRequests.UnitGlobalDisabled() {
if *opts.HasPullRequests { if *opts.HasPullRequests {
// We do allow setting individual PR settings through the API, so // We do allow setting individual PR settings through the API, so

View File

@ -24333,6 +24333,11 @@
"type": "boolean", "type": "boolean",
"x-go-name": "HasActions" "x-go-name": "HasActions"
}, },
"has_code": {
"description": "either `true` to enable code for this repository or `false` to disable it.",
"type": "boolean",
"x-go-name": "HasCode"
},
"has_issues": { "has_issues": {
"description": "either `true` to enable issues for this repository or `false` to disable them.", "description": "either `true` to enable issues for this repository or `false` to disable them.",
"type": "boolean", "type": "boolean",
@ -27375,6 +27380,10 @@
"type": "boolean", "type": "boolean",
"x-go-name": "HasActions" "x-go-name": "HasActions"
}, },
"has_code": {
"type": "boolean",
"x-go-name": "HasCode"
},
"has_issues": { "has_issues": {
"type": "boolean", "type": "boolean",
"x-go-name": "HasIssues" "x-go-name": "HasIssues"

View File

@ -76,12 +76,36 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
allowFastForwardOnly = config.AllowFastForwardOnly allowFastForwardOnly = config.AllowFastForwardOnly
} }
archived := repo.IsArchived archived := repo.IsArchived
hasProjects := false
var projectsMode *string
if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeProjects); err == nil && unit != nil {
hasProjects = true
pm := string(unit.ProjectsConfig().ProjectsMode)
projectsMode = &pm
}
hasCode := repo.UnitEnabled(db.DefaultContext, unit_model.TypeCode)
hasPackages := repo.UnitEnabled(db.DefaultContext, unit_model.TypePackages)
hasReleases := repo.UnitEnabled(db.DefaultContext, unit_model.TypeReleases)
hasActions := false
if unit, err := repo.GetUnit(db.DefaultContext, unit_model.TypeActions); err == nil && unit != nil {
hasActions = true
// TODO: expose action config of repo to api
// actionsConfig = &api.RepoActionsConfig{
// DisabledWorkflows: unit.ActionsConfig().DisabledWorkflows,
// }
}
return &api.EditRepoOption{ return &api.EditRepoOption{
Name: &name, Name: &name,
Description: &description, Description: &description,
Website: &website, Website: &website,
Private: &private, Private: &private,
HasIssues: &hasIssues, HasIssues: &hasIssues,
HasProjects: &hasProjects,
ProjectsMode: projectsMode,
HasCode: &hasCode,
HasPackages: &hasPackages,
HasReleases: &hasReleases,
HasActions: &hasActions,
ExternalTracker: externalTracker, ExternalTracker: externalTracker,
InternalTracker: internalTracker, InternalTracker: internalTracker,
HasWiki: &hasWiki, HasWiki: &hasWiki,
@ -108,6 +132,11 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
private := !*opts.Private private := !*opts.Private
hasIssues := !*opts.HasIssues hasIssues := !*opts.HasIssues
hasWiki := !*opts.HasWiki hasWiki := !*opts.HasWiki
hasProjects := !*opts.HasProjects
hasCode := !*opts.HasCode
hasPackages := !*opts.HasPackages
hasReleases := !*opts.HasReleases
hasActions := !*opts.HasActions
defaultBranch := "master" defaultBranch := "master"
hasPullRequests := !*opts.HasPullRequests hasPullRequests := !*opts.HasPullRequests
ignoreWhitespaceConflicts := !*opts.IgnoreWhitespaceConflicts ignoreWhitespaceConflicts := !*opts.IgnoreWhitespaceConflicts
@ -125,6 +154,11 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
DefaultBranch: &defaultBranch, DefaultBranch: &defaultBranch,
HasIssues: &hasIssues, HasIssues: &hasIssues,
HasWiki: &hasWiki, HasWiki: &hasWiki,
HasProjects: &hasProjects,
HasCode: &hasCode,
HasPackages: &hasPackages,
HasReleases: &hasReleases,
HasActions: &hasActions,
HasPullRequests: &hasPullRequests, HasPullRequests: &hasPullRequests,
IgnoreWhitespaceConflicts: &ignoreWhitespaceConflicts, IgnoreWhitespaceConflicts: &ignoreWhitespaceConflicts,
AllowMerge: &allowMerge, AllowMerge: &allowMerge,
@ -156,6 +190,11 @@ func TestAPIRepoEdit(t *testing.T) {
// Test editing a repo1 which user2 owns, changing name and many properties // Test editing a repo1 which user2 owns, changing name and many properties
origRepoEditOption := getRepoEditOptionFromRepo(repo1) origRepoEditOption := getRepoEditOptionFromRepo(repo1)
assert.True(t, *origRepoEditOption.HasCode)
assert.True(t, *origRepoEditOption.HasPackages)
assert.True(t, *origRepoEditOption.HasProjects)
assert.True(t, *origRepoEditOption.HasReleases)
assert.True(t, *origRepoEditOption.HasActions)
repoEditOption := getNewRepoEditOption(origRepoEditOption) repoEditOption := getNewRepoEditOption(origRepoEditOption)
req := NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, repo1.Name), &repoEditOption). req := NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, repo1.Name), &repoEditOption).
AddTokenAuth(token2) AddTokenAuth(token2)
@ -177,6 +216,11 @@ func TestAPIRepoEdit(t *testing.T) {
assert.Equal(t, *repoEditOption.Archived, *repo1editedOption.Archived) assert.Equal(t, *repoEditOption.Archived, *repo1editedOption.Archived)
assert.Equal(t, *repoEditOption.Private, *repo1editedOption.Private) assert.Equal(t, *repoEditOption.Private, *repo1editedOption.Private)
assert.Equal(t, *repoEditOption.HasWiki, *repo1editedOption.HasWiki) assert.Equal(t, *repoEditOption.HasWiki, *repo1editedOption.HasWiki)
assert.Equal(t, *repoEditOption.HasCode, *repo1editedOption.HasCode)
assert.Equal(t, *repoEditOption.HasPackages, *repo1editedOption.HasPackages)
assert.Equal(t, *repoEditOption.HasProjects, *repo1editedOption.HasProjects)
assert.Equal(t, *repoEditOption.HasReleases, *repo1editedOption.HasReleases)
assert.Equal(t, *repoEditOption.HasActions, *repo1editedOption.HasActions)
// Test editing repo1 to use internal issue and wiki (default) // Test editing repo1 to use internal issue and wiki (default)
*repoEditOption.HasIssues = true *repoEditOption.HasIssues = true
@ -224,6 +268,11 @@ func TestAPIRepoEdit(t *testing.T) {
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker) assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
assert.True(t, *repo1editedOption.HasWiki) assert.True(t, *repo1editedOption.HasWiki)
assert.Equal(t, *repo1editedOption.ExternalWiki, *repoEditOption.ExternalWiki) assert.Equal(t, *repo1editedOption.ExternalWiki, *repoEditOption.ExternalWiki)
assert.False(t, *repo1editedOption.HasCode)
assert.False(t, *repo1editedOption.HasPackages)
assert.False(t, *repo1editedOption.HasProjects)
assert.False(t, *repo1editedOption.HasReleases)
assert.False(t, *repo1editedOption.HasActions)
repoEditOption.ExternalTracker.ExternalTrackerStyle = "regexp" repoEditOption.ExternalTracker.ExternalTrackerStyle = "regexp"
repoEditOption.ExternalTracker.ExternalTrackerRegexpPattern = `(\d+)` repoEditOption.ExternalTracker.ExternalTrackerRegexpPattern = `(\d+)`
@ -272,6 +321,11 @@ func TestAPIRepoEdit(t *testing.T) {
assert.NotNil(t, *repo1editedOption.ExternalTracker) assert.NotNil(t, *repo1editedOption.ExternalTracker)
assert.True(t, *repo1editedOption.HasWiki) assert.True(t, *repo1editedOption.HasWiki)
assert.NotNil(t, *repo1editedOption.ExternalWiki) assert.NotNil(t, *repo1editedOption.ExternalWiki)
assert.False(t, *repo1editedOption.HasCode)
assert.False(t, *repo1editedOption.HasPackages)
assert.False(t, *repo1editedOption.HasProjects)
assert.False(t, *repo1editedOption.HasReleases)
assert.False(t, *repo1editedOption.HasActions)
// reset repo in db // reset repo in db
req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, *repoEditOption.Name), &origRepoEditOption). req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, *repoEditOption.Name), &origRepoEditOption).