mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-17 00:01:00 -04:00
Compare commits
3 Commits
087df926cc
...
c3d323fd85
Author | SHA1 | Date | |
---|---|---|---|
|
c3d323fd85 | ||
|
4013f3f600 | ||
|
3bab20491e |
61
modules/doctor/fix8312.go
Normal file
61
modules/doctor/fix8312.go
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright 2023 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package doctor
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
org_model "code.gitea.io/gitea/models/organization"
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
func fixOwnerTeamCreateOrgRepo(ctx context.Context, logger log.Logger, autofix bool) error {
|
||||
count := 0
|
||||
|
||||
err := db.Iterate(
|
||||
ctx,
|
||||
builder.Eq{"authorize": perm.AccessModeOwner, "can_create_org_repo": false},
|
||||
func(ctx context.Context, team *org_model.Team) error {
|
||||
team.CanCreateOrgRepo = true
|
||||
count++
|
||||
|
||||
if !autofix {
|
||||
return nil
|
||||
}
|
||||
|
||||
return models.UpdateTeam(team, false, false)
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
logger.Critical("Unable to iterate across repounits to fix incorrect can_create_org_repo: Error %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if !autofix {
|
||||
if count == 0 {
|
||||
logger.Info("Found no team with incorrect can_create_org_repo")
|
||||
} else {
|
||||
logger.Warn("Found %d teams with incorrect can_create_org_repo", count)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
logger.Info("Fixed %d teams with incorrect can_create_org_repo", count)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
Register(&Check{
|
||||
Title: "Check for incorrect can_create_org_repo for org owner teams",
|
||||
Name: "fix-owner-team-create-org-repo",
|
||||
IsDefault: false,
|
||||
Run: fixOwnerTeamCreateOrgRepo,
|
||||
Priority: 7,
|
||||
})
|
||||
}
|
@ -221,7 +221,7 @@ func loadServiceFrom(rootCfg ConfigProvider) {
|
||||
Service.UserDeleteWithCommentsMaxTime = sec.Key("USER_DELETE_WITH_COMMENTS_MAX_TIME").MustDuration(0)
|
||||
sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https")
|
||||
Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",")
|
||||
schemes := make([]string, len(Service.ValidSiteURLSchemes))
|
||||
schemes := make([]string, 0, len(Service.ValidSiteURLSchemes))
|
||||
for _, scheme := range Service.ValidSiteURLSchemes {
|
||||
scheme = strings.ToLower(strings.TrimSpace(scheme))
|
||||
if scheme != "" {
|
||||
|
@ -326,11 +326,9 @@ func CreatePullRequest(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
labelIDs = make([]int64, len(form.Labels))
|
||||
orgLabelIDs := make([]int64, len(form.Labels))
|
||||
|
||||
for i := range labels {
|
||||
labelIDs[i] = labels[i].ID
|
||||
labelIDs = make([]int64, 0, len(labels))
|
||||
for _, label := range labels {
|
||||
labelIDs = append(labelIDs, label.ID)
|
||||
}
|
||||
|
||||
if ctx.Repo.Owner.IsOrganization() {
|
||||
@ -340,12 +338,12 @@ func CreatePullRequest(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
|
||||
for i := range orgLabels {
|
||||
orgLabelIDs[i] = orgLabels[i].ID
|
||||
orgLabelIDs := make([]int64, 0, len(orgLabels))
|
||||
for _, orgLabel := range orgLabels {
|
||||
orgLabelIDs = append(orgLabelIDs, orgLabel.ID)
|
||||
}
|
||||
labelIDs = append(labelIDs, orgLabelIDs...)
|
||||
}
|
||||
|
||||
labelIDs = append(labelIDs, orgLabelIDs...)
|
||||
}
|
||||
|
||||
if form.Milestone > 0 {
|
||||
|
@ -459,7 +459,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
|
||||
rootRepo.ID != ci.HeadRepo.ID &&
|
||||
rootRepo.ID != baseRepo.ID {
|
||||
canRead := access_model.CheckRepoUnitUser(ctx, rootRepo, ctx.Doer, unit.TypeCode)
|
||||
if canRead && rootRepo.AllowsPulls() {
|
||||
if canRead {
|
||||
ctx.Data["RootRepo"] = rootRepo
|
||||
if !fileOnly {
|
||||
branches, tags, err := getBranchesAndTagsForRepo(ctx, rootRepo)
|
||||
|
@ -114,12 +114,12 @@ func (t *TemporaryUploadRepository) LsFiles(filenames ...string) ([]string, erro
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filelist := make([]string, len(filenames))
|
||||
fileList := make([]string, 0, len(filenames))
|
||||
for _, line := range bytes.Split(stdOut.Bytes(), []byte{'\000'}) {
|
||||
filelist = append(filelist, string(line))
|
||||
fileList = append(fileList, string(line))
|
||||
}
|
||||
|
||||
return filelist, nil
|
||||
return fileList, nil
|
||||
}
|
||||
|
||||
// RemoveFilesFromIndex removes the given files from the index
|
||||
|
@ -77,7 +77,7 @@
|
||||
<div class="item" data-url="{{$.OwnForkRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$OwnForkCompareName}}:{{.}}</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if .RootRepo}}
|
||||
{{if and .RootRepo .RootRepo.AllowsPulls}}
|
||||
{{range .RootRepoBranches}}
|
||||
<div class="item" data-url="{{$.RootRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$RootRepoCompareName}}:{{.}}</div>
|
||||
{{end}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user