mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-08 11:17:29 -05:00
Remove unnecessary code and fix comments (#35761)
Follow #35459, #32562 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -276,6 +276,7 @@ func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Reposito
|
|||||||
// The task repo can access the current repo only if the task repo is private and
|
// The task repo can access the current repo only if the task repo is private and
|
||||||
// the owner of the task repo is a collaborative owner of the current repo.
|
// the owner of the task repo is a collaborative owner of the current repo.
|
||||||
// FIXME allow public repo read access if tokenless pull is enabled
|
// FIXME allow public repo read access if tokenless pull is enabled
|
||||||
|
// FIXME should owner's visibility also be considered here?
|
||||||
return perm, nil
|
return perm, nil
|
||||||
}
|
}
|
||||||
accessMode = perm_model.AccessModeRead
|
accessMode = perm_model.AccessModeRead
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ func CreateBranch(ctx *context.APIContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = repo_service.CreateNewBranchFromCommit(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, oldCommit.ID.String(), opt.BranchName)
|
err = repo_service.CreateNewBranchFromCommit(ctx, ctx.Doer, ctx.Repo.Repository, oldCommit.ID.String(), opt.BranchName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if git_model.IsErrBranchNotExist(err) {
|
if git_model.IsErrBranchNotExist(err) {
|
||||||
ctx.APIError(http.StatusNotFound, "The old branch does not exist")
|
ctx.APIError(http.StatusNotFound, "The old branch does not exist")
|
||||||
@@ -434,7 +434,7 @@ func RenameBranch(ctx *context.APIContext) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := repo_service.RenameBranch(ctx, repo, ctx.Doer, ctx.Repo.GitRepo, oldName, opt.Name)
|
msg, err := repo_service.RenameBranch(ctx, repo, ctx.Doer, oldName, opt.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
|
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
|
||||||
|
|||||||
@@ -194,9 +194,9 @@ func CreateBranch(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
err = release_service.CreateNewTag(ctx, ctx.Doer, ctx.Repo.Repository, target, form.NewBranchName, "")
|
err = release_service.CreateNewTag(ctx, ctx.Doer, ctx.Repo.Repository, target, form.NewBranchName, "")
|
||||||
} else if ctx.Repo.RefFullName.IsBranch() {
|
} else if ctx.Repo.RefFullName.IsBranch() {
|
||||||
err = repo_service.CreateNewBranch(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.BranchName, form.NewBranchName)
|
err = repo_service.CreateNewBranch(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.BranchName, form.NewBranchName)
|
||||||
} else {
|
} else {
|
||||||
err = repo_service.CreateNewBranchFromCommit(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.CommitID, form.NewBranchName)
|
err = repo_service.CreateNewBranchFromCommit(ctx, ctx.Doer, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if release_service.IsErrProtectedTagName(err) {
|
if release_service.IsErrProtectedTagName(err) {
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ func RenameBranchPost(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg, err := repository.RenameBranch(ctx, ctx.Repo.Repository, ctx.Doer, ctx.Repo.GitRepo, form.From, form.To)
|
msg, err := repository.RenameBranch(ctx, ctx.Repo.Repository, ctx.Doer, form.From, form.To)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
|
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
|
||||||
|
|||||||
@@ -207,11 +207,6 @@ func handleSettingsPostUpdate(ctx *context.Context) {
|
|||||||
repo.Website = form.Website
|
repo.Website = form.Website
|
||||||
repo.IsTemplate = form.Template
|
repo.IsTemplate = form.Template
|
||||||
|
|
||||||
// Visibility of forked repository is forced sync with base repository.
|
|
||||||
if repo.IsFork {
|
|
||||||
form.Private = repo.BaseRepo.IsPrivate || repo.BaseRepo.Owner.Visibility == structs.VisibleTypePrivate
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := repo_service.UpdateRepository(ctx, repo, false); err != nil {
|
if err := repo_service.UpdateRepository(ctx, repo, false); err != nil {
|
||||||
ctx.ServerError("UpdateRepository", err)
|
ctx.ServerError("UpdateRepository", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ type RepoSettingForm struct {
|
|||||||
PushMirrorPassword string
|
PushMirrorPassword string
|
||||||
PushMirrorSyncOnCommit bool
|
PushMirrorSyncOnCommit bool
|
||||||
PushMirrorInterval string
|
PushMirrorInterval string
|
||||||
Private bool
|
|
||||||
Template bool
|
Template bool
|
||||||
EnablePrune bool
|
EnablePrune bool
|
||||||
|
|
||||||
@@ -148,10 +147,6 @@ type RepoSettingForm struct {
|
|||||||
AllowOnlyContributorsToTrackTime bool
|
AllowOnlyContributorsToTrackTime bool
|
||||||
EnableIssueDependencies bool
|
EnableIssueDependencies bool
|
||||||
|
|
||||||
EnableActions bool
|
|
||||||
|
|
||||||
IsArchived bool
|
|
||||||
|
|
||||||
// Signing Settings
|
// Signing Settings
|
||||||
TrustModel string
|
TrustModel string
|
||||||
|
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateNewBranch creates a new repository branch
|
// CreateNewBranch creates a new repository branch
|
||||||
func CreateNewBranch(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, gitRepo *git.Repository, oldBranchName, branchName string) (err error) {
|
func CreateNewBranch(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldBranchName, branchName string) (err error) {
|
||||||
branch, err := git_model.GetBranch(ctx, repo.ID, oldBranchName)
|
branch, err := git_model.GetBranch(ctx, repo.ID, oldBranchName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateNewBranchFromCommit(ctx, doer, repo, gitRepo, branch.CommitID, branchName)
|
return CreateNewBranchFromCommit(ctx, doer, repo, branch.CommitID, branchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Branch contains the branch information
|
// Branch contains the branch information
|
||||||
@@ -374,7 +374,7 @@ func SyncBranchesToDB(ctx context.Context, repoID, pusherID int64, branchNames,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateNewBranchFromCommit creates a new repository branch
|
// CreateNewBranchFromCommit creates a new repository branch
|
||||||
func CreateNewBranchFromCommit(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, gitRepo *git.Repository, commitID, branchName string) (err error) {
|
func CreateNewBranchFromCommit(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, commitID, branchName string) (err error) {
|
||||||
err = repo.MustNotBeArchived()
|
err = repo.MustNotBeArchived()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -399,7 +399,7 @@ func CreateNewBranchFromCommit(ctx context.Context, doer *user_model.User, repo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RenameBranch rename a branch
|
// RenameBranch rename a branch
|
||||||
func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, gitRepo *git.Repository, from, to string) (string, error) {
|
func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_model.User, from, to string) (string, error) {
|
||||||
err := repo.MustNotBeArchived()
|
err := repo.MustNotBeArchived()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -413,8 +413,12 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
|
|||||||
return "target_exist", nil
|
return "target_exist", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if exist, _ := git_model.IsBranchExist(ctx, repo.ID, from); !exist {
|
fromBranch, err := git_model.GetBranch(ctx, repo.ID, from)
|
||||||
return "from_not_exist", nil
|
if err != nil {
|
||||||
|
if git_model.IsErrBranchNotExist(err) {
|
||||||
|
return "from_not_exist", nil
|
||||||
|
}
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
perm, err := access_model.GetUserRepoPermission(ctx, repo, doer)
|
perm, err := access_model.GetUserRepoPermission(ctx, repo, doer)
|
||||||
@@ -472,14 +476,9 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
refNameTo := git.RefNameFromBranch(to)
|
|
||||||
refID, err := gitRepo.GetRefCommitID(refNameTo.String())
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
notify_service.DeleteRef(ctx, doer, repo, git.RefNameFromBranch(from))
|
notify_service.DeleteRef(ctx, doer, repo, git.RefNameFromBranch(from))
|
||||||
notify_service.CreateRef(ctx, doer, repo, refNameTo, refID)
|
notify_service.CreateRef(ctx, doer, repo, git.RefNameFromBranch(to), fromBranch.CommitID)
|
||||||
|
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
{{.CsrfTokenHtml}}
|
{{.CsrfTokenHtml}}
|
||||||
<button type="submit" class="ui red small button">{{ctx.Locale.Tr "admin.notices.delete_all"}}</button>
|
<button type="submit" class="ui red small button">{{ctx.Locale.Tr "admin.notices.delete_all"}}</button>
|
||||||
</form>
|
</form>
|
||||||
<div class="ui floating upward dropdown small button">{{/* TODO: Make this dropdown accessible */}}
|
<div class="ui floating upward dropdown small button">
|
||||||
<span class="text">{{ctx.Locale.Tr "admin.notices.operations"}}</span>
|
<span class="text">{{ctx.Locale.Tr "admin.notices.operations"}}</span>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<div class="item select action" data-action="select-all">
|
<div class="item select action" data-action="select-all">
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>{{ctx.Locale.Tr "repo.projects.description"}}</label>
|
<label>{{ctx.Locale.Tr "repo.projects.description"}}</label>
|
||||||
{{/* TODO: repo-level project and org-level project have different behaviros to render */}}
|
{{/* TODO: repo-level project and org-level project have different behaviors to render */}}
|
||||||
{{/* the "Repository" is nil when the project is org-level */}}
|
{{/* the "Repository" is nil when the project is org-level */}}
|
||||||
{{template "shared/combomarkdowneditor" (dict
|
{{template "shared/combomarkdowneditor" (dict
|
||||||
"MarkdownPreviewInRepo" $.Repository
|
"MarkdownPreviewInRepo" $.Repository
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
PR: https://github.com/go-gitea/gitea/pull/32744
|
PR: https://github.com/go-gitea/gitea/pull/32744
|
||||||
|
|
||||||
The Issue.Ref was added by Add possibility to record branch or tag information in an issue (#780)
|
The Issue.Ref was added by Add possibility to record branch or tag information in an issue (#780)
|
||||||
After 8 years, this "branch selector" does nothing more than saving the branch/tag name into database and displays it.
|
After 8 years, this "branch selector" does nothing more than saving the branch/tag name into database and displays it,
|
||||||
|
or sometimes auto-close a ref-matched issue by a commit message when CloseIssuesViaCommitInAnyBranch=false.
|
||||||
|
|
||||||
There are still users using it:
|
There are still users using it:
|
||||||
* @didim99: it is a really useful feature to specify a branch in which issue found.
|
* @didim99: it is a really useful feature to specify a branch in which issue found.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<label>{{ctx.Locale.Tr "actions.actions"}}</label>
|
<label>{{ctx.Locale.Tr "actions.actions"}}</label>
|
||||||
<div class="ui checkbox{{if $isActionsGlobalDisabled}} disabled{{end}}"{{if $isActionsGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}>
|
<div class="ui checkbox{{if $isActionsGlobalDisabled}} disabled{{end}}"{{if $isActionsGlobalDisabled}} data-tooltip-content="{{ctx.Locale.Tr "repo.unit_disabled"}}"{{end}}>
|
||||||
<input class="enable-system" name="enable_actions" type="checkbox" {{if $isActionsGlobalDisabled}}disabled{{end}} {{if $isActionsEnabled}}checked{{end}}>
|
<input name="enable_actions" type="checkbox" {{if $isActionsGlobalDisabled}}disabled{{end}} {{if $isActionsEnabled}}checked{{end}}>
|
||||||
<label>{{ctx.Locale.Tr "repo.settings.actions_desc"}}</label>
|
<label>{{ctx.Locale.Tr "repo.settings.actions_desc"}}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if and .EnableActions (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}}
|
{{if and .EnableActions (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}}
|
||||||
{{if .Repository.IsPrivate}}
|
{{if .Repository.IsPrivate}}
|
||||||
<h4 class="ui top attached header">
|
<h4 class="ui top attached header">
|
||||||
{{ctx.Locale.Tr "actions.general.collaborative_owners_management"}}
|
{{ctx.Locale.Tr "actions.general.collaborative_owners_management"}}
|
||||||
@@ -65,5 +65,5 @@
|
|||||||
{{ctx.Locale.Tr "actions.general.collaborative_owners_management_help"}}
|
{{ctx.Locale.Tr "actions.general.collaborative_owners_management_help"}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import (
|
|||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
actions_module "code.gitea.io/gitea/modules/actions"
|
actions_module "code.gitea.io/gitea/modules/actions"
|
||||||
"code.gitea.io/gitea/modules/commitstatus"
|
"code.gitea.io/gitea/modules/commitstatus"
|
||||||
"code.gitea.io/gitea/modules/git"
|
|
||||||
"code.gitea.io/gitea/modules/gitrepo"
|
"code.gitea.io/gitea/modules/gitrepo"
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
@@ -412,7 +411,7 @@ jobs:
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// create a branch
|
// create a branch
|
||||||
err = repo_service.CreateNewBranchFromCommit(t.Context(), user2, repo, gitRepo, branch.CommitID, "test-create-branch")
|
err = repo_service.CreateNewBranchFromCommit(t.Context(), user2, repo, branch.CommitID, "test-create-branch")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{
|
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{
|
||||||
Title: "add workflow",
|
Title: "add workflow",
|
||||||
@@ -530,9 +529,7 @@ jobs:
|
|||||||
|
|
||||||
// create a new branch
|
// create a new branch
|
||||||
testBranch := "test-branch"
|
testBranch := "test-branch"
|
||||||
gitRepo, err := git.OpenRepository(t.Context(), ".")
|
err = repo_service.CreateNewBranch(t.Context(), user2, repo, "main", testBranch)
|
||||||
assert.NoError(t, err)
|
|
||||||
err = repo_service.CreateNewBranch(t.Context(), user2, repo, gitRepo, "main", testBranch)
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// create Pull
|
// create Pull
|
||||||
@@ -1507,14 +1504,11 @@ jobs:
|
|||||||
assert.NotEmpty(t, addWorkflowToBaseResp)
|
assert.NotEmpty(t, addWorkflowToBaseResp)
|
||||||
|
|
||||||
// Get the commit ID of the default branch
|
// Get the commit ID of the default branch
|
||||||
gitRepo, err := gitrepo.OpenRepository(t.Context(), repo)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
defer gitRepo.Close()
|
|
||||||
branch, err := git_model.GetBranch(t.Context(), repo.ID, repo.DefaultBranch)
|
branch, err := git_model.GetBranch(t.Context(), repo.ID, repo.DefaultBranch)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// create a branch
|
// create a branch
|
||||||
err = repo_service.CreateNewBranchFromCommit(t.Context(), user2, repo, gitRepo, branch.CommitID, "test-action-run-name-with-variables")
|
err = repo_service.CreateNewBranchFromCommit(t.Context(), user2, repo, branch.CommitID, "test-action-run-name-with-variables")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{
|
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{
|
||||||
Title: user2.LoginName + " is running this workflow",
|
Title: user2.LoginName + " is running this workflow",
|
||||||
@@ -1584,14 +1578,11 @@ jobs:
|
|||||||
assert.NotEmpty(t, addWorkflowToBaseResp)
|
assert.NotEmpty(t, addWorkflowToBaseResp)
|
||||||
|
|
||||||
// Get the commit ID of the default branch
|
// Get the commit ID of the default branch
|
||||||
gitRepo, err := gitrepo.OpenRepository(t.Context(), repo)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
defer gitRepo.Close()
|
|
||||||
branch, err := git_model.GetBranch(t.Context(), repo.ID, repo.DefaultBranch)
|
branch, err := git_model.GetBranch(t.Context(), repo.ID, repo.DefaultBranch)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
// create a branch
|
// create a branch
|
||||||
err = repo_service.CreateNewBranchFromCommit(t.Context(), user2, repo, gitRepo, branch.CommitID, "test-action-run-name")
|
err = repo_service.CreateNewBranchFromCommit(t.Context(), user2, repo, branch.CommitID, "test-action-run-name")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{
|
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{
|
||||||
Title: "run name without variables",
|
Title: "run name without variables",
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
|
|||||||
|
|
||||||
// Make a new branch in repo1
|
// Make a new branch in repo1
|
||||||
newBranch := "test_branch"
|
newBranch := "test_branch"
|
||||||
err = repo_service.CreateNewBranch(t.Context(), user2, repo1, gitRepo, repo1.DefaultBranch, newBranch)
|
err = repo_service.CreateNewBranch(t.Context(), user2, repo1, repo1.DefaultBranch, newBranch)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
commitID, _ := gitRepo.GetBranchCommitID(repo1.DefaultBranch)
|
commitID, _ := gitRepo.GetBranchCommitID(repo1.DefaultBranch)
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
|
|||||||
|
|
||||||
// Make a new branch in repo1
|
// Make a new branch in repo1
|
||||||
newBranch := "test_branch"
|
newBranch := "test_branch"
|
||||||
err = repo_service.CreateNewBranch(t.Context(), user2, repo1, gitRepo, repo1.DefaultBranch, newBranch)
|
err = repo_service.CreateNewBranch(t.Context(), user2, repo1, repo1.DefaultBranch, newBranch)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
commitID, err := gitRepo.GetBranchCommitID(repo1.DefaultBranch)
|
commitID, err := gitRepo.GetBranchCommitID(repo1.DefaultBranch)
|
||||||
|
|||||||
Reference in New Issue
Block a user