Skip to content

Commit

Permalink
Add print
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Oct 5, 2023
1 parent 6d5e7fd commit 4f1a504
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 14 additions & 0 deletions run/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ package run

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
)

func gitClone(repoUrl string, path string) {
fmt.Printf("gitClone(): [%s]\n", path)

cmd := exec.Command("git", "clone", repoUrl, path)
err := cmd.Run()
if err != nil {
Expand All @@ -46,6 +49,8 @@ func GitDiff(path string) string {
}

func gitApply(path string, patch string) {
fmt.Printf("gitApply(): [%s]\n", path)

tmpFile, err := ioutil.TempFile("", "patch")
if err != nil {
panic(err)
Expand Down Expand Up @@ -78,6 +83,8 @@ func gitGetLatestCommitHash(path string) string {
}

func gitPull(path string) bool {
fmt.Printf("gitPull(): [%s]\n", path)

oldHash := gitGetLatestCommitHash(path)

cmd := exec.Command("git", "pull", "--rebase", "--autostash")
Expand All @@ -90,6 +97,11 @@ func gitPull(path string) bool {

newHash := gitGetLatestCommitHash(path)
affected := oldHash != newHash

if affected {
fmt.Printf("Affected: [%s] -> [%s]\n", oldHash, newHash)
}

return affected
}

Expand All @@ -103,6 +115,8 @@ func runCmd(dir, name string, args ...string) error {

func gitWebBuild(path string) {
webDir := filepath.Join(path, "web")
fmt.Printf("gitWebBuild(): [%s]\n", webDir)

err := runCmd(webDir, "yarn", "install")
if err != nil {
panic(err)
Expand Down
10 changes: 5 additions & 5 deletions run/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func ensureFileFolderExists(path string) {
}

func updateAppConfFile(name string, i int) {
fmt.Printf("Updating code's app.conf file: [%s]\n", name)
fmt.Printf("updateAppConfFile(): [%s]\n", name)

confPath := getCodeAppConfPath(name)
content := util.ReadStringFromPath(confPath)
Expand All @@ -85,7 +85,7 @@ func updateAppConfFile(name string, i int) {
}

func updateBatFile(name string) {
fmt.Printf("Updating BAT file: [%s]\n", name)
fmt.Printf("updateBatFile(): [%s]\n", name)

batPath := getBatPath(name)
ensureFileFolderExists(filepath.Dir(batPath))
Expand All @@ -94,7 +94,7 @@ func updateBatFile(name string) {
}

func updateShortcutFile(name string) {
fmt.Printf("Updating shortcut file: [%s]\n", name)
fmt.Printf("updateShortcutFile(): [%s]\n", name)

cmd := exec.Command("powershell", fmt.Sprintf("$s=(New-Object -COM WScript.Shell).CreateShortcut('%s');$s.TargetPath='%s';$s.Save()", getShortcutPath(name), getBatPath(name)))
err := cmd.Run()
Expand All @@ -104,7 +104,7 @@ func updateShortcutFile(name string) {
}

func startProcess(name string) {
fmt.Printf("Starting process: [%s]\n", name)
fmt.Printf("startProcess(): [%s]\n", name)

cmd := exec.Command("cmd", "/C", "start", "", getShortcutPath(name))
err := cmd.Run()
Expand All @@ -114,7 +114,7 @@ func startProcess(name string) {
}

func stopProcess(name string) {
fmt.Printf("Stopping process: [%s]\n", name)
fmt.Printf("stopProcess(): [%s]\n", name)

windowName := fmt.Sprintf("%s.bat - %s", name, getShortcut())
// taskkill /IM "casdoor.bat - Shortcut" /F
Expand Down

0 comments on commit 4f1a504

Please sign in to comment.