Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyusong committed Dec 23, 2023
1 parent b4015c0 commit de22ce5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
10 changes: 8 additions & 2 deletions conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
if err != nil {
panic(err)
}

//fmt.Println(pathFile)
err = json.Unmarshal(pathFile, &Cfg)
if err != nil {
panic(err)
Expand All @@ -41,6 +41,8 @@ func init() {
}

repoName, err := GetRepoName(Cfg.DocumentGitUrl)
fmt.Println(Cfg.CurrentDir)
fmt.Println(repoName)
if err != nil {
panic(err)
}
Expand All @@ -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) {
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
}

0 comments on commit de22ce5

Please sign in to comment.