Skip to content

Add new command issue pin#5597

Merged
samcoe merged 5 commits intocli:trunkfrom
ffalor:issue_pin
Aug 31, 2022
Merged

Add new command issue pin#5597
samcoe merged 5 commits intocli:trunkfrom
ffalor:issue_pin

Conversation

@ffalor
Copy link
Contributor

@ffalor ffalor commented May 10, 2022

Fixes #5585

Adds the issue pin command to pin issues to a repository
Adds the --remove flag to remove pinned issues from a repository

image

@ffalor ffalor marked this pull request as ready for review May 15, 2022 22:11
@ffalor ffalor requested a review from a team as a code owner May 15, 2022 22:11
@ffalor ffalor requested review from mislav and removed request for a team May 15, 2022 22:11
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label May 15, 2022
Comment on lines +75 to +94
// isPinned is an invalid field for PullRequest
prFields := make([]string, len(fields))
for i, f := range fields {
if f == "isPinned" {
prFields = append(fields[:i], fields[i+1:]...)
break
}
}

query := fmt.Sprintf(`
query IssueByNumber($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
hasIssuesEnabled
issue: issueOrPullRequest(number: $number) {
__typename
...on Issue{%[1]s}
...on PullRequest{%[1]s}
...on PullRequest{%[2]s}
}
}
}`, api.PullRequestGraphQL(fields))
}`, api.PullRequestGraphQL(fields), api.PullRequestGraphQL(prFields))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lmk if there is a better way to do this. My graphql knowledge is limited.

Copy link
Contributor

@rsteube rsteube May 17, 2022

Choose a reason for hiding this comment

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

repository has pinnedIssues (see here).
Might potentially give better performance but could also opt for this solution for consistency.
edit: ah forget it, you aren't listing them but rather looking up by number 😄

@vilmibm vilmibm assigned samcoe and unassigned mislav Aug 22, 2022
@vilmibm vilmibm requested a review from samcoe August 22, 2022 16:19
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

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

@ffalor Apologies for taking so long to get around to this PR. The code looked great to me, but out of date so I pulled in the latest trunk. Also while looking over it I decided that having two commands pin and unpin was more desirable than pin --remove, so I pushed a change to implement that.

@samcoe samcoe enabled auto-merge (squash) August 31, 2022 10:11
@samcoe samcoe merged commit 665e4e3 into cli:trunk Aug 31, 2022
@ffalor ffalor deleted the issue_pin branch August 31, 2022 22:20
@adriens
Copy link

adriens commented Sep 19, 2022

Lve demo here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

issue pinning

6 participants