代码拉取完成,页面将自动刷新
package common
import (
"fmt"
"io"
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/utils/ioutil"
)
// ServerCommand is used for a single server command execution.
type ServerCommand struct {
Stderr io.Writer
Stdout io.WriteCloser
Stdin io.Reader
}
func ServeUploadPack(cmd ServerCommand, s transport.UploadPackSession) (err error) {
ioutil.CheckClose(cmd.Stdout, &err)
ar, err := s.AdvertisedReferences()
if err != nil {
return err
}
if err := ar.Encode(cmd.Stdout); err != nil {
return err
}
req := packp.NewUploadPackRequest()
if err := req.Decode(cmd.Stdin); err != nil {
return err
}
var resp *packp.UploadPackResponse
resp, err = s.UploadPack(req)
if err != nil {
return err
}
return resp.Encode(cmd.Stdout)
}
func ServeReceivePack(cmd ServerCommand, s transport.ReceivePackSession) error {
ar, err := s.AdvertisedReferences()
if err != nil {
return fmt.Errorf("internal error in advertised references: %s", err)
}
if err := ar.Encode(cmd.Stdout); err != nil {
return fmt.Errorf("error in advertised references encoding: %s", err)
}
req := packp.NewReferenceUpdateRequest()
if err := req.Decode(cmd.Stdin); err != nil {
return fmt.Errorf("error decoding: %s", err)
}
rs, err := s.ReceivePack(req)
if rs != nil {
if err := rs.Encode(cmd.Stdout); err != nil {
return fmt.Errorf("error in encoding report status %s", err)
}
}
if err != nil {
return fmt.Errorf("error in receive pack: %s", err)
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。