Skip to content

Commit

Permalink
Add language
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Oct 5, 2023
1 parent d4ce580 commit 7d956a9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ casdoorApplication = "app-casibase"
isDemoMode = false
appDir = "C:/github_repos"
dbPass = ""
language = "en"
2 changes: 1 addition & 1 deletion run/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func gitGetLatestCommitHash(path string) string {
func gitPull(path string) bool {
oldHash := gitGetLatestCommitHash(path)

cmd := exec.Command("git", "pull")
cmd := exec.Command("git", "pull", "--rebase", "--autostash")
cmd.Dir = path
out, err := cmd.CombinedOutput()
println(out)
Expand Down
10 changes: 8 additions & 2 deletions run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,22 @@ func CreateRepo(siteName string, needStart bool, diff string) {
} else if diff != "" {
gitApply(path, diff)
}

updateBatFile(siteName)
updateShortcutFile(siteName)
} else {
affected := gitPull(path)
if affected {
gitWebBuild(path)
}

if !needStart {
stopProcess(siteName)
startProcess(siteName)
}
}

if needStart {
updateBatFile(siteName)
updateShortcutFile(siteName)
startProcess(siteName)
}
}
4 changes: 4 additions & 0 deletions run/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ func stopProcess(name string) {
fmt.Printf("Stopping process: [%s]\n", name)

windowName := fmt.Sprintf("%s.bat - Shortcut", name)
if language != "en" {
windowName = fmt.Sprintf("%s.bat - 快捷方式", name)
}

// taskkill /IM "casdoor.bat - Shortcut" /F
// taskkill /F /FI "WINDOWTITLE eq casdoor.bat - Shortcut" /T
cmd := exec.Command("taskkill", "/F", "/FI", fmt.Sprintf("WINDOWTITLE eq %s", windowName), "/T")
Expand Down
3 changes: 3 additions & 0 deletions run/util_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

var username string
var language string

func init() {
usr, err := user.Current()
Expand All @@ -36,6 +37,8 @@ func init() {
if len(tokens) == 2 {
username = tokens[1]
}

language = beego.AppConfig.String("language")
}

func GetRepoPath(name string) string {
Expand Down

0 comments on commit 7d956a9

Please sign in to comment.