Merged
Conversation
Adding methods similar to RepoProjects and OrganizationProjects to collect a list of RepoProjectV2. In constrast to projects old/v1, we cannot query projects by state. So, we filter out closed projects after fetching them.
With this change, project names are now mapped to a pair of ID lists. The first one contains IDs of old/v1 projects and the second contains the IDs of next/v2 projects. This allows us to exclude projectV2 IDs from IssueCreate and PullRequestCreate mutations and in the future, would allow us to include only projectV2 IDs in the addProjectV2ItemById mutation.
If creating the entity succeeded, then we add it by ID to all V2 projects. This will require triggering a mutation per project.
In constrast to regular field update, we track additions and deletions separately, since project items can be added to and remove from project, but not in a single mutation. To add item (i.e. issue or PR) to a project V2, we call AddProjectV2ItemById with the entity's ID and project's ID. Removing the item from a project is more tricky. The item known to the project does not correspond to an ID of an issue or PR. Instead, we firstly fetch all known item IDs that correspond to the issue or PR, and then remove those from all projects that are requested to be removed.
Prior to this commit, only projectV1 names were provided as hints when using interactive suvery. Now, projectV2 titles are also included in the proposal.
Handle if project scope does not exist Handle if host does not support projectsV2
Contributor
|
@qoega Thanks for the contribution and getting this work started. I pushed a couple commits that made these changes:
|
Contributor
Author
Contributor
mislav
approved these changes
Jan 18, 2023
| return nil, fmt.Errorf("error fetching projectsV2: %w", err) | ||
| } | ||
|
|
||
| orgProjectsV2, err := OrganizationProjectsV2(client, repo) |
Contributor
There was a problem hiding this comment.
Nit: repo projects and organization projects could be looked up in parallel with each other, since they're orthogonal
Contributor
There was a problem hiding this comment.
Agreed that we could do that but because of how this function is used in RepoMetadata function this change would be require adding some synchronization code around result.ProjectsV2 in RepoMetadata which would add a good amount of complexity for what seems like fairly little payoff. If we notice this is slow or receive complaints then we can optimize this further.
| if v, ok := inputs["teamIds"]; ok { | ||
| t.Errorf("did not expect teamIds: %v", v) | ||
| } | ||
| assert.NotContains(t, inputs, "userIds") |
This was referenced Jan 24, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR continues PR #6043 from another contributor.
Original fork is currently unavailable and I restored changes in separate one.
Rebased and fixed tests as they were reworked since last PR change.
Note: Currently I had to manually run
gh auth refresh -s projectto make it work. Probably it makes sense to add project scope to default scopes.Original PR description from #6043
Fixes #4547