From 1e57e243e0630be0bb49f51214b5d904cf01bde1 Mon Sep 17 00:00:00 2001 From: Andy Li <1450947+andy1li@users.noreply.github.com> Date: Tue, 10 Mar 2026 14:03:48 +0900 Subject: [PATCH] Refactor error handling in GetRepositoryDir to provide clearer error messages when the current directory is not a Git repository. The new message includes specific instructions for the user to run the command within the CodeCrafters Git repository. --- internal/utils/repository_dir.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/utils/repository_dir.go b/internal/utils/repository_dir.go index 1c2d8df..fff354c 100644 --- a/internal/utils/repository_dir.go +++ b/internal/utils/repository_dir.go @@ -19,10 +19,8 @@ func GetRepositoryDir() (string, error) { if err != nil { if _, ok := err.(*exec.ExitError); ok { if regexp.MustCompile("not a git repository").Match(outputBytes) { - fmt.Fprintf(os.Stderr, "The current directory is not within a Git repository.\n") - fmt.Fprintf(os.Stderr, "Please run this command from within your CodeCrafters Git repository.\n") - - return "", errors.New("used not in a repository") + return "", errors.New(`Error: The current directory is not within a Git repository. +Please run this command from within your CodeCrafters Git repository.`) } }