Skip to content

Commit

Permalink
ues client.Head.Commit at log (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jun 8, 2023
1 parent ecdc2db commit 8cd736b
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8cd736b

Please sign in to comment.