Skip to content

Commit 8121ac9

Browse files
committed
[#200] Make functions in vcs/command.go public
To be able to isolate git related code in their own subpackage - rename - adapt call sites
1 parent 18164af commit 8121ac9

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/vcs/command.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ package vcs
2424

2525
import "os/exec"
2626

27-
func isCommandAvailable(command string) bool {
27+
// IsCommandAvailable indicates if the provided command is available in the path
28+
func IsCommandAvailable(command string) bool {
2829
_, err := exec.LookPath(command)
2930
return err == nil
3031
}
3132

32-
func getCommandPath(command string) string {
33+
// GetCommandPath returns the full path to the provided command
34+
func GetCommandPath(command string) string {
3335
path, _ := exec.LookPath(command)
3436
return path
3537
}

src/vcs/command_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ import (
3030
)
3131

3232
func Test_check_command_is_available_for_a_valid_command(t *testing.T) {
33-
assert.True(t, isCommandAvailable("ls"))
33+
assert.True(t, IsCommandAvailable("ls"))
3434
}
3535

3636
func Test_check_command_is_available_for_an_invalid_command(t *testing.T) {
37-
assert.False(t, isCommandAvailable("unknown-command"))
37+
assert.False(t, IsCommandAvailable("unknown-command"))
3838
}
3939

4040
func Test_check_command_path_for_a_valid_command(t *testing.T) {
41-
base := filepath.Base(getCommandPath("ls"))
41+
base := filepath.Base(GetCommandPath("ls"))
4242
assert.Equal(t, strings.TrimSuffix(base, ".exe"), "ls")
4343
}
4444

4545
func Test_check_command_path_for_an_invalid_command(t *testing.T) {
46-
assert.Zero(t, getCommandPath("unknown-command"))
46+
assert.Zero(t, GetCommandPath("unknown-command"))
4747
}

src/vcs/git_command.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ import (
3232

3333
// IsGitCommandAvailable indicates if git command is available on local machine
3434
func IsGitCommandAvailable() bool {
35-
return isCommandAvailable("git")
35+
return IsCommandAvailable("git")
3636
}
3737

3838
// GetGitCommandPath returns the path to git command on this machine
3939
func GetGitCommandPath() string {
40-
return getCommandPath("git")
40+
return GetCommandPath("git")
4141
}
4242

4343
// GetGitCommandVersion returns the version of git command on this machine

0 commit comments

Comments
 (0)