func ListCommit(apiClient pfs.APIClient, repoName string) ([]*pfs.CommitInfo, error) { commitInfos, err := apiClient.ListCommit( context.Background(), &pfs.ListCommitRequest{ Repo: &pfs.Repo{ Name: repoName, }, }, ) if err != nil { return nil, err } return commitInfos.CommitInfo, nil }
func ListCommit(apiClient pfs.APIClient, repoNames []string) ([]*pfs.CommitInfo, error) { var repos []*pfs.Repo for _, repoName := range repoNames { repos = append(repos, &pfs.Repo{Name: repoName}) } commitInfos, err := apiClient.ListCommit( context.Background(), &pfs.ListCommitRequest{ Repo: repos, }, ) if err != nil { return nil, err } return commitInfos.CommitInfo, nil }
func testBlockListCommits(t *testing.T, apiClient pfs.APIClient, cluster Cluster) { repoName := "testBlockListCommitsRepo" err := pfsutil.CreateRepo(apiClient, repoName) require.NoError(t, err) baseCommit, err := pfsutil.StartCommit(apiClient, repoName, "") require.NoError(t, err) err = pfsutil.FinishCommit(apiClient, repoName, baseCommit.Id) require.NoError(t, err) repo := &pfs.Repo{ Name: repoName, } listCommitRequest := &pfs.ListCommitRequest{ Repo: repo, From: baseCommit, } commitInfos, err := apiClient.ListCommit( context.Background(), listCommitRequest, ) require.NoError(t, err) require.Equal(t, len(commitInfos.CommitInfo), 0) var newCommit *pfs.Commit var wg sync.WaitGroup wg.Add(1) go func() { defer wg.Done() time.Sleep(1) commit, err := pfsutil.StartCommit(apiClient, repoName, baseCommit.Id) require.NoError(t, err) require.NotNil(t, commit) newCommit = commit }() listCommitRequest.Block = true listCommitRequest.CommitType = pfs.CommitType_COMMIT_TYPE_WRITE commitInfos, err = apiClient.ListCommit( context.Background(), listCommitRequest, ) wg.Wait() require.NoError(t, err) require.Equal(t, len(commitInfos.CommitInfo), 1) require.Equal(t, newCommit, commitInfos.CommitInfo[0].Commit) wg = sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() time.Sleep(1) err := pfsutil.FinishCommit(apiClient, repoName, newCommit.Id) require.NoError(t, err) }() listCommitRequest.Block = true listCommitRequest.CommitType = pfs.CommitType_COMMIT_TYPE_READ commitInfos, err = apiClient.ListCommit( context.Background(), listCommitRequest, ) wg.Wait() require.NoError(t, err) require.Equal(t, len(commitInfos.CommitInfo), 1) require.Equal(t, newCommit, commitInfos.CommitInfo[0].Commit) }