Skip to content

Commit 7ac3975

Browse files
author
coder1125
authored
Merge branch 'main' into AddInlineCommitComments
2 parents 4d88732 + ed8d4dc commit 7ac3975

File tree

10 files changed

+82
-42
lines changed

10 files changed

+82
-42
lines changed

.github/workflows/release-nightly.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ jobs:
7575
- name: Get cleaned branch name
7676
id: clean_name
7777
run: |
78-
# if main then say nightly otherwise cleanup name
79-
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
80-
echo "branch=nightly" >> "$GITHUB_OUTPUT"
81-
exit 0
82-
fi
8378
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//')
8479
echo "branch=${REF_NAME}-nightly" >> "$GITHUB_OUTPUT"
8580
- name: Login to Docker Hub
@@ -122,11 +117,6 @@ jobs:
122117
- name: Get cleaned branch name
123118
id: clean_name
124119
run: |
125-
# if main then say nightly otherwise cleanup name
126-
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
127-
echo "branch=nightly" >> "$GITHUB_OUTPUT"
128-
exit 0
129-
fi
130120
REF_NAME=$(echo "${{ github.ref }}" | sed -e 's/refs\/heads\///' -e 's/refs\/tags\///' -e 's/release\/v//')
131121
echo "branch=${REF_NAME}-nightly" >> "$GITHUB_OUTPUT"
132122
- name: Login to Docker Hub

options/locale/locale_pt-PT.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ error404=A página que pretende aceder <strong>não existe</strong> ou <strong>n
120120
error503=O servidor não conseguiu concluir o seu pedido. Tente novamente mais tarde.
121121
go_back=Voltar
122122
invalid_data=Dados inválidos: %v
123+
nothing_has_been_changed=Nada foi alterado.
123124

124125
never=Nunca
125126
unknown=Desconhecido
@@ -2843,6 +2844,11 @@ settings.location=Localização
28432844
settings.permission=Permissões
28442845
settings.repoadminchangeteam=O administrador do repositório pode adicionar e remover o acesso às equipas
28452846
settings.visibility=Visibilidade
2847+
settings.change_visibility=Alterar visibilidade
2848+
settings.change_visibility_notices_1=Se a organização for convertida em privada, a contagem de favoritos do repositório será eliminada e não poderá ser restaurada.
2849+
settings.change_visibility_notices_2=Os não-membros irão perder acesso aos repositórios da organização se a visibilidade for mudada para privada.
2850+
settings.change_visibility_success=A visibilidade da organização %s foi mudada com sucesso.
2851+
settings.visibility_desc=Mudar quem pode ver a organização e os seus repositórios.
28462852
settings.visibility.public=Público
28472853
settings.visibility.limited=Limitada (visível apenas para utilizadores autenticados)
28482854
settings.visibility.limited_shortname=Limitada
@@ -3419,6 +3425,7 @@ config.picture_service=Serviço de imagem
34193425
config.disable_gravatar=Desabilitar o Gravatar
34203426
config.enable_federated_avatar=Habilitar avatares federados
34213427
config.open_with_editor_app_help=Os editores de "Abrir com" do menu de clonagem. Se for deixado em branco, será usado o predefinido. Expanda para ver o predefinido.
3428+
config.git_guide_remote_name=Nome remoto do repositório para os comandos git no guia
34223429

34233430
config.git_config=Configuração Git
34243431
config.git_disable_diff_highlight=Desabilitar o realce de sintaxe no diff

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"jquery": "3.7.1",
3434
"katex": "0.16.22",
3535
"license-checker-webpack-plugin": "0.2.1",
36-
"mermaid": "11.9.0",
36+
"mermaid": "11.10.0",
3737
"mini-css-extract-plugin": "2.9.2",
3838
"minimatch": "10.0.3",
3939
"monaco-editor": "0.52.2",

routers/api/v1/repo/status.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
271271
}
272272
ctx.SetTotalCountHeader(count)
273273

274-
if len(statuses) == 0 {
275-
ctx.JSON(http.StatusOK, &api.CombinedStatus{})
276-
return
277-
}
278-
279-
combiStatus := convert.ToCombinedStatus(ctx, statuses, convert.ToRepo(ctx, repo, ctx.Repo.Permission))
274+
combiStatus := convert.ToCombinedStatus(ctx, refCommit.Commit.ID.String(), statuses,
275+
convert.ToRepo(ctx, repo, ctx.Repo.Permission))
280276
ctx.JSON(http.StatusOK, combiStatus)
281277
}

