-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch PR info from GH before trying to open it (#38)
This allows users to open PR's outside of `av` and then let av know about the state of that PR. This is mostly useful in scenarios where users open the first (root) PR using the GH UI, then realize that they want to stack their work on top if it. Before this commit, that wasn't possible (without closing the original PR and then re-creating it with `av pr create`). When we implement `av stack submit`, this should also happen automatically (for every PR in the stack), but that's a bridge we haven't quite reached.
- Loading branch information
Showing
4 changed files
with
132 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package gh | ||
|
||
// PageInfo contains information about the current/previous/next page of results | ||
// when using paginated APIs. | ||
type PageInfo struct { | ||
EndCursor string | ||
HasNextPage bool | ||
HasPreviousPage bool | ||
StartCursor string | ||
} | ||
|
||
// Ptr returns a pointer to the argument. | ||
// It's a convenience function to make working with the API easier: since Go | ||
// disallows pointers-to-literals, and optional input fields are expressed as | ||
// pointers, this function can be used to easily set optional fields to non-nil | ||
// primitives. | ||
// For example, githubv4.CreatePullRequestInput{Draft: Ptr(true)} | ||
func Ptr[T any](v T) *T { | ||
return &v | ||
} | ||
|
||
// nullable returns a pointer to the argument if it's not the zero value, | ||
// otherwise it returns nil. | ||
// This is useful to translate between Golang-style "unset is zero" and GraphQL | ||
// which distinguishes between unset (null) and zero values. | ||
func nullable[T comparable](v T) *T { | ||
var zero T | ||
if v == zero { | ||
return nil | ||
} | ||
return &v | ||
} |
This file contains 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