forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
* upstream/main: Use User.ID instead of User.Name in ActivityPub API for Person IRI (go-gitea#23823) Remove fomantic ".link" selector and styles (go-gitea#23888) [skip ci] Updated translations via Crowdin Fix `cases.Title` crash for concurrency (go-gitea#23885) Disable editing tags (go-gitea#23883) Fix user profile description rendering (go-gitea#23882) Introduce GiteaLocaleNumber custom element to handle number localization on pages. (go-gitea#23861) Convert .Source.SkipVerify to $cfg.SkipVerify (go-gitea#23839) Fix review box viewport overflow issue (go-gitea#23800) Fix owner team access mode value in team_unit table (go-gitea#23675) Fix submit button won't refresh in New Repository Fork page (go-gitea#22994) Introduce GitHub markdown editor, keep EasyMDE as fallback (go-gitea#23876) Improve LoadUnitConfig to handle invalid or duplicate units (go-gitea#23736) Append `(comment)` when a link points at a comment rather than the whole issue (go-gitea#23734) Rename actions unit to `repo.actions` and add docs for it (go-gitea#23733) Try to catch more broken translations (go-gitea#23867)
- Loading branch information
Showing
95 changed files
with
1,169 additions
and
1,217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package v1_20 //nolint | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/log" | ||
|
||
"xorm.io/xorm" | ||
) | ||
|
||
func FixIncorrectOwnerTeamUnitAccessMode(x *xorm.Engine) error { | ||
type UnitType int | ||
type AccessMode int | ||
|
||
type TeamUnit struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
OrgID int64 `xorm:"INDEX"` | ||
TeamID int64 `xorm:"UNIQUE(s)"` | ||
Type UnitType `xorm:"UNIQUE(s)"` | ||
AccessMode AccessMode | ||
} | ||
|
||
const ( | ||
// AccessModeOwner owner access | ||
AccessModeOwner = 4 | ||
) | ||
|
||
sess := x.NewSession() | ||
defer sess.Close() | ||
|
||
if err := sess.Begin(); err != nil { | ||
return err | ||
} | ||
|
||
count, err := sess.Table("team_unit"). | ||
Where("team_id IN (SELECT id FROM team WHERE authorize = ?)", AccessModeOwner). | ||
Update(&TeamUnit{ | ||
AccessMode: AccessModeOwner, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
log.Debug("Updated %d owner team unit access mode to belong to owner instead of none", count) | ||
|
||
return sess.Commit() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package unit | ||
|
||
import ( | ||
"testing" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestLoadUnitConfig(t *testing.T) { | ||
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []Type) { | ||
DisabledRepoUnits = disabledRepoUnits | ||
DefaultRepoUnits = defaultRepoUnits | ||
DefaultForkRepoUnits = defaultForkRepoUnits | ||
}(DisabledRepoUnits, DefaultRepoUnits, DefaultForkRepoUnits) | ||
defer func(disabledRepoUnits, defaultRepoUnits, defaultForkRepoUnits []string) { | ||
setting.Repository.DisabledRepoUnits = disabledRepoUnits | ||
setting.Repository.DefaultRepoUnits = defaultRepoUnits | ||
setting.Repository.DefaultForkRepoUnits = defaultForkRepoUnits | ||
}(setting.Repository.DisabledRepoUnits, setting.Repository.DefaultRepoUnits, setting.Repository.DefaultForkRepoUnits) | ||
|
||
t.Run("regular", func(t *testing.T) { | ||
setting.Repository.DisabledRepoUnits = []string{"repo.issues"} | ||
setting.Repository.DefaultRepoUnits = []string{"repo.code", "repo.releases", "repo.issues", "repo.pulls"} | ||
setting.Repository.DefaultForkRepoUnits = []string{"repo.releases"} | ||
LoadUnitConfig() | ||
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits) | ||
assert.Equal(t, []Type{TypeCode, TypeReleases, TypePullRequests}, DefaultRepoUnits) | ||
assert.Equal(t, []Type{TypeCode, TypeReleases}, DefaultForkRepoUnits) | ||
}) | ||
t.Run("invalid", func(t *testing.T) { | ||
setting.Repository.DisabledRepoUnits = []string{"repo.issues", "invalid.1"} | ||
setting.Repository.DefaultRepoUnits = []string{"repo.code", "invalid.2", "repo.releases", "repo.issues", "repo.pulls"} | ||
setting.Repository.DefaultForkRepoUnits = []string{"invalid.3", "repo.releases"} | ||
LoadUnitConfig() | ||
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits) | ||
assert.Equal(t, []Type{TypeCode, TypeReleases, TypePullRequests}, DefaultRepoUnits) | ||
assert.Equal(t, []Type{TypeCode, TypeReleases}, DefaultForkRepoUnits) | ||
}) | ||
t.Run("duplicate", func(t *testing.T) { | ||
setting.Repository.DisabledRepoUnits = []string{"repo.issues", "repo.issues"} | ||
setting.Repository.DefaultRepoUnits = []string{"repo.code", "repo.releases", "repo.issues", "repo.pulls", "repo.code"} | ||
setting.Repository.DefaultForkRepoUnits = []string{"repo.releases", "repo.releases"} | ||
LoadUnitConfig() | ||
assert.Equal(t, []Type{TypeIssues}, DisabledRepoUnits) | ||
assert.Equal(t, []Type{TypeCode, TypeReleases, TypePullRequests}, DefaultRepoUnits) | ||
assert.Equal(t, []Type{TypeCode, TypeReleases}, DefaultForkRepoUnits) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.