1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00
This commit is contained in:
hiifong 2025-01-10 10:45:32 +08:00
parent 35a2b9b3a5
commit b99fe1cf79
2 changed files with 5 additions and 1 deletions

View File

@ -237,7 +237,7 @@ func runServ(c *cli.Context) error {
// for AGit Flow
if cmd == "ssh_info" {
data := private.GetSSHInfo(ctx)
fmt.Print(data)
fmt.Println(data)
return nil
}
}

View File

@ -12,6 +12,7 @@ import (
"strconv"
"time"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
@ -43,16 +44,19 @@ func GetSSHInfo(ctx context.Context) string {
resp, err := req.Response()
if err != nil {
log.Error("GetSSHInfo Error: %v", err)
return ""
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
log.Error("response status code is not OK, code: %d", resp.StatusCode)
return ""
}
content, err := io.ReadAll(resp.Body)
if err != nil {
log.Error("read body error: %v", err)
return ""
}