Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address projects bugs #7007

Merged
merged 5 commits into from Feb 15, 2023
Merged

Address projects bugs #7007

merged 5 commits into from Feb 15, 2023

Conversation

samcoe
Copy link
Contributor

@samcoe samcoe commented Feb 12, 2023

Fixes #6989 - Allow retrieving projectItems from --json flag.
Fixes #6940 - Retrieve current user projectsV2 along with projectsV2 we were already retrieving.

Note that for now I did not address the behavior of projects with duplicate names. I think we should hold off on that for now as any behavior that I experimented with felt confusing. When there are duplicate named projects there is no way to know which project a user is referring to. I think our advice for users in this situation should be to rename the project to a unique name and/or manipulate the project on the web. This edge case seems highly unlikely as we have never (as far as I know) run into it with projects classic. If we have reports of this actually occurring we can revisit my decision.

@samcoe samcoe self-assigned this Feb 12, 2023
@samcoe samcoe requested a review from a team as a code owner February 12, 2023 23:04
@samcoe samcoe requested review from mislav and removed request for a team February 12, 2023 23:04
@cliAutomation cliAutomation added this to Needs review 🤔 in The GitHub CLI Feb 12, 2023
@@ -42,45 +42,6 @@ func OrganizationProjects(client *Client, repo ghrepo.Interface) ([]RepoProject,
return projects, nil
}

// OrganizationProjectsV2 fetches all open projectsV2 for an organization.
func OrganizationProjectsV2(client *Client, repo ghrepo.Interface) ([]RepoProjectV2, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just got moved not actually deleted. Consolidated it in queries_projects_v2.go.

count := 0
var result RepoMetadataResult

g, _ := errgroup.WithContext(context.Background())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errgroup felt like a nice improvement here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Nit: since we don't have a parent context here, and we won't use the child context for anything either, you can just initialize a Group without context.

Suggested change
g, _ := errgroup.WithContext(context.Background())
var g errgroup.Group

@@ -1096,87 +1067,6 @@ func RepoProjects(client *Client, repo ghrepo.Interface) ([]RepoProject, error)
return projects, nil
}

// RepoProjectsV2 fetches all open projectsV2 for a repository.
func RepoProjectsV2(client *Client, repo ghrepo.Interface) ([]RepoProjectV2, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to queries_projects_v2.go

@@ -1050,14 +1029,6 @@ type RepoProject struct {
ResourcePath string `json:"resourcePath"`
}

type RepoProjectV2 struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to queries_projects_v2.go

@@ -96,6 +104,14 @@ func (pr *PullRequest) ExportData(fields []string) map[string]interface{} {
data[f] = pr.Labels.Nodes
case "projectCards":
data[f] = pr.ProjectCards.Nodes
case "projectItems":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually have these field names map closely to the underlying GraphQL schema, but that's not a strict contract. In this case, I wonder if the projectCards vs. projectItems distinction does any service to the user. Offering both without any documentation clarifying that one is Projects Classic and another is Projects Next could be confusing.

Could we just merge ProjectItems and expose it under projectCards?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the distinction is confusing. We definitely could merge the two. I think there are two downsides.

The first is that new projects don't use "cards", so it might be confusing for users who are familiar with only projects V2.

Second, is that the data we want to return for each is slightly different. They have the title in common but that is about it. What if in the future we want to expand on what data gets returned for projectItems? I don't envision projectCards getting expanded as projects classic usage dwindles.

I think if we didn't have to worry about backwards compatibility I would suggest making a new projects name that would encompass both, while removing projectCards. Since we do, I would perhaps leave it as projectCards and projectItems while adding some help documentation describing the difference.

Copy link
Contributor

@mislav mislav Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about "cards" not being a term that new-style Projects use. Now that you reasoned about this, I see value in projectCards and projectItems being distinct. I wonder if we could somehow provide some documentation for our --json fields noting that projectCards is basically a legacy API and that most users will want projectItems for their generic Projects-related needs 🤔

api/queries_projects_v2.go Outdated Show resolved Hide resolved
"pageInfo": { "hasNextPage": false }
} } } }
`))
mockRetrieveProjects(t, reg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see!

@samcoe samcoe requested a review from mislav February 13, 2023 23:58
count := 0
var result RepoMetadataResult

g, _ := errgroup.WithContext(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Nit: since we don't have a parent context here, and we won't use the child context for anything either, you can just initialize a Group without context.

Suggested change
g, _ := errgroup.WithContext(context.Background())
var g errgroup.Group

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Feb 14, 2023
@samcoe samcoe enabled auto-merge (squash) February 15, 2023 22:03
@samcoe samcoe merged commit 08a1231 into trunk Feb 15, 2023
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Feb 15, 2023
@samcoe samcoe deleted the more-projects branch February 15, 2023 22:15
@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

Issue list command does not support non-classic Projects Differences with Projects Classic and Projects V2
2 participants