-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Update status and code index after changing the default branch #27018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lunny
merged 10 commits into
go-gitea:main
from
lng2020:fix/update-code-index-after-change-default-branch
Sep 13, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d22969
update status and code index after changing the default branch
lng2020 ee3f08b
fix
lng2020 f34d57a
Merge branch 'main' into fix/update-code-index-after-change-default-b…
lng2020 4ddb244
Update routers/web/repo/setting/default_branch.go
techknowlogick 1fdedc4
fix
lng2020 31640b6
Merge branch 'main' into fix/update-code-index-after-change-default-b…
techknowlogick 43dc7d0
Merge branch 'main' into fix/update-code-index-after-change-default-b…
GiteaBot 5ca99b8
Merge branch 'main' into fix/update-code-index-after-change-default-b…
GiteaBot f2cba0d
Merge branch 'main' into fix/update-code-index-after-change-default-b…
GiteaBot 955c9e6
Merge branch 'main' into fix/update-code-index-after-change-default-b…
GiteaBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,64 @@ | ||
// Copyright 2023 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package setting | ||
|
||
import ( | ||
"net/http" | ||
|
||
repo_model "code.gitea.io/gitea/models/repo" | ||
"code.gitea.io/gitea/modules/context" | ||
"code.gitea.io/gitea/modules/git" | ||
"code.gitea.io/gitea/modules/log" | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/routers/web/repo" | ||
notify_service "code.gitea.io/gitea/services/notify" | ||
) | ||
|
||
// SetDefaultBranchPost set default branch | ||
func SetDefaultBranchPost(ctx *context.Context) { | ||
ctx.Data["Title"] = ctx.Tr("repo.settings.branches.update_default_branch") | ||
ctx.Data["PageIsSettingsBranches"] = true | ||
|
||
repo.PrepareBranchList(ctx) | ||
if ctx.Written() { | ||
return | ||
} | ||
|
||
repo := ctx.Repo.Repository | ||
|
||
switch ctx.FormString("action") { | ||
case "default_branch": | ||
if ctx.HasError() { | ||
ctx.HTML(http.StatusOK, tplBranches) | ||
return | ||
} | ||
|
||
branch := ctx.FormString("branch") | ||
if !ctx.Repo.GitRepo.IsBranchExist(branch) { | ||
ctx.Status(http.StatusNotFound) | ||
return | ||
} else if repo.DefaultBranch != branch { | ||
repo.DefaultBranch = branch | ||
if err := ctx.Repo.GitRepo.SetDefaultBranch(branch); err != nil { | ||
if !git.IsErrUnsupportedVersion(err) { | ||
ctx.ServerError("SetDefaultBranch", err) | ||
return | ||
} | ||
} | ||
if err := repo_model.UpdateDefaultBranch(repo); err != nil { | ||
ctx.ServerError("SetDefaultBranch", err) | ||
return | ||
} | ||
|
||
notify_service.ChangeDefaultBranch(ctx, repo) | ||
} | ||
|
||
log.Trace("Repository basic settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name) | ||
|
||
ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) | ||
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.EscapedPath()) | ||
default: | ||
ctx.NotFound("", nil) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.