Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Fix non-windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbad committed Aug 30, 2019
1 parent 89590bc commit 8bd3a7c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
13 changes: 1 addition & 12 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import (
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"syscall"

"github.com/sinbad/lfs-folderstore/api"
"github.com/sinbad/lfs-folderstore/util"
Expand Down Expand Up @@ -253,7 +250,7 @@ func store(baseDir string, oid string, size int64, a *api.Action, fromPath strin
}

func gitDir() (string, error) {
cmd := newCmd("git", "rev-parse", "--git-dir")
cmd := util.NewCmd("git", "rev-parse", "--git-dir")
out, err := cmd.Output()
if err != nil {
return "", fmt.Errorf("Failed to call git rev-parse --git-dir: %v %v", err, string(out))
Expand All @@ -263,14 +260,6 @@ func gitDir() (string, error) {

}

func newCmd(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
if runtime.GOOS == "windows" {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
return cmd
}

func absPath(path string) (string, error) {
if len(path) > 0 {
path, err := filepath.Abs(path)
Expand Down
10 changes: 10 additions & 0 deletions util/cmd_notwindows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// +build !windows

package util

import "os/exec"

func NewCmd(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
return cmd
}
12 changes: 12 additions & 0 deletions util/cmd_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package util

import (
"os/exec"
"syscall"
)

func NewCmd(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
return cmd
}

0 comments on commit 8bd3a7c

Please sign in to comment.