Skip to content

Fix push-to-create #9772

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

Merged
merged 10 commits into from
Jan 16, 2020
7 changes: 6 additions & 1 deletion routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ func HTTP(ctx *context.Context) {
return
}

var isPull bool
var isPull, pushCreate bool
service := ctx.Query("service")
if service == "git-receive-pack" ||
strings.HasSuffix(ctx.Req.URL.Path, "git-receive-pack") {
isPull = false
pushCreate = true
} else if service == "git-upload-pack" ||
strings.HasSuffix(ctx.Req.URL.Path, "git-upload-pack") {
isPull = true
Expand Down Expand Up @@ -282,6 +283,10 @@ func HTTP(ctx *context.Context) {
}

if !repoExist {
if !pushCreate {
ctx.HandleText(http.StatusNotFound, "Repository not found")
return
}
if owner.IsOrganization() && !setting.Repository.EnablePushCreateOrg {
ctx.HandleText(http.StatusForbidden, "Push to create is not enabled for organizations.")
return
Expand Down