mirror of
https://github.com/go-gitea/gitea
synced 2025-01-31 12:04:28 +00:00
parent
fcd096231a
commit
f6dbf0e7b3
@ -295,6 +295,7 @@ func SingleRelease(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.Data["PageIsSingleTag"] = release.IsTag
|
ctx.Data["PageIsSingleTag"] = release.IsTag
|
||||||
|
ctx.Data["SingleReleaseTagName"] = release.TagName
|
||||||
if release.IsTag {
|
if release.IsTag {
|
||||||
ctx.Data["Title"] = release.TagName
|
ctx.Data["Title"] = release.TagName
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,7 +70,7 @@ func Search(ctx *context.Context) {
|
|||||||
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, prepareSearch.Keyword, git.GrepOptions{
|
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, prepareSearch.Keyword, git.GrepOptions{
|
||||||
ContextLineNumber: 1,
|
ContextLineNumber: 1,
|
||||||
IsFuzzy: prepareSearch.IsFuzzy,
|
IsFuzzy: prepareSearch.IsFuzzy,
|
||||||
RefName: git.RefNameFromBranch(ctx.Repo.BranchName).String(), // BranchName should be default branch or the first existing branch
|
RefName: git.RefNameFromBranch(ctx.Repo.Repository.DefaultBranch).String(), // BranchName should be default branch or the first existing branch
|
||||||
PathspecList: indexSettingToGitGrepPathspecList(),
|
PathspecList: indexSettingToGitGrepPathspecList(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1592,7 +1592,7 @@ func registerRoutes(m *web.Router) {
|
|||||||
m.Get("/watchers", repo.Watchers)
|
m.Get("/watchers", repo.Watchers)
|
||||||
m.Get("/search", reqUnitCodeReader, repo.Search)
|
m.Get("/search", reqUnitCodeReader, repo.Search)
|
||||||
m.Post("/action/{action}", reqSignIn, repo.Action)
|
m.Post("/action/{action}", reqSignIn, repo.Action)
|
||||||
}, optSignIn, context.RepoAssignment, context.RepoRef())
|
}, optSignIn, context.RepoAssignment)
|
||||||
|
|
||||||
common.AddOwnerRepoGitLFSRoutes(m, optSignInIgnoreCsrf, lfsServerEnabled) // "/{username}/{reponame}/{lfs-paths}": git-lfs support
|
common.AddOwnerRepoGitLFSRoutes(m, optSignInIgnoreCsrf, lfsServerEnabled) // "/{username}/{reponame}/{lfs-paths}": git-lfs support
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ type Repository struct {
|
|||||||
// RefFullName is the full ref name that the user is viewing
|
// RefFullName is the full ref name that the user is viewing
|
||||||
RefFullName git.RefName
|
RefFullName git.RefName
|
||||||
BranchName string // it is the RefFullName's short name if its type is "branch"
|
BranchName string // it is the RefFullName's short name if its type is "branch"
|
||||||
TagName string // it is the RefFullName's short name if its type is "tag"
|
|
||||||
TreePath string
|
TreePath string
|
||||||
|
|
||||||
// Commit it is always set to the commit for the branch or tag, or just the commit that the user is viewing
|
// Commit it is always set to the commit for the branch or tag, or just the commit that the user is viewing
|
||||||
@ -851,7 +850,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
|||||||
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
|
ctx.Repo.CommitID = ctx.Repo.Commit.ID.String()
|
||||||
} else if refType == git.RefTypeTag && ctx.Repo.GitRepo.IsTagExist(refShortName) {
|
} else if refType == git.RefTypeTag && ctx.Repo.GitRepo.IsTagExist(refShortName) {
|
||||||
ctx.Repo.RefFullName = git.RefNameFromTag(refShortName)
|
ctx.Repo.RefFullName = git.RefNameFromTag(refShortName)
|
||||||
ctx.Repo.TagName = refShortName
|
|
||||||
|
|
||||||
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetTagCommit(refShortName)
|
ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetTagCommit(refShortName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -901,8 +899,6 @@ func RepoRefByType(detectRefType git.RefType) func(*Context) {
|
|||||||
|
|
||||||
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
ctx.Data["BranchName"] = ctx.Repo.BranchName
|
||||||
|
|
||||||
ctx.Data["TagName"] = ctx.Repo.TagName
|
|
||||||
|
|
||||||
ctx.Data["CommitID"] = ctx.Repo.CommitID
|
ctx.Data["CommitID"] = ctx.Repo.CommitID
|
||||||
|
|
||||||
ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef
|
ctx.Data["CanCreateBranch"] = ctx.Repo.CanCreateBranch() // only used by the branch selector dropdown: AllowCreateNewRef
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and (not .PageIsTagList) .CanCreateRelease}}
|
{{if and (not .PageIsTagList) .CanCreateRelease}}
|
||||||
<a class="ui small primary button" href="{{$.RepoLink}}/releases/new{{if .PageIsSingleTag}}?tag={{.TagName}}{{end}}">
|
<a class="ui small primary button" href="{{$.RepoLink}}/releases/new{{if .PageIsSingleTag}}?tag={{.SingleReleaseTagName}}{{end}}">
|
||||||
{{ctx.Locale.Tr "repo.release.new_release"}}
|
{{ctx.Locale.Tr "repo.release.new_release"}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -173,17 +173,25 @@ func TestViewReleaseListNoLogin(t *testing.T) {
|
|||||||
}, commitsToMain)
|
}, commitsToMain)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestViewSingleReleaseNoLogin(t *testing.T) {
|
func TestViewSingleRelease(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
t.Run("NoLogin", func(t *testing.T) {
|
||||||
req := NewRequest(t, "GET", "/user2/repo-release/releases/tag/v1.0")
|
req := NewRequest(t, "GET", "/user2/repo-release/releases/tag/v1.0")
|
||||||
resp := MakeRequest(t, req, http.StatusOK)
|
resp := MakeRequest(t, req, http.StatusOK)
|
||||||
|
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
// check the "number of commits to main since this release"
|
// check the "number of commits to main since this release"
|
||||||
releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
|
releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
|
||||||
assert.EqualValues(t, 1, releaseList.Length())
|
assert.EqualValues(t, 1, releaseList.Length())
|
||||||
assert.EqualValues(t, "3 commits", releaseList.First().Text())
|
assert.EqualValues(t, "3 commits", releaseList.First().Text())
|
||||||
|
})
|
||||||
|
t.Run("Login", func(t *testing.T) {
|
||||||
|
session := loginUser(t, "user1")
|
||||||
|
req := NewRequest(t, "GET", "/user2/repo1/releases/tag/delete-tag") // "delete-tag" is the only one with is_tag=true (although strange name)
|
||||||
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
|
// the New Release button should contain the tag name
|
||||||
|
assert.Contains(t, resp.Body.String(), `<a class="ui small primary button" href="/user2/repo1/releases/new?tag=delete-tag">`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestViewReleaseListLogin(t *testing.T) {
|
func TestViewReleaseListLogin(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user