mirror of https://github.com/go-gitea/gitea.git
Keep path when creating a new branch (#21153)
If you are create a new new branch while viewing file or directory, you get redirected to the root of the repo. With this PR, you keep your current path instead of getting redirected to the repo root.pull/21175/head
parent
ef40324c43
commit
bf325d4412
|
@ -427,5 +427,5 @@ func CreateBranch(ctx *context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.Flash.Success(ctx.Tr("repo.branch.create_success", form.NewBranchName))
|
ctx.Flash.Success(ctx.Tr("repo.branch.create_success", form.NewBranchName))
|
||||||
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(form.NewBranchName))
|
ctx.Redirect(ctx.Repo.RepoLink + "/src/branch/" + util.PathEscapeSegments(form.NewBranchName) + "/" + util.PathEscapeSegments(form.CurrentPath))
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
// NewBranchForm form for creating a new branch
|
// NewBranchForm form for creating a new branch
|
||||||
type NewBranchForm struct {
|
type NewBranchForm struct {
|
||||||
NewBranchName string `binding:"Required;MaxSize(100);GitRefName"`
|
NewBranchName string `binding:"Required;MaxSize(100);GitRefName"`
|
||||||
|
CurrentPath string
|
||||||
CreateTag bool
|
CreateTag bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,9 @@
|
||||||
{{.root.CsrfTokenHtml}}
|
{{.root.CsrfTokenHtml}}
|
||||||
<input type="hidden" name="new_branch_name" v-model="searchTerm">
|
<input type="hidden" name="new_branch_name" v-model="searchTerm">
|
||||||
<input type="hidden" name="create_tag" v-model="createTag">
|
<input type="hidden" name="create_tag" v-model="createTag">
|
||||||
|
{{if $.root.TreePath}}
|
||||||
|
<input type="hidden" name="current_path" value="{{.root.TreePath}}">
|
||||||
|
{{end}}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue