Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  [skip ci] Updated licenses and gitignores
  Comment on PrivateUsers option for gitea.service (go-gitea#20383)
  [skip ci] Updated translations via Crowdin
  Remove confusing TrimPrefix(... git.BranchPrefix) (go-gitea#20369)
  Set target on create release with existing tag (go-gitea#20381)
  Initialize cron last (go-gitea#20373)
  Allow access to the Public Organization Member lists with minimal permissions (go-gitea#20330)
  • Loading branch information
zjjhot committed Jul 18, 2022
2 parents 099187d + 17ce5f8 commit 7fa3229
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 16 deletions.
7 changes: 7 additions & 0 deletions contrib/systemd/gitea.service
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
###
# In some cases, when using CapabilityBoundingSet and AmbientCapabilities option, you may want to
# set the following value to false to allow capabilities to be applied on gitea process. The following
# value if set to true sandboxes gitea service and prevent any processes from running with privileges
# in the host user namespace.
###
#PrivateUsers=false
###

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions modules/context/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models/perm"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
)

// Organization contains organization context
Expand Down Expand Up @@ -69,6 +70,20 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
return
}
org := ctx.Org.Organization

// Handle Visibility
if org.Visibility != structs.VisibleTypePublic && !ctx.IsSigned {
// We must be signed in to see limited or private organizations
ctx.NotFound("OrgAssignment", err)
return
}

if org.Visibility == structs.VisibleTypePrivate {
requireMember = true
} else if ctx.IsSigned && ctx.Doer.IsRestricted {
requireMember = true
}

ctx.ContextUser = org.AsUser()
ctx.Data["Org"] = org

Expand Down
10 changes: 9 additions & 1 deletion modules/git/repo_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package git

import (
"context"
"errors"
"fmt"
"strings"
)
Expand Down Expand Up @@ -72,7 +73,14 @@ func (repo *Repository) SetDefaultBranch(name string) error {
// GetDefaultBranch gets default branch of repository.
func (repo *Repository) GetDefaultBranch() (string, error) {
stdout, _, err := NewCommand(repo.Ctx, "symbolic-ref", "HEAD").RunStdString(&RunOpts{Dir: repo.Path})
return stdout, err
if err != nil {
return "", err
}
stdout = strings.TrimSpace(stdout)
if !strings.HasPrefix(stdout, BranchPrefix) {
return "", errors.New("the HEAD is not a branch: " + stdout)
}
return strings.TrimPrefix(stdout, BranchPrefix), nil
}

// GetBranch returns a branch by it's name
Expand Down
2 changes: 1 addition & 1 deletion options/gitignore/Bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/bazel-*

# Directories for the Bazel IntelliJ plugin containing the generated
# IntelliJ project files and plugin configuration. Separate directories are
# IntelliJ project files and plugin configuration. Seperate directories are
# for the IntelliJ, Android Studio and CLion versions of the plugin.
/.ijwb/
/.aswb/
Expand Down
1 change: 1 addition & 0 deletions options/license/GStreamer-exception-2005
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The Totem project hereby grant permission for non-gpl compatible GStreamer plugins to be used and distributed together with GStreamer and Totem. This permission are above and beyond the permissions granted by the GPL license Totem is covered by.
1 change: 1 addition & 0 deletions options/license/GStreamer-exception-2008
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This project hereby grants permission for non-GPL compatible GStreamer plugins to be used and distributed together with GStreamer and this project. This permission is above and beyond the permissions granted by the GPL license by which this project is covered. If you modify this code, you may extend this exception to your version of the code, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
51 changes: 51 additions & 0 deletions options/license/Minpack
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Minpack Copyright Notice (1999) University of Chicago. All rights reserved

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

1. Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.

2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.

3. The end-user documentation included with the
redistribution, if any, must include the following
acknowledgment:

"This product includes software developed by the
University of Chicago, as Operator of Argonne National
Laboratory.

Alternately, this acknowledgment may appear in the software
itself, if and wherever such third-party acknowledgments
normally appear.

4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS"
WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE
UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND
THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE
OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY
OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR
USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF
THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4)
DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION
UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL
BE CORRECTED.

5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT
HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF
ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT,
INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF
ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF
PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER
SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT
(INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE,
EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE
POSSIBILITY OF SUCH LOSS OR DAMAGES.
2 changes: 2 additions & 0 deletions options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,8 @@ users.delete_account=Eliminar conta de utilizador
users.cannot_delete_self=Não se pode eliminar a si próprio
users.still_own_repo=Este utilizador ainda possui um ou mais repositórios. Elimine ou transfira esses repositórios primeiro.
users.still_has_org=Este utilizador é membro de uma organização. Remova, primeiro, o utilizador de todas as organizações.
users.purge=Eliminar utilizador
users.purge_help=Eliminar o utilizador à força, juntamente com todos os seus repositórios, organizações e pacotes. Também serão eliminados todos os seus comentários.
users.still_own_packages=Este utilizador ainda possui um ou mais pacotes. Elimine esses pacotes primeiro.
users.deletion_success=A conta de utilizador foi eliminada.
users.reset_2fa=Reinicializar a autenticação em dois passos
Expand Down
1 change: 1 addition & 0 deletions routers/api/v1/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func CreateRelease(ctx *context.APIContext) {
rel.IsTag = false
rel.Repo = ctx.Repo.Repository
rel.Publisher = ctx.Doer
rel.Target = form.Target

if err = release_service.UpdateRelease(ctx.Doer, ctx.Repo.GitRepo, rel, nil, nil, nil); err != nil {
ctx.Error(http.StatusInternalServerError, "UpdateRelease", err)
Expand Down
4 changes: 3 additions & 1 deletion routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func GlobalInitInstalled(ctx context.Context) {
mustInit(repo_service.Init)

// Booting long running goroutines.
cron.NewContext(ctx)
issue_indexer.InitIssueIndexer(false)
code_indexer.Init()
mustInit(stats_indexer.Init)
Expand All @@ -160,6 +159,9 @@ func GlobalInitInstalled(ctx context.Context) {

auth.Init()
svg.Init()

// Finally start up the cron
cron.NewContext(ctx)
}

// NormalRoutes represents non install routes
Expand Down
5 changes: 0 additions & 5 deletions routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ func Home(ctx *context.Context) {

org := ctx.Org.Organization

if !organization.HasOrgOrUserVisible(ctx, org.AsUser(), ctx.Doer) {
ctx.NotFound("HasOrgOrUserVisible", nil)
return
}

ctx.Data["PageIsUserProfile"] = true
ctx.Data["Title"] = org.DisplayName()
if len(org.Description) != 0 {
Expand Down
7 changes: 6 additions & 1 deletion routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,12 @@ func RegisterRoutes(m *web.Route) {
}

// ***** START: Organization *****
m.Group("/org", func() {
m.Group("/{org}", func() {
m.Get("/members", org.Members)
}, context.OrgAssignment())
}, ignSignIn)

m.Group("/org", func() {
m.Group("", func() {
m.Get("/create", org.Create)
Expand All @@ -625,7 +631,6 @@ func RegisterRoutes(m *web.Route) {
m.Get("/pulls/{team}", user.Pulls)
m.Get("/milestones", reqMilestonesDashboardPageEnabled, user.Milestones)
m.Get("/milestones/{team}", reqMilestonesDashboardPageEnabled, user.Milestones)
m.Get("/members", org.Members)
m.Post("/members/action/{action}", org.MembersAction)
m.Get("/teams", org.Teams)
}, context.OrgAssignment(true, false, true))
Expand Down
2 changes: 0 additions & 2 deletions services/repository/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ func adoptRepository(ctx context.Context, repoPath string, u *user_model.User, r
return fmt.Errorf("setDefaultBranch: %v", err)
}
}

repo.DefaultBranch = strings.TrimPrefix(repo.DefaultBranch, git.BranchPrefix)
}
branches, _, _ := gitRepo.GetBranchNames(0, 0)
found := false
Expand Down
8 changes: 3 additions & 5 deletions templates/org/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@
{{end}}
<h4 class="ui top attached header df">
<strong class="f1">{{.locale.Tr "org.people"}}</strong>
{{if .IsOrganizationMember}}
<div class="ui">
<a class="text grey dif ac" href="{{.OrgLink}}/members"><span>{{.Org.NumMembers}}</span> {{svg "octicon-chevron-right"}}</a>
</div>
{{end}}
<div class="ui">
<a class="text grey dif ac" href="{{.OrgLink}}/members"><span>{{.MembersTotal}}</span> {{svg "octicon-chevron-right"}}</a>
</div>
</h4>
<div class="ui attached segment members">
{{$isMember := .IsOrganizationMember}}
Expand Down

0 comments on commit 7fa3229

Please sign in to comment.