diff --git a/models/fixtures/repository.yml b/models/fixtures/repository.yml index 845dae7fc1..f783d58187 100644 --- a/models/fixtures/repository.yml +++ b/models/fixtures/repository.yml @@ -26,7 +26,7 @@ fork_id: 0 is_template: false template_id: 0 - size: 7320 + size: 7597 is_fsck_enabled: true close_issues_via_commit_in_any_branch: false diff --git a/modules/migration/pullrequest.go b/modules/migration/pullrequest.go index 4e7500f0d6..1435991bd2 100644 --- a/modules/migration/pullrequest.go +++ b/modules/migration/pullrequest.go @@ -45,7 +45,7 @@ func (p *PullRequest) GetContext() DownloaderContext { return p.Context } // IsForkPullRequest returns true if the pull request from a forked repository but not the same repository func (p *PullRequest) IsForkPullRequest() bool { - return p.Head.RepoPath() != p.Base.RepoPath() + return p.Head.RepoFullName() != p.Base.RepoFullName() } // GetGitRefName returns pull request relative path to head @@ -62,8 +62,8 @@ type PullRequestBranch struct { OwnerName string `yaml:"owner_name"` } -// RepoPath returns pull request repo path -func (p PullRequestBranch) RepoPath() string { +// RepoFullName returns pull request repo full name +func (p PullRequestBranch) RepoFullName() string { return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName) } diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index a74446b7f0..cfe0771be2 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -618,7 +618,6 @@ lang_select_error = Select a language from the list. username_been_taken = The username is already taken. username_change_not_local_user = Non-local users are not allowed to change their username. -username_has_not_been_changed = Username has not been changed repo_name_been_taken = The repository name is already used. repository_force_private = Force Private is enabled: private repositories cannot be made public. repository_files_already_exist = Files already exist for this repository. Contact the system administrator. @@ -848,7 +847,6 @@ principal_desc = These SSH certificate principals are associated with your accou gpg_desc = These public GPG keys are associated with your account and used to verify your commits. Keep your private keys safe as they allow to sign commits with your identity. ssh_helper = Need help? Have a look at the guide to create your own SSH keys or solve common problems you may encounter using SSH. gpg_helper = Need help? Have a look at the guide about GPG. -add_new_gpg_key = Add GPG key key_content_ssh_placeholder = Begins with "ssh-ed25519", "ssh-rsa", "ecdsa-sha2-nistp256", "ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521", "sk-ecdsa-sha2-nistp256@openssh.com", or "sk-ssh-ed25519@openssh.com" key_content_gpg_placeholder = Begins with "-----BEGIN PGP PUBLIC KEY BLOCK-----" add_new_principal = Add principal @@ -912,9 +910,6 @@ hide_openid = Hide from profile ssh_disabled = SSH is disabled ssh_signonly = SSH is currently disabled so these keys are only used for commit signature verification. ssh_externally_managed = This SSH key is externally managed for this user -social_desc = These social accounts can be used to sign in to your account. Make sure you recognize all of them. -unbind = Unlink -unbind_success = The social account has been removed successfully. manage_access_token = Access tokens generate_new_token = Generate new token @@ -925,8 +920,6 @@ generate_token_success = Your new token has been generated. Copy it now as it wi generate_token_name_duplicate = %s has been used as an application name already. Please use a new one. delete_token = Delete access_token_deletion = Delete access token -access_token_deletion_cancel_action = Cancel -access_token_deletion_confirm_action = Delete access_token_deletion_desc = Deleting a token will revoke access to your account for applications using it. This cannot be undone. Continue? delete_token_success = The token has been deleted. Applications using it no longer have access to your account. repo_and_org_access = Repository and Organization Access @@ -1000,7 +993,6 @@ webauthn_alternative_tip = You may want to configure an additional authenticatio manage_account_links = Linked accounts manage_account_links_desc = These external accounts are linked to your Forgejo account. -account_links_not_available = There are currently no external accounts linked to your Forgejo account. link_account = Link account remove_account_link = Remove linked account remove_account_link_desc = Removing a linked account will revoke its access to your Forgejo account. Continue? @@ -2476,8 +2468,6 @@ settings.protected_branch.save_rule = Save rule settings.protected_branch.delete_rule = Delete rule settings.branch_protection = Protection rules for branch "%s" settings.protect_new_rule = Create a new branch protection rule -settings.protect_this_branch = Enable branch protection -settings.protect_this_branch_desc = Prevents deletion and restricts Git pushing and merging to the branch. settings.protect_disable_push = Disable push settings.protect_disable_push_desc = No pushing will be allowed to this branch. settings.protect_enable_push = Enable push @@ -2520,8 +2510,6 @@ settings.protect_protected_file_patterns = Protected file patterns (separated us settings.protect_protected_file_patterns_desc = Protected files are not allowed to be changed directly even if user has rights to add, edit, or delete files in this branch. Multiple patterns can be separated using semicolon (";"). See github.com/gobwas/glob documentation for pattern syntax. Examples: .drone.yml, /docs/**/*.txt. settings.protect_unprotected_file_patterns = Unprotected file patterns (separated using semicolon ";") settings.protect_unprotected_file_patterns_desc = Unprotected files that are allowed to be changed directly if user has write access, bypassing push restriction. Multiple patterns can be separated using semicolon (";"). See github.com/gobwas/glob documentation for pattern syntax. Examples: .drone.yml, /docs/**/*.txt. -settings.add_protected_branch = Enable protection -settings.delete_protected_branch = Disable protection settings.update_protect_branch_success = Branch protection for rule "%s" has been updated. settings.remove_protected_branch_success = Branch protection for rule "%s" has been removed. settings.remove_protected_branch_failed = Removing branch protection rule "%s" failed. @@ -2606,8 +2594,6 @@ settings.rename_branch_failed_protected=Cannot rename branch %s because it is a settings.rename_branch_failed_exist=Cannot rename branch because target branch %s exists. settings.rename_branch_failed_not_exist=Cannot rename branch %s because it does not exist. settings.rename_branch_success =Branch %s was successfully renamed to %s. -settings.rename_branch_from=old branch name -settings.rename_branch_to=new branch name settings.rename_branch=Rename branch diff.browse_source = Browse source @@ -2754,7 +2740,6 @@ branch.create_new_branch = Create branch from branch: branch.confirm_create_branch = Create branch branch.warning_rename_default_branch = You are renaming the default branch. branch.rename_branch_to = Rename "%s" to: -branch.confirm_rename_branch = Rename branch branch.create_branch_operation = Create branch branch.new_branch = Create new branch branch.new_branch_from = Create new branch from "%s" diff --git a/release-notes/5109.md b/release-notes/5109.md new file mode 100644 index 0000000000..b3aecd8100 --- /dev/null +++ b/release-notes/5109.md @@ -0,0 +1,2 @@ +fix: [commit](https://codeberg.org/forgejo/forgejo/commit/3ade4d9b2bfa6ae84a1ded932907a53060565575) Don't return 500 if mirror url contains special chars +fix: [commit](https://codeberg.org/forgejo/forgejo/commit/dda53569b1b70507469fc296881eec89606ab9c3) Fix agit automerge diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go index f744a57a43..9b0141c14e 100644 --- a/routers/web/auth/linkaccount.go +++ b/routers/web/auth/linkaccount.go @@ -40,6 +40,7 @@ func LinkAccount(ctx *context.Context) { ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration ctx.Data["AllowOnlyInternalRegistration"] = setting.Service.AllowOnlyInternalRegistration ctx.Data["ShowRegistrationButton"] = false @@ -128,6 +129,7 @@ func LinkAccountPostSignIn(ctx *context.Context) { ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration ctx.Data["ShowRegistrationButton"] = false @@ -215,6 +217,7 @@ func LinkAccountPostRegister(ctx *context.Context) { ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration ctx.Data["ShowRegistrationButton"] = false diff --git a/routers/web/auth/openid.go b/routers/web/auth/openid.go index 2143b8096a..83268faacb 100644 --- a/routers/web/auth/openid.go +++ b/routers/web/auth/openid.go @@ -307,6 +307,7 @@ func RegisterOpenID(ctx *context.Context) { ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["OpenID"] = oid userName, _ := ctx.Session.Get("openid_determined_username").(string) if userName != "" { diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index 32e1d99e24..f6a372117f 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -481,7 +481,8 @@ func SettingsPost(ctx *context.Context) { } remoteAddress, err := util.SanitizeURL(address) if err != nil { - ctx.ServerError("SanitizeURL", err) + ctx.Data["Err_MirrorAddress"] = true + handleSettingRemoteAddrError(ctx, err, form) return } pullMirror.RemoteAddress = remoteAddress @@ -667,7 +668,8 @@ func SettingsPost(ctx *context.Context) { remoteAddress, err := util.SanitizeURL(address) if err != nil { - ctx.ServerError("SanitizeURL", err) + ctx.Data["Err_PushMirrorAddress"] = true + handleSettingRemoteAddrError(ctx, err, form) return } diff --git a/services/actions/notifier.go b/services/actions/notifier.go index 1166bbbfd2..e97afad990 100644 --- a/services/actions/notifier.go +++ b/services/actions/notifier.go @@ -396,7 +396,7 @@ func (n *actionsNotifier) ForkRepository(ctx context.Context, doer *user_model.U // Add to hook queue for created repo after session commit. if u.IsOrganization() { newNotifyInput(repo, doer, webhook_module.HookEventRepository). - WithRef(oldRepo.DefaultBranch). + WithRef(git.RefNameFromBranch(oldRepo.DefaultBranch).String()). WithPayload(&api.RepositoryPayload{ Action: api.HookRepoCreated, Repository: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm_model.AccessModeOwner}), diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 86897d5cba..751b896162 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -69,7 +69,7 @@ type notifyInput struct { Event webhook_module.HookEventType // optional - Ref string + Ref git.RefName Payload api.Payloader PullRequest *issues_model.PullRequest } @@ -93,7 +93,7 @@ func (input *notifyInput) WithDoer(doer *user_model.User) *notifyInput { } func (input *notifyInput) WithRef(ref string) *notifyInput { - input.Ref = ref + input.Ref = git.RefName(ref) return input } @@ -105,7 +105,7 @@ func (input *notifyInput) WithPayload(payload api.Payloader) *notifyInput { func (input *notifyInput) WithPullRequest(pr *issues_model.PullRequest) *notifyInput { input.PullRequest = pr if input.Ref == "" { - input.Ref = pr.GetGitRefName() + input.Ref = git.RefName(pr.GetGitRefName()) } return input } @@ -148,20 +148,25 @@ func notify(ctx context.Context, input *notifyInput) error { defer gitRepo.Close() ref := input.Ref - if ref != input.Repo.DefaultBranch && actions_module.IsDefaultBranchWorkflow(input.Event) { + if ref.BranchName() != input.Repo.DefaultBranch && actions_module.IsDefaultBranchWorkflow(input.Event) { if ref != "" { log.Warn("Event %q should only trigger workflows on the default branch, but its ref is %q. Will fall back to the default branch", input.Event, ref) } - ref = input.Repo.DefaultBranch + ref = git.RefNameFromBranch(input.Repo.DefaultBranch) } if ref == "" { log.Warn("Ref of event %q is empty, will fall back to the default branch", input.Event) - ref = input.Repo.DefaultBranch + ref = git.RefNameFromBranch(input.Repo.DefaultBranch) + } + + commitID, err := gitRepo.GetRefCommitID(ref.String()) + if err != nil { + return fmt.Errorf("gitRepo.GetRefCommitID: %w", err) } // Get the commit object for the ref - commit, err := gitRepo.GetCommit(ref) + commit, err := gitRepo.GetCommit(commitID) if err != nil { return fmt.Errorf("gitRepo.GetCommit: %w", err) } @@ -177,7 +182,7 @@ func notify(ctx context.Context, input *notifyInput) error { var detectedWorkflows []*actions_module.DetectedWorkflow actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig() - shouldDetectSchedules := input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch + shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, input.Event, input.Payload, @@ -235,12 +240,12 @@ func notify(ctx context.Context, input *notifyInput) error { } if shouldDetectSchedules { - if err := handleSchedules(ctx, schedules, commit, input, ref); err != nil { + if err := handleSchedules(ctx, schedules, commit, input, ref.String()); err != nil { return err } } - return handleWorkflows(ctx, detectedWorkflows, commit, input, ref) + return handleWorkflows(ctx, detectedWorkflows, commit, input, ref.String()) } func SkipPullRequestEvent(ctx context.Context, event webhook_module.HookEventType, repoID int64, commitSHA string) bool { diff --git a/services/automerge/automerge.go b/services/automerge/automerge.go index 9729616033..a1ee204882 100644 --- a/services/automerge/automerge.go +++ b/services/automerge/automerge.go @@ -245,9 +245,21 @@ func handlePullRequestAutoMerge(pullID int64, sha string) { defer headGitRepo.Close() } - headBranchExist := headGitRepo.IsBranchExist(pr.HeadBranch) - if pr.HeadRepo == nil || !headBranchExist { - log.Warn("Head branch of auto merge %-v does not exist [HeadRepoID: %d, Branch: %s]", pr, pr.HeadRepoID, pr.HeadBranch) + switch pr.Flow { + case issues_model.PullRequestFlowGithub: + headBranchExist := headGitRepo.IsBranchExist(pr.HeadBranch) + if pr.HeadRepo == nil || !headBranchExist { + log.Warn("Head branch of auto merge %-v does not exist [HeadRepoID: %d, Branch: %s]", pr, pr.HeadRepoID, pr.HeadBranch) + return + } + case issues_model.PullRequestFlowAGit: + headBranchExist := git.IsReferenceExist(ctx, baseGitRepo.Path, pr.GetGitRefName()) + if !headBranchExist { + log.Warn("Head branch of auto merge %-v does not exist [HeadRepoID: %d, Branch(Agit): %s]", pr, pr.HeadRepoID, pr.HeadBranch) + return + } + default: + log.Error("wrong flow type %d", pr.Flow) return } diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index e2c7c6f186..f5bffb097e 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -20,9 +20,11 @@
- {{if .DefaultBranchBranch.IsProtected}}{{svg "octicon-shield-lock"}}{{end}} {{.DefaultBranchBranch.DBBranch.Name}} - + {{if .DefaultBranchBranch.IsProtected}} + {{svg "octicon-shield-lock"}} + {{end}} + {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}

{{svg "octicon-git-commit" 16 "tw-mr-1"}}{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}} · {{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}} · {{ctx.Locale.Tr "org.repo_updated" (TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale)}} {{if .DefaultBranchBranch.DBBranch.Pusher}}  {{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}

@@ -39,7 +41,7 @@ {{end}} {{if .EnableFeed}} - {{svg "octicon-rss"}} + {{svg "octicon-rss"}} {{end}} {{if not $.DisableDownloadSourceArchives}}