-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix API-Endpoint release (#3005) #3012
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3012 +/- ##
==========================================
+ Coverage 35.01% 35.28% +0.26%
==========================================
Files 281 281
Lines 40560 40563 +3
==========================================
+ Hits 14204 14314 +110
+ Misses 24255 24138 -117
- Partials 2101 2111 +10
Continue to review full report at Codecov.
|
Could you explain why we need that change? |
When I tried to create a release via the api, I always got an internal server error (#3005). Digging around I found out that in // IsTagExist returns true if given tag exists in the repository.
func (repo *Repository) IsTagExist(name string) bool {
return IsTagExist(repo.Path, name)
} That call comes from if !ctx.Repo.GitRepo.IsTagExist(form.TagName) {
ctx.Status(404)
return
} |
@SnowMB Try using |
@lafriks done. Also fixed the same error in the PATCH route. |
Integration test for this would be great but otherwise LGTM |
Yes, it's better to have tests. |
Would love to add some tests. But I've got some problems to get the tests running on my machine (windows 10 / vs code). My error is that the environment variable |
@SnowMB I'm also new here, but I've managed to run the tests, on a Linux machine. The target to start is
Besides that, you will need the I suggest to work with the |
@SnowMB it's still panic on my test:
|
@SnowMB please fix this or could you give the push permission to maintainers on this PR. diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go
index 17cddc565..d26d337cb 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -146,6 +146,7 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
IsDraft: form.IsDraft,
IsPrerelease: form.IsPrerelease,
IsTag: false,
+ Repo: ctx.Repo.Repository,
}
if err := models.CreateRelease(ctx.Repo.GitRepo, rel, nil); err != nil {
if models.IsErrReleaseAlreadyExist(err) {
@@ -167,6 +168,8 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
rel.IsPrerelease = form.IsPrerelease
rel.PublisherID = ctx.User.ID
rel.IsTag = false
+ rel.Repo = ctx.Repo.Repository
+ rel.Publisher = ctx.User
if err = models.UpdateRelease(ctx.Repo.GitRepo, rel, nil); err != nil {
ctx.Handle(500, "UpdateRelease", err) |
Hey @lunny, Unfortunately I don't have time to fix this myself. But you should have permission to add commits to the pr. ( |
@SnowMB thanks. I have sent a commit. I think it's ready to review now. |
I'd also like to see a test added for this |
I'm just getting started with go. But here is my try to fix #3005 😁