From de22ce589c001ca68757fcc58749fa13a1a9f583 Mon Sep 17 00:00:00 2001 From: wangyusong Date: Fri, 22 Dec 2023 21:54:23 -0500 Subject: [PATCH] update --- conf/conf.go | 10 ++++++++-- config.json | 4 ++-- main.go | 6 +++--- utils/git.go | 7 ++++--- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/conf/conf.go b/conf/conf.go index a9132d3..fd593d7 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -30,7 +30,7 @@ func init() { if err != nil { panic(err) } - + //fmt.Println(pathFile) err = json.Unmarshal(pathFile, &Cfg) if err != nil { panic(err) @@ -41,6 +41,8 @@ func init() { } repoName, err := GetRepoName(Cfg.DocumentGitUrl) + fmt.Println(Cfg.CurrentDir) + fmt.Println(repoName) if err != nil { panic(err) } @@ -49,7 +51,7 @@ func init() { Cfg.Version = 3.0 Cfg.DocumentDir = Cfg.CurrentDir + "/" + repoName Cfg.GitHookUrl = "/api/git_push_hook" - Cfg.AppRepository = "https://github.com/Downsonwang/myblog" + Cfg.AppRepository = "git@github.com:Downsonwang/myblog" } func GetRepoName(gitUrl string) (string, error) { @@ -69,9 +71,13 @@ func CheckInit() { if !utils.IsDir(Cfg.DocumentDir) { fmt.Println("正在克隆文档仓库,请稍等...") out, err := utils.RunCmdByDir(Cfg.CurrentDir, "git", "clone", Cfg.DocumentGitUrl) + fmt.Println(Cfg.CurrentDir) + fmt.Println(Cfg.DocumentGitUrl) if err != nil { panic(err) } + //fmt.Println(Cfg.CurrentDir) + //fmt.Println(Cfg.DocumentGitUrl) fmt.Println(out) } else { out, err := utils.RunCmdByDir(Cfg.DocumentDir, "git", "pull") diff --git a/config.json b/config.json index adbbbb6..fca48fb 100644 --- a/config.json +++ b/config.json @@ -7,12 +7,12 @@ "webHookSecret": "downson", "categoryDisplayQuantity": 6, "tagDisplayQuantity": 6, - "utterancesRepo": "Downsonwang/blog_docs", + "utterancesRepo": "Downsonwang/docs", "timeLayout": "2006.01.02 15:04", "siteName": "Downson's Personal Blog", "htmlKeywords": "Record Everything", "htmlDescription": "Downson's Personal blog", - "documentGitUrl": "https://github.com/Downsonwang/docs.git", + "documentGitUrl": "git@github.com:Downsonwang/docs.git", "themeColor": "#f44336", "dashboardEntrance": "/admin", "themeOption": ["#673ab7","#f44336","#9c27b0","#2196f3","#607d8b","#795548"] diff --git a/main.go b/main.go index 98c854e..2440d77 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,7 @@ * @Descripttion: BLOG * @Author: DW * @Date: 2023-12-17 17:45:17 - * @LastEditTime: 2023-12-21 12:32:24 + * @LastEditTime: 2023-12-22 21:16:24 */ package main @@ -20,9 +20,9 @@ func init() { func main() { r := route.InitRoute() - conf.CheckInit() + s := &http.Server{ - Addr: "0.0.0.0:" + fmt.Sprintf("%d", conf.Cfg.Port), + Addr: "127.0.0.1:" + fmt.Sprintf("%d", conf.Cfg.Port), Handler: r, } if err := s.ListenAndServe(); err != nil { diff --git a/utils/git.go b/utils/git.go index 886c7cb..509ed9e 100644 --- a/utils/git.go +++ b/utils/git.go @@ -2,12 +2,13 @@ * @Descripttion: * @Author: * @Date: 2023-12-19 20:37:08 - * @LastEditTime: 2023-12-19 20:37:14 + * @LastEditTime: 2023-12-22 21:29:56 */ package utils import ( "errors" + "fmt" "strings" ) @@ -17,9 +18,9 @@ func GetRepoName(gitUrl string) (string, error) { if !strings.HasSuffix(gitUrl, ".git") { return "", errors.New("git URL must end with .git!") } - + fmt.Println(gitUrl) noSuffixUrl := strings.TrimSuffix(gitUrl, ".git") urlArr := strings.Split(noSuffixUrl, "/") - + fmt.Println(urlArr) return urlArr[len(urlArr)-1], nil }