Skip to content

Commit 0d9ac76

Browse files
authored
Merge branch 'go-gitea:main' into star/list
2 parents 85227d0 + aba96f6 commit 0d9ac76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+582
-555
lines changed

models/auth/access_token_scope.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package auth
55

66
import (
77
"fmt"
8+
"slices"
89
"strings"
910

1011
"code.gitea.io/gitea/models/perm"
@@ -14,7 +15,7 @@ import (
1415
type AccessTokenScopeCategory int
1516

1617
const (
17-
AccessTokenScopeCategoryActivityPub = iota
18+
AccessTokenScopeCategoryActivityPub AccessTokenScopeCategory = iota
1819
AccessTokenScopeCategoryAdmin
1920
AccessTokenScopeCategoryMisc // WARN: this is now just a placeholder, don't remove it which will change the following values
2021
AccessTokenScopeCategoryNotification
@@ -193,6 +194,14 @@ var accessTokenScopes = map[AccessTokenScopeLevel]map[AccessTokenScopeCategory]A
193194
},
194195
}
195196

197+
func GetAccessTokenCategories() (res []string) {
198+
for _, cat := range accessTokenScopes[Read] {
199+
res = append(res, strings.TrimPrefix(string(cat), "read:"))
200+
}
201+
slices.Sort(res)
202+
return res
203+
}
204+
196205
// GetRequiredScopes gets the specific scopes for a given level and categories
197206
func GetRequiredScopes(level AccessTokenScopeLevel, scopeCategories ...AccessTokenScopeCategory) []AccessTokenScope {
198207
scopes := make([]AccessTokenScope, 0, len(scopeCategories))
@@ -270,6 +279,9 @@ func (s AccessTokenScope) parse() (accessTokenScopeBitmap, error) {
270279

271280
// StringSlice returns the AccessTokenScope as a []string
272281
func (s AccessTokenScope) StringSlice() []string {
282+
if s == "" {
283+
return nil
284+
}
273285
return strings.Split(string(s), ",")
274286
}
275287

models/auth/access_token_scope_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type scopeTestNormalize struct {
1717
}
1818

1919
func TestAccessTokenScope_Normalize(t *testing.T) {
20+
assert.Equal(t, []string{"activitypub", "admin", "issue", "misc", "notification", "organization", "package", "repository", "user"}, GetAccessTokenCategories())
2021
tests := []scopeTestNormalize{
2122
{"", "", nil},
2223
{"write:misc,write:notification,read:package,write:notification,public-only", "public-only,write:misc,write:notification,read:package", nil},
@@ -25,7 +26,7 @@ func TestAccessTokenScope_Normalize(t *testing.T) {
2526
{"write:activitypub,write:admin,write:misc,write:notification,write:organization,write:package,write:issue,write:repository,write:user,public-only", "public-only,all", nil},
2627
}
2728

28-
for _, scope := range []string{"activitypub", "admin", "misc", "notification", "organization", "package", "issue", "repository", "user"} {
29+
for _, scope := range GetAccessTokenCategories() {
2930
tests = append(tests,
3031
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("read:%s", scope)), AccessTokenScope(fmt.Sprintf("read:%s", scope)), nil},
3132
scopeTestNormalize{AccessTokenScope(fmt.Sprintf("write:%s", scope)), AccessTokenScope(fmt.Sprintf("write:%s", scope)), nil},
@@ -59,7 +60,7 @@ func TestAccessTokenScope_HasScope(t *testing.T) {
5960
{"public-only", "read:issue", false, nil},
6061
}
6162

62-
for _, scope := range []string{"activitypub", "admin", "misc", "notification", "organization", "package", "issue", "repository", "user"} {
63+
for _, scope := range GetAccessTokenCategories() {
6364
tests = append(tests,
6465
scopeTestHasScope{
6566
AccessTokenScope(fmt.Sprintf("read:%s", scope)),

models/issues/pull_list.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,16 @@ type PullRequestsOptions struct {
2828
Labels []int64
2929
MilestoneID int64
3030
PosterID int64
31+
BaseBranch string
3132
}
3233

3334
func listPullRequestStatement(ctx context.Context, baseRepoID int64, opts *PullRequestsOptions) *xorm.Session {
3435
sess := db.GetEngine(ctx).Where("pull_request.base_repo_id=?", baseRepoID)
3536

37+
if opts.BaseBranch != "" {
38+
sess.And("pull_request.base_branch=?", opts.BaseBranch)
39+
}
40+
3641
sess.Join("INNER", "issue", "pull_request.issue_id = issue.id")
3742
switch opts.State {
3843
case "closed", "open":

models/repo/repo.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,15 @@ func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML {
646646
type CloneLink struct {
647647
SSH string
648648
HTTPS string
649+
Tea string
649650
}
650651

651-
// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
652+
// ComposeHTTPSCloneURL returns HTTPS clone URL based on the given owner and repository name.
652653
func ComposeHTTPSCloneURL(ctx context.Context, owner, repo string) string {
653654
return fmt.Sprintf("%s%s/%s.git", httplib.GuessCurrentAppURL(ctx), url.PathEscape(owner), url.PathEscape(repo))
654655
}
655656

657+
// ComposeSSHCloneURL returns SSH clone URL based on the given owner and repository name.
656658
func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string) string {
657659
sshUser := setting.SSH.User
658660
sshDomain := setting.SSH.Domain
@@ -686,11 +688,17 @@ func ComposeSSHCloneURL(doer *user_model.User, ownerName, repoName string) strin
686688
return fmt.Sprintf("%s@%s:%s/%s.git", sshUser, sshHost, url.PathEscape(ownerName), url.PathEscape(repoName))
687689
}
688690

691+
// ComposeTeaCloneCommand returns Tea CLI clone command based on the given owner and repository name.
692+
func ComposeTeaCloneCommand(ctx context.Context, owner, repo string) string {
693+
return fmt.Sprintf("tea clone %s/%s", url.PathEscape(owner), url.PathEscape(repo))
694+
}
695+
689696
func (repo *Repository) cloneLink(ctx context.Context, doer *user_model.User, repoPathName string) *CloneLink {
690-
cl := new(CloneLink)
691-
cl.SSH = ComposeSSHCloneURL(doer, repo.OwnerName, repoPathName)
692-
cl.HTTPS = ComposeHTTPSCloneURL(ctx, repo.OwnerName, repoPathName)
693-
return cl
697+
return &CloneLink{
698+
SSH: ComposeSSHCloneURL(doer, repo.OwnerName, repoPathName),
699+
HTTPS: ComposeHTTPSCloneURL(ctx, repo.OwnerName, repoPathName),
700+
Tea: ComposeTeaCloneCommand(ctx, repo.OwnerName, repoPathName),
701+
}
694702
}
695703

696704
// CloneLink returns clone URLs of repository.

options/locale/locale_cs-CZ.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,6 @@ delete_token_success=Token byl odstraněn. Aplikace, které jej používají ji
911911
repo_and_org_access=Repozitář a přístup organizace
912912
permissions_public_only=Pouze veřejnost
913913
permissions_access_all=Vše (veřejné, soukromé a omezené)
914-
select_permissions=Vyberte oprávnění
915914
permission_not_set=Není nastaveno
916915
permission_no_access=Bez přístupu
917916
permission_read=Přečtené

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ delete_token_success=Der Zugriffstoken wurde gelöscht. Anwendungen die diesen T
910910
repo_and_org_access=Repository- und Organisationszugriff
911911
permissions_public_only=Nur öffentlich
912912
permissions_access_all=Alle (öffentlich, privat und begrenzt)
913-
select_permissions=Berechtigungen auswählen
914913
permission_not_set=Nicht festgelegt
915914
permission_no_access=Kein Zugriff
916915
permission_read=Lesen

options/locale/locale_el-GR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,6 @@ delete_token_success=Το διακριτικό έχει διαγραφεί. Οι
810810
repo_and_org_access=Πρόσβαση στο Αποθετήριο και Οργανισμό
811811
permissions_public_only=Δημόσια μόνο
812812
permissions_access_all=Όλα (δημόσια, ιδιωτικά, και περιορισμένα)
813-
select_permissions=Επιλέξτε δικαιώματα
814813
permission_no_access=Καμία Πρόσβαση
815814
permission_read=Αναγνωσμένες
816815
permission_write=Ανάγνωση και Εγγραφή

options/locale/locale_en-US.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ delete_token_success = The token has been deleted. Applications using it no long
917917
repo_and_org_access = Repository and Organization Access
918918
permissions_public_only = Public only
919919
permissions_access_all = All (public, private, and limited)
920-
select_permissions = Select permissions
921920
permission_not_set = Not set
922921
permission_no_access = No Access
923922
permission_read = Read
@@ -2595,7 +2594,6 @@ diff.commit = commit
25952594
diff.git-notes = Notes
25962595
diff.data_not_available = Diff Content Not Available
25972596
diff.options_button = Diff Options
2598-
diff.show_diff_stats = Show Stats
25992597
diff.download_patch = Download Patch File
26002598
diff.download_diff = Download Diff File
26012599
diff.show_split_view = Split View

options/locale/locale_es-ES.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ delete_token_success=El token ha sido eliminado. Las aplicaciones que lo usen ya
806806
repo_and_org_access=Acceso al Repositorio y a la Organización
807807
permissions_public_only=Sólo público
808808
permissions_access_all=Todo (público, privado y limitado)
809-
select_permissions=Seleccionar permisos
810809
permission_no_access=Sin acceso
811810
permission_read=Leídas
812811
permission_write=Lectura y Escritura

options/locale/locale_fr-FR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,6 @@ delete_token_success=Ce jeton a été supprimé. Les applications l'utilisant n'
917917
repo_and_org_access=Accès aux Organisations et Dépôts
918918
permissions_public_only=Publique uniquement
919919
permissions_access_all=Tout (public, privé et limité)
920-
select_permissions=Sélectionner les autorisations
921920
permission_not_set=Non défini
922921
permission_no_access=Aucun accès
923922
permission_read=Lecture

0 commit comments

Comments
 (0)