0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-11-05 10:25:30 +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)
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)
IS_WINDOWS := yes
else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows)
@ -746,7 +757,10 @@ security-check:
go run $(GOVULNCHECK_PACKAGE) -show color ./...
$(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
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};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# generic
git
git-lfs
gnumake
gnused
gnutar
gzip
devShells.default =
with pkgs;
let
# only bump toolchain versions here
go = go_1_24;
nodejs = nodejs_24;
python3 = python312;
in
pkgs.mkShell {
buildInputs = [
# generic
git
git-lfs
gnumake
gnused
gnutar
gzip
# frontend
nodejs_22
# frontend
nodejs
# linting
python312
uv
# linting
python3
uv
# backend
go_1_24
gofumpt
sqlite
];
shellHook = ''
export GO="${pkgs.go_1_24}/bin/go"
export GOROOT="${pkgs.go_1_24}/share/go"
'';
};
# backend
go
glibc.static
gofumpt
sqlite
];
CFLAGS = "-I${glibc.static.dev}/include";
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
go 1.24.5
go 1.24.6
// 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

@ -84,6 +84,7 @@ type Repository struct {
Updated time.Time `json:"updated_at"`
ArchivedAt time.Time `json:"archived_at"`
Permissions *Permission `json:"permissions,omitempty"`
HasCode bool `json:"has_code"`
HasIssues bool `json:"has_issues"`
InternalTracker *InternalTracker `json:"internal_tracker,omitempty"`
ExternalTracker *ExternalTracker `json:"external_tracker,omitempty"`
@ -170,6 +171,8 @@ type EditRepoOption struct {
Private *bool `json:"private,omitempty"`
// either `true` to make this repository a template or `false` to make it a normal repository
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.
HasIssues *bool `json:"has_issues,omitempty"`
// 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_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.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
download_file=Télécharger le fichier
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_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.merged_in_pr=Cuireadh an tiomantas seo le chéile san iarratas tarraingthe %s.
blame=An milleán
download_file=Íoslódáil comhad
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 {
// We do allow setting individual PR settings through the API, so

View File

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

View File

@ -76,12 +76,36 @@ func getRepoEditOptionFromRepo(repo *repo_model.Repository) *api.EditRepoOption
allowFastForwardOnly = config.AllowFastForwardOnly
}
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{
Name: &name,
Description: &description,
Website: &website,
Private: &private,
HasIssues: &hasIssues,
HasProjects: &hasProjects,
ProjectsMode: projectsMode,
HasCode: &hasCode,
HasPackages: &hasPackages,
HasReleases: &hasReleases,
HasActions: &hasActions,
ExternalTracker: externalTracker,
InternalTracker: internalTracker,
HasWiki: &hasWiki,
@ -108,6 +132,11 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
private := !*opts.Private
hasIssues := !*opts.HasIssues
hasWiki := !*opts.HasWiki
hasProjects := !*opts.HasProjects
hasCode := !*opts.HasCode
hasPackages := !*opts.HasPackages
hasReleases := !*opts.HasReleases
hasActions := !*opts.HasActions
defaultBranch := "master"
hasPullRequests := !*opts.HasPullRequests
ignoreWhitespaceConflicts := !*opts.IgnoreWhitespaceConflicts
@ -125,6 +154,11 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
DefaultBranch: &defaultBranch,
HasIssues: &hasIssues,
HasWiki: &hasWiki,
HasProjects: &hasProjects,
HasCode: &hasCode,
HasPackages: &hasPackages,
HasReleases: &hasReleases,
HasActions: &hasActions,
HasPullRequests: &hasPullRequests,
IgnoreWhitespaceConflicts: &ignoreWhitespaceConflicts,
AllowMerge: &allowMerge,
@ -156,6 +190,11 @@ func TestAPIRepoEdit(t *testing.T) {
// Test editing a repo1 which user2 owns, changing name and many properties
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)
req := NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, repo1.Name), &repoEditOption).
AddTokenAuth(token2)
@ -177,6 +216,11 @@ func TestAPIRepoEdit(t *testing.T) {
assert.Equal(t, *repoEditOption.Archived, *repo1editedOption.Archived)
assert.Equal(t, *repoEditOption.Private, *repo1editedOption.Private)
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)
*repoEditOption.HasIssues = true
@ -224,6 +268,11 @@ func TestAPIRepoEdit(t *testing.T) {
assert.Equal(t, *repo1editedOption.ExternalTracker, *repoEditOption.ExternalTracker)
assert.True(t, *repo1editedOption.HasWiki)
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.ExternalTrackerRegexpPattern = `(\d+)`
@ -272,6 +321,11 @@ func TestAPIRepoEdit(t *testing.T) {
assert.NotNil(t, *repo1editedOption.ExternalTracker)
assert.True(t, *repo1editedOption.HasWiki)
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
req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, *repoEditOption.Name), &origRepoEditOption).