in reference-api/sources/github/commits.go [49:70]
func FetchCommits(repo, gitRef string) (*StandardizedOutput, int, error) {
currentCommit, err := FetchCommit(repo, gitRef)
if err != nil {
log.Printf("Error fetching current commit: %v", err)
if strings.Contains(err.Error(), "404") {
return nil, http.StatusNotFound, fmt.Errorf("commit not found for gitRef: %s", gitRef)
}
return nil, http.StatusInternalServerError, fmt.Errorf("error fetching commit: %v", err)
}
latestCommit, err := FetchLatestCommit(repo)
if err != nil {
log.Printf("Error fetching latest commit: %v", err)
latestCommit = nil // Allow partial results
}
// Standardize the commit response
return &StandardizedOutput{
Latest: StandardizeCommit(latestCommit),
Current: StandardizeCommit(currentCommit),
}, http.StatusOK, nil
}