From 8cd736b2633eb58aae2755e23738c3dba635350f Mon Sep 17 00:00:00 2001 From: Jun Nishimura Date: Fri, 9 Jun 2023 01:09:40 +0900 Subject: [PATCH] ues client.Head.Commit at log (#106) --- cmd/log.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/cmd/log.go b/cmd/log.go index b35a7fd..cf21e17 100644 --- a/cmd/log.go +++ b/cmd/log.go @@ -79,20 +79,8 @@ var logCmd = &cobra.Command{ return fmt.Errorf("fatal: your current branch 'main' does not have any commits yet") } - // get last commit hash - branchPath := filepath.Join(dirName, "main") - lastCommitHashBytes, err := os.ReadFile(branchPath) - if err != nil { - return fmt.Errorf("%w: %s", ErrIOHandling, branchPath) - } - lastCommitHashString := string(lastCommitHashBytes) - lastCommitHash, err := sha.ReadHash(lastCommitHashString) - if err != nil { - return fmt.Errorf("fail to read hash: %w", err) - } - // print log - if err := walkHistory(lastCommitHash, func(commit *object.Commit) error { + if err := walkHistory(client.Head.Commit.Hash, func(commit *object.Commit) error { fmt.Println(commit) return nil }); err != nil {