[GITEA] Allow release creation on commit
- The code and tests are already there to allow releases to be created on commits. - This patch modifies the web code to take into account that an commitID could've been passed as target. - Added unit test. - Resolves https://codeberg.org/forgejo/forgejo/issues/1196 (cherry picked from commit 90863e0ab51d1b243f67de266bbeeb7a9031c525) (cherry picked from commit c805aa23b5c6c9a8ab79e2e66786a4ef798e827a) (cherry picked from commit cf45567ca60b2a9411694c8e9b649fd77c64bdae) (cherry picked from commit 672a2b91e5612f438bd7951d173f42c223629fd1) (cherry picked from commit 82c930152cd693f8451e9553504365c724e1fced) (cherry picked from commit 95ac2508b3e8dd9fc2b0168600d989dbce0744ec) (cherry picked from commit b13a81ab98a02e30d1b508bb89cdd67a05eae782) (cherry picked from commit 9f463a7c1fa74ce17ab6ff8df49e2bcea3c1bc89) (cherry picked from commit 758ce84dc58e0c689e0fcc34386c7a8ed50f3df9) Conflicts: tests/integration/release_test.go https://codeberg.org/forgejo/forgejo/pulls/1550 (cherry picked from commit edf0531aeead2f68bbb283e437494ace33a8d3b8) (cherry picked from commit 44b29f3a1df81c072737b139cad34435313f086c) (cherry picked from commit b851b674195ecf3020aba55c5f46704fa3405289) (cherry picked from commit 37b408f5aac53bf72cd530722c774d7ace8356e1) (cherry picked from commit e81dbedb88a8601cf5a071176ecdbf29a0018cc1) (cherry picked from commit d5fa6be6ecc789448a45d4968ead4f958c33040b) (cherry picked from commit b8c4be25297401bc570dbff41bf312545ade4b54) (cherry picked from commit f23ce2843c59e442f63a240862d0d2e009a6eff2) (cherry picked from commit 8b7bcabae27bc5f66c72c44693e1d051231d2a79) (cherry picked from commit 2d6e52dda9b7f5fd29d7700f9a7835627aeada90) (cherry picked from commit 42e4f3ffdd211d3bb45e505a0cf632172bcbf6b2) (cherry picked from commit 39a1f689d8cb7a741cb10c35d4748fb54ecec34a) (cherry picked from commit 553d4872f883b8ac5cd6e9e585c599201b06067a) (cherry picked from commit df3743372576e708b03fe253eac0f37901a524be) (cherry picked from commit d67eac487b6d5120cf7d4976b9c426eb4d00013a) (cherry picked from commit 28cb0b191212457f90b661261b9d56ebc9e6e6bc) (cherry picked from commit 031c04c579a24cb05bcd662f085f538954cd34ef)
This commit is contained in:
parent
d3f9808151
commit
c237ab9f18
2 changed files with 19 additions and 2 deletions
|
@ -397,7 +397,11 @@ func NewReleasePost(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ctx.Repo.GitRepo.IsBranchExist(form.Target) {
|
objectFormat, _ := ctx.Repo.GitRepo.GetObjectFormat()
|
||||||
|
|
||||||
|
// form.Target can be a branch name or a full commitID.
|
||||||
|
if !ctx.Repo.GitRepo.IsBranchExist(form.Target) &&
|
||||||
|
len(form.Target) == objectFormat.FullLength() && !ctx.Repo.GitRepo.IsCommitExist(form.Target) {
|
||||||
ctx.RenderWithErr(ctx.Tr("form.target_branch_not_exist"), tplReleaseNew, &form)
|
ctx.RenderWithErr(ctx.Tr("form.target_branch_not_exist"), tplReleaseNew, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func createNewRelease(t *testing.T, session *TestSession, repoURL, tag, title string, preRelease, draft bool) {
|
func createNewRelease(t *testing.T, session *TestSession, repoURL, tag, title string, preRelease, draft bool) {
|
||||||
|
createNewReleaseTarget(t, session, repoURL, tag, title, "master", preRelease, draft)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createNewReleaseTarget(t *testing.T, session *TestSession, repoURL, tag, title, target string, preRelease, draft bool) {
|
||||||
req := NewRequest(t, "GET", repoURL+"/releases/new")
|
req := NewRequest(t, "GET", repoURL+"/releases/new")
|
||||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||||
|
@ -31,7 +35,7 @@ func createNewRelease(t *testing.T, session *TestSession, repoURL, tag, title st
|
||||||
postData := map[string]string{
|
postData := map[string]string{
|
||||||
"_csrf": htmlDoc.GetCSRF(),
|
"_csrf": htmlDoc.GetCSRF(),
|
||||||
"tag_name": tag,
|
"tag_name": tag,
|
||||||
"tag_target": "master",
|
"tag_target": target,
|
||||||
"title": title,
|
"title": title,
|
||||||
"content": "",
|
"content": "",
|
||||||
}
|
}
|
||||||
|
@ -217,6 +221,15 @@ func TestViewReleaseListLogin(t *testing.T) {
|
||||||
}, links)
|
}, links)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReleaseOnCommit(t *testing.T) {
|
||||||
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
session := loginUser(t, "user2")
|
||||||
|
createNewReleaseTarget(t, session, "/user2/repo1", "v0.0.1", "v0.0.1", "65f1bf27bc3bf70f64657658635e66094edbcb4d", false, false)
|
||||||
|
|
||||||
|
checkLatestReleaseAndCount(t, session, "/user2/repo1", "v0.0.1", translation.NewLocale("en-US").Tr("repo.release.stable"), 4)
|
||||||
|
}
|
||||||
|
|
||||||
func TestViewTagsList(t *testing.T) {
|
func TestViewTagsList(t *testing.T) {
|
||||||
defer tests.PrepareTestEnv(t)()
|
defer tests.PrepareTestEnv(t)()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue