func FetchLatestCommit()

in reference-api/sources/github/commits.go [32:46]


func FetchLatestCommit(repo string) (*github.RepositoryCommit, error) {
	owner, repoName, _ := strings.Cut(repo, "/")
	client := NewGithubClient((repo))
	ctx := context.Background()
	commits, _, err := client.Repositories.ListCommits(ctx, owner, repoName, nil)
	if err != nil {
		return nil, err
	}

	if len(commits) > 0 {
		return commits[0], nil
	}

	return nil, fmt.Errorf("no commits found")
}