routers/web/admin/auths.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func NewAuthSource(ctx *context.Context) {
9797
ctx.Data["AuthSources"] = authSources
9898
ctx.Data["SecurityProtocols"] = securityProtocols
9999
ctx.Data["SMTPAuths"] = smtp.Authenticators
100-
oauth2providers := oauth2.GetSupportedOAuth2Providers()
100+
oauth2providers := oauth2.GetSupportedOAuth2ProvidersWithContext(ctx)
101101
ctx.Data["OAuth2Providers"] = oauth2providers
102102

103103
ctx.Data["SSPIAutoCreateUsers"] = true
@@ -107,7 +107,9 @@ func NewAuthSource(ctx *context.Context) {
107107
ctx.Data["SSPIDefaultLanguage"] = ""
108108

109109
// only the first as default
110-
ctx.Data["oauth2_provider"] = oauth2providers[0].Name()
110+
if len(oauth2providers) > 0 {
111+
ctx.Data["oauth2_provider"] = oauth2providers[0].Name()
112+
}
111113

112114
ctx.HTML(http.StatusOK, tplAuthNew)
113115
}
@@ -240,7 +242,7 @@ func NewAuthSourcePost(ctx *context.Context) {
240242
ctx.Data["AuthSources"] = authSources
241243
ctx.Data["SecurityProtocols"] = securityProtocols
242244
ctx.Data["SMTPAuths"] = smtp.Authenticators
243-
oauth2providers := oauth2.GetSupportedOAuth2Providers()
245+
oauth2providers := oauth2.GetSupportedOAuth2ProvidersWithContext(ctx)
244246
ctx.Data["OAuth2Providers"] = oauth2providers
245247

246248
ctx.Data["SSPIAutoCreateUsers"] = true

routers/web/feed/render.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ import (
88
)
99

1010
// RenderBranchFeed render format for branch or file
11-
func RenderBranchFeed(ctx *context.Context) {
12-
_, showFeedType := GetFeedType(ctx.PathParam("reponame"), ctx.Req)
11+
func RenderBranchFeed(ctx *context.Context, feedType string) {
1312
if ctx.Repo.TreePath == "" {
14-
ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType)
13+
ShowBranchFeed(ctx, ctx.Repo.Repository, feedType)
1514
} else {
16-
ShowFileFeed(ctx, ctx.Repo.Repository, showFeedType)
15+
ShowFileFeed(ctx, ctx.Repo.Repository, feedType)
1716
}
1817
}
18+
19+
func RenderBranchFeedRSS(ctx *context.Context) {
20+
RenderBranchFeed(ctx, "rss")
21+
}
22+
23+
func RenderBranchFeedAtom(ctx *context.Context) {
24+
RenderBranchFeed(ctx, "atom")
25+
}

routers/web/web.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,8 +1634,8 @@ func registerWebRoutes(m *web.Router) {
16341634
m.Get("/cherry-pick/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, context.RepoRefByDefaultBranch(), repo.CherryPick)
16351635
}, repo.MustBeNotEmpty)
16361636

1637-
m.Get("/rss/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
1638-
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
1637+
m.Get("/rss/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeedRSS)
1638+
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeedAtom)
16391639

16401640
m.Group("/src", func() {
16411641
m.Get("", func(ctx *context.Context) { ctx.Redirect(ctx.Repo.RepoLink) }) // there is no "{owner}/{repo}/src" page, so redirect to "{owner}/{repo}" to avoid 404

services/auth/source/oauth2/providers.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"html"
1111
"html/template"
1212
"net/url"
13+
"slices"
1314
"sort"
1415

1516
"code.gitea.io/gitea/models/auth"
@@ -75,6 +76,10 @@ func (p *AuthSourceProvider) IconHTML(size int) template.HTML {
7576
// value is used to store display data
7677
var gothProviders = map[string]GothProvider{}
7778

79+
func isAzureProvider(name string) bool {
80+
return name == "azuread" || name == "microsoftonline" || name == "azureadv2"
81+
}
82+
7883
// RegisterGothProvider registers a GothProvider
7984
func RegisterGothProvider(provider GothProvider) {
8085
if _, has := gothProviders[provider.Name()]; has {
@@ -83,13 +88,47 @@ func RegisterGothProvider(provider GothProvider) {
8388
gothProviders[provider.Name()] = provider
8489
}
8590

91+
// getExistingAzureADAuthSources returns a list of Azure AD provider names that are already configured
92+
func getExistingAzureADAuthSources(ctx context.Context) ([]string, error) {
93+
authSources, err := db.Find[auth.Source](ctx, auth.FindSourcesOptions{
94+
LoginType: auth.OAuth2,
95+
})
96+
if err != nil {
97+
return nil, err
98+
}
99+
100+
var existingAzureProviders []string
101+
for _, source := range authSources {
102+
if oauth2Cfg, ok := source.Cfg.(*Source); ok {
103+
if isAzureProvider(oauth2Cfg.Provider) {
104+
existingAzureProviders = append(existingAzureProviders, oauth2Cfg.Provider)
105+
}
106+
}
107+
}
108+
return existingAzureProviders, nil
109+
}
110+
86111
// GetSupportedOAuth2Providers returns the map of unconfigured OAuth2 providers
87112
// key is used as technical name (like in the callbackURL)
88113
// values to display
114+
// Note: Azure AD providers (azuread, microsoftonline, azureadv2) are filtered out
115+
// unless they already exist in the system to encourage use of OpenID Connect
89116
func GetSupportedOAuth2Providers() []Provider {
117+
return GetSupportedOAuth2ProvidersWithContext(context.Background())
118+
}
119+
120+
// GetSupportedOAuth2ProvidersWithContext returns the list of supported OAuth2 providers with context for filtering
121+
func GetSupportedOAuth2ProvidersWithContext(ctx context.Context) []Provider {
90122
providers := make([]Provider, 0, len(gothProviders))
123+
existingAzureSources, err := getExistingAzureADAuthSources(ctx)
124+
if err != nil {
125+
log.Error("Failed to get existing OAuth2 auth sources: %v", err)
126+
}
91127

92128
for _, provider := range gothProviders {
129+
if isAzureProvider(provider.Name()) && !slices.Contains(existingAzureSources, provider.Name()) {
130+
continue
131+
}
93132
providers = append(providers, provider)
94133
}
95134
sort.Slice(providers, func(i, j int) bool {

services/convert/status.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,19 @@ func ToCommitStatuses(ctx context.Context, statuses []*git_model.CommitStatus) [
4242
}
4343

4444
// ToCombinedStatus converts List of CommitStatus to a CombinedStatus
45-
func ToCombinedStatus(ctx context.Context, statuses []*git_model.CommitStatus, repo *api.Repository) *api.CombinedStatus {
46-
if len(statuses) == 0 {
47-
return nil
45+
func ToCombinedStatus(ctx context.Context, commitID string, statuses []*git_model.CommitStatus, repo *api.Repository) *api.CombinedStatus {
46+
status := api.CombinedStatus{
47+
SHA: commitID,
48+
TotalCount: len(statuses),
49+
Repository: repo,
50+
CommitURL: repo.URL + "/commits/" + url.PathEscape(commitID),
51+
URL: repo.URL + "/commits/" + url.PathEscape(commitID) + "/status",
4852
}
4953

5054
combinedStatus := git_model.CalcCommitStatus(statuses)
51-
52-
return &api.CombinedStatus{
53-
State: combinedStatus.State,
54-
Statuses: ToCommitStatuses(ctx, statuses),
55-
SHA: combinedStatus.SHA,
56-
TotalCount: len(statuses),
57-
Repository: repo,
58-
CommitURL: repo.URL + "/commits/" + url.PathEscape(combinedStatus.SHA),
59-
URL: repo.URL + "/commits/" + url.PathEscape(combinedStatus.SHA) + "/status",
55+
if combinedStatus != nil {
56+
status.Statuses = ToCommitStatuses(ctx, statuses)
57+
status.State = combinedStatus.State
6058
}
59+
return &status
6160
}

0 commit comments

Comments
 (0)