mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 20:16:20 +01:00
Fix #572
This commit is contained in:
parent
fa241efa6d
commit
1aa12c7452
4 changed files with 44 additions and 11 deletions
|
@ -1489,6 +1489,12 @@ The register and sign-in page style
|
||||||
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
|
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
.commit-list .message {
|
||||||
|
width: 60%;
|
||||||
|
}
|
||||||
|
.commit-list .message span {
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
.diff-head-box {
|
.diff-head-box {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,6 +523,12 @@
|
||||||
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
|
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
.message {
|
||||||
|
width: 60%;
|
||||||
|
span {
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.diff-head-box {
|
.diff-head-box {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
|
|
|
@ -6,6 +6,7 @@ package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -283,23 +284,42 @@ func serviceReceivePack(hr handler) {
|
||||||
|
|
||||||
func serviceRpc(rpc string, hr handler) {
|
func serviceRpc(rpc string, hr handler) {
|
||||||
w, r, dir := hr.w, hr.r, hr.Dir
|
w, r, dir := hr.w, hr.r, hr.Dir
|
||||||
access := hasAccess(r, hr.Config, dir, rpc, true)
|
|
||||||
|
|
||||||
|
access := hasAccess(r, hr.Config, dir, rpc, true)
|
||||||
if access == false {
|
if access == false {
|
||||||
renderNoAccess(w)
|
renderNoAccess(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", rpc))
|
w.Header().Set("Content-Type", fmt.Sprintf("application/x-git-%s-result", rpc))
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
|
|
||||||
var input []byte
|
var (
|
||||||
var br io.Reader
|
reqBody = r.Body
|
||||||
|
input []byte
|
||||||
|
br io.Reader
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
// Handle GZIP.
|
||||||
|
if r.Header.Get("Content-Encoding") == "gzip" {
|
||||||
|
reqBody, err = gzip.NewReader(reqBody)
|
||||||
|
if err != nil {
|
||||||
|
log.GitLogger.Error(2, "fail to create gzip reader: %v", err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if hr.Config.OnSucceed != nil {
|
if hr.Config.OnSucceed != nil {
|
||||||
input, _ = ioutil.ReadAll(r.Body)
|
input, err = ioutil.ReadAll(reqBody)
|
||||||
|
if err != nil {
|
||||||
|
log.GitLogger.Error(2, "fail to read request body: %v", err)
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
br = bytes.NewReader(input)
|
br = bytes.NewReader(input)
|
||||||
} else {
|
} else {
|
||||||
br = r.Body
|
br = reqBody
|
||||||
}
|
}
|
||||||
|
|
||||||
args := []string{rpc, "--stateless-rpc", dir}
|
args := []string{rpc, "--stateless-rpc", dir}
|
||||||
|
@ -308,15 +328,16 @@ func serviceRpc(rpc string, hr handler) {
|
||||||
cmd.Stdout = w
|
cmd.Stdout = w
|
||||||
cmd.Stdin = br
|
cmd.Stdin = br
|
||||||
|
|
||||||
err := cmd.Run()
|
if err := cmd.Run(); err != nil {
|
||||||
if err != nil {
|
log.GitLogger.Error(2, "fail to serve RPC(%s): %v", rpc, err)
|
||||||
log.GitLogger.Error(4, err.Error())
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if hr.Config.OnSucceed != nil {
|
if hr.Config.OnSucceed != nil {
|
||||||
hr.Config.OnSucceed(rpc, input)
|
hr.Config.OnSucceed(rpc, input)
|
||||||
}
|
}
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getInfoRefs(hr handler) {
|
func getInfoRefs(hr handler) {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="author"><img class="avatar-20" src="{{AvatarLink .Author.Email}}" alt=""/> {{if .UserName}}<a href="{{AppSubUrl}}/{{.UserName}}">{{.Author.Name}}</a>{{else}}{{.Author.Name}}{{end}}</td>
|
<td class="author"><img class="avatar-20" src="{{AvatarLink .Author.Email}}" alt=""/> {{if .UserName}}<a href="{{AppSubUrl}}/{{.UserName}}">{{.Author.Name}}</a>{{else}}{{.Author.Name}}{{end}}</td>
|
||||||
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||||
<td class="message">{{.Summary}} </td>
|
<td class="message"><span class="text-truncate">{{.Summary}}</span></td>
|
||||||
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue