Skip to content

Commit c475b18

Browse files
committed
refactor: rename MoveGitToTemp to RelocateSystemGit for clarity and update related functions
1 parent 2a87dc3 commit c475b18

File tree

8 files changed

+12
-11
lines changed

8 files changed

+12
-11
lines changed

internal/stage_clone_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func randomRepo() TestRepo {
7979
func testCloneRepository(harness *test_case_harness.TestCaseHarness) error {
8080
logger := harness.Logger
8181
executable := harness.Executable
82-
MoveGitToTemp(harness, logger)
82+
RelocateSystemGit(harness, logger)
8383

8484
tempDir, err := os.MkdirTemp("", "worktree")
8585
if err != nil {

internal/stage_create_blob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func testCreateBlob(harness *test_case_harness.TestCaseHarness) error {
1515
logger := harness.Logger
1616
executable := harness.Executable
17-
MoveGitToTemp(harness, logger)
17+
RelocateSystemGit(harness, logger)
1818

1919
tempDir, err := os.MkdirTemp("", "worktree")
2020
if err != nil {

internal/stage_create_commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
func testCreateCommit(harness *test_case_harness.TestCaseHarness) error {
1818
logger := harness.Logger
1919
executable := harness.Executable
20-
MoveGitToTemp(harness, logger)
20+
RelocateSystemGit(harness, logger)
2121

2222
tempDir, err := os.MkdirTemp("", "worktree")
2323
if err != nil {

internal/stage_init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func testInit(harness *test_case_harness.TestCaseHarness) error {
1313
logger := harness.Logger
1414
executable := harness.Executable
15-
MoveGitToTemp(harness, logger)
15+
RelocateSystemGit(harness, logger)
1616

1717
tempDir, err := os.MkdirTemp("", "worktree")
1818
if err != nil {

internal/stage_read_blob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
func testReadBlob(harness *test_case_harness.TestCaseHarness) error {
1818
logger := harness.Logger
1919
executable := harness.Executable
20-
MoveGitToTemp(harness, logger)
20+
RelocateSystemGit(harness, logger)
2121

2222
tempDir, err := os.MkdirTemp("", "worktree")
2323
if err != nil {

internal/stage_read_tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
func testReadTree(harness *test_case_harness.TestCaseHarness) error {
2222
logger := harness.Logger
2323
executable := harness.Executable
24-
MoveGitToTemp(harness, logger)
24+
RelocateSystemGit(harness, logger)
2525

2626
tempDir, err := os.MkdirTemp("", "worktree")
2727
if err != nil {

internal/stage_write_tree.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
func testWriteTree(harness *test_case_harness.TestCaseHarness) error {
2222
logger := harness.Logger
2323
executable := harness.Executable
24+
RelocateSystemGit(harness, logger)
2425

2526
tempDir, err := os.MkdirTemp("", "worktree")
2627
if err != nil {

internal/utils.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"github.com/codecrafters-io/tester-utils/test_case_harness"
1212
)
1313

14-
// MoveGitToTemp moves the system git binary to a temporary directory
15-
func MoveGitToTemp(harness *test_case_harness.TestCaseHarness, logger *logger.Logger) {
14+
// RelocateSystemGit moves the system git binary to a temporary directory
15+
func RelocateSystemGit(harness *test_case_harness.TestCaseHarness, logger *logger.Logger) {
1616
oldGitPath, err := exec.LookPath("git")
1717
if err != nil {
1818
panic(fmt.Sprintf("CodeCrafters Internal Error: git executable not found: %v", err))
@@ -34,11 +34,11 @@ func MoveGitToTemp(harness *test_case_harness.TestCaseHarness, logger *logger.Lo
3434
}
3535

3636
// Register teardown function to automatically restore git
37-
harness.RegisterTeardownFunc(func() { restoreGit(tmpGitPath, oldGitPath) })
37+
harness.RegisterTeardownFunc(func() { restoreSystemGit(tmpGitPath, oldGitPath) })
3838
}
3939

40-
// RestoreGit moves the git binary back to its original location and cleans up
41-
func restoreGit(newPath string, originalPath string) error {
40+
// RestoreSystemGit moves the git binary back to its original location and cleans up
41+
func restoreSystemGit(newPath string, originalPath string) error {
4242
command := fmt.Sprintf("mv %s %s", newPath, originalPath)
4343
moveCmd := exec.Command("sh", "-c", command)
4444
moveCmd.Stdout = io.Discard

0 commit comments

Comments
 (0)