Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* upstream/main:
  Revert "packages: Calculate package size quota using package creator ID instead of owner ID (go-gitea#28007)" (go-gitea#28049)
  Restricted users only see repos in orgs which their team was assigned to (go-gitea#28025)
  Fix release link in changelog for v1.21.0
  Add v1.21.0 changelog (go-gitea#28005)
  Fix viewing wiki commit on empty repo (go-gitea#28040)
  Add word break to the repo list in admin settings page (go-gitea#28034)
  • Loading branch information
zjjhot committed Nov 15, 2023
2 parents 4c78dfc + f65977d commit c20bfbd
Show file tree
Hide file tree
Showing 6 changed files with 458 additions and 22 deletions.
449 changes: 448 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions models/packages/package_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,3 @@ func CalculateFileSize(ctx context.Context, opts *PackageFileSearchOptions) (int
Join("INNER", "package_blob", "package_blob.id = package_file.blob_id").
SumInt(new(PackageBlob), "size")
}

// CalculateCreatorPackageQuota sums up all blob sizes related to package
// version creator id.
// It does NOT respect the deduplication of blobs.
func CalculateCreatorPackageQuota(ctx context.Context, creatorID int64) (int64, error) {
return db.GetEngine(ctx).
Table("package_version").
Where(builder.Eq{"creator_id": creatorID}).
Join("INNER", "package_file", "package_version.id = package_file.version_id").
Join("INNER", "package_blob", "package_blob.id = package_file.blob_id").
SumInt(new(PackageBlob), "size")
}
10 changes: 5 additions & 5 deletions models/repo/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,12 @@ func AccessibleRepositoryCondition(user *user_model.User, unitType unit.Type) bu
userOrgTeamUnitRepoCond("`repository`.id", user.ID, unitType),
)
}
cond = cond.Or(
// 4. Repositories that we directly own
builder.Eq{"`repository`.owner_id": user.ID},
// 4. Repositories that we directly own
cond = cond.Or(builder.Eq{"`repository`.owner_id": user.ID})
if !user.IsRestricted {
// 5. Be able to see all public repos in private organizations that we are an org_user of
userOrgPublicRepoCond(user.ID),
)
cond = cond.Or(userOrgPublicRepoCond(user.ID))
}
}

return cond
Expand Down
1 change: 0 additions & 1 deletion routers/web/repo/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
// SetEditorconfigIfExists set editor config as render variable
func SetEditorconfigIfExists(ctx *context.Context) {
if ctx.Repo.Repository.IsEmpty {
ctx.Data["Editorconfig"] = nil
return
}

Expand Down
4 changes: 3 additions & 1 deletion services/packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ func CheckSizeQuotaExceeded(ctx context.Context, doer, owner *user_model.User, p
}

if setting.Packages.LimitTotalOwnerSize > -1 {
totalSize, err := packages_model.CalculateCreatorPackageQuota(ctx, doer.ID)
totalSize, err := packages_model.CalculateFileSize(ctx, &packages_model.PackageFileSearchOptions{
OwnerID: owner.ID,
})
if err != nil {
log.Error("CalculateFileSize failed: %v", err)
return err
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/repo/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
<tr>
<td>{{.ID}}</td>
<td>
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
<a class="gt-word-break" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
{{if .Owner.Visibility.IsPrivate}}
<span class="text gold">{{svg "octicon-lock"}}</span>
{{end}}
</td>
<td>
<a href="{{.Link}}">{{.Name}}</a>
<a class="gt-word-break" href="{{.Link}}">{{.Name}}</a>
{{if .IsArchived}}
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.archived"}}</span>
{{end}}
Expand Down

0 comments on commit c20bfbd

Please sign in to comment.