mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-18 00:01:32 -04:00
Compare commits
No commits in common. "c3d323fd859539678ac10988945cbf7af057f766" and "087df926ccd47806805fb5c63eede5827ee743c2" have entirely different histories.
c3d323fd85
...
087df926cc
@ -1,61 +0,0 @@
|
|||||||
// 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)
|
Service.UserDeleteWithCommentsMaxTime = sec.Key("USER_DELETE_WITH_COMMENTS_MAX_TIME").MustDuration(0)
|
||||||
sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https")
|
sec.Key("VALID_SITE_URL_SCHEMES").MustString("http,https")
|
||||||
Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",")
|
Service.ValidSiteURLSchemes = sec.Key("VALID_SITE_URL_SCHEMES").Strings(",")
|
||||||
schemes := make([]string, 0, len(Service.ValidSiteURLSchemes))
|
schemes := make([]string, len(Service.ValidSiteURLSchemes))
|
||||||
for _, scheme := range Service.ValidSiteURLSchemes {
|
for _, scheme := range Service.ValidSiteURLSchemes {
|
||||||
scheme = strings.ToLower(strings.TrimSpace(scheme))
|
scheme = strings.ToLower(strings.TrimSpace(scheme))
|
||||||
if scheme != "" {
|
if scheme != "" {
|
||||||
|
@ -326,9 +326,11 @@ func CreatePullRequest(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
labelIDs = make([]int64, 0, len(labels))
|
labelIDs = make([]int64, len(form.Labels))
|
||||||
for _, label := range labels {
|
orgLabelIDs := make([]int64, len(form.Labels))
|
||||||
labelIDs = append(labelIDs, label.ID)
|
|
||||||
|
for i := range labels {
|
||||||
|
labelIDs[i] = labels[i].ID
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.Repo.Owner.IsOrganization() {
|
if ctx.Repo.Owner.IsOrganization() {
|
||||||
@ -338,12 +340,12 @@ func CreatePullRequest(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
orgLabelIDs := make([]int64, 0, len(orgLabels))
|
for i := range orgLabels {
|
||||||
for _, orgLabel := range orgLabels {
|
orgLabelIDs[i] = orgLabels[i].ID
|
||||||
orgLabelIDs = append(orgLabelIDs, orgLabel.ID)
|
|
||||||
}
|
}
|
||||||
labelIDs = append(labelIDs, orgLabelIDs...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
labelIDs = append(labelIDs, orgLabelIDs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if form.Milestone > 0 {
|
if form.Milestone > 0 {
|
||||||
|
@ -459,7 +459,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
|
|||||||
rootRepo.ID != ci.HeadRepo.ID &&
|
rootRepo.ID != ci.HeadRepo.ID &&
|
||||||
rootRepo.ID != baseRepo.ID {
|
rootRepo.ID != baseRepo.ID {
|
||||||
canRead := access_model.CheckRepoUnitUser(ctx, rootRepo, ctx.Doer, unit.TypeCode)
|
canRead := access_model.CheckRepoUnitUser(ctx, rootRepo, ctx.Doer, unit.TypeCode)
|
||||||
if canRead {
|
if canRead && rootRepo.AllowsPulls() {
|
||||||
ctx.Data["RootRepo"] = rootRepo
|
ctx.Data["RootRepo"] = rootRepo
|
||||||
if !fileOnly {
|
if !fileOnly {
|
||||||
branches, tags, err := getBranchesAndTagsForRepo(ctx, rootRepo)
|
branches, tags, err := getBranchesAndTagsForRepo(ctx, rootRepo)
|
||||||
|
@ -114,12 +114,12 @@ func (t *TemporaryUploadRepository) LsFiles(filenames ...string) ([]string, erro
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
fileList := make([]string, 0, len(filenames))
|
filelist := make([]string, len(filenames))
|
||||||
for _, line := range bytes.Split(stdOut.Bytes(), []byte{'\000'}) {
|
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
|
// 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>
|
<div class="item" data-url="{{$.OwnForkRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$OwnForkCompareName}}:{{.}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and .RootRepo .RootRepo.AllowsPulls}}
|
{{if .RootRepo}}
|
||||||
{{range .RootRepoBranches}}
|
{{range .RootRepoBranches}}
|
||||||
<div class="item" data-url="{{$.RootRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$RootRepoCompareName}}:{{.}}</div>
|
<div class="item" data-url="{{$.RootRepo.Link}}/compare/{{PathEscapeSegments .}}{{$.CompareSeparator}}{{PathEscape $.HeadUser.Name}}/{{PathEscape $.HeadRepo.Name}}:{{PathEscapeSegments $.HeadBranch}}">{{$RootRepoCompareName}}:{{.}}</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user