added to repo struct and working on fetching merge opts for repo
This commit is contained in:
parent
f1ea9102c4
commit
5f67ddc975
2 changed files with 35 additions and 2 deletions
|
|
@ -32,6 +32,10 @@ type Repository struct {
|
|||
|
||||
Parent *Repository
|
||||
|
||||
MergeCommitAllowed bool
|
||||
SquashMergeAllowed bool
|
||||
RebaseMergeAllowed bool
|
||||
|
||||
// pseudo-field that keeps track of host name of this repo
|
||||
hostname string
|
||||
}
|
||||
|
|
@ -869,3 +873,30 @@ func MilestoneByNumber(client *Client, repo ghrepo.Interface, number int) (*Repo
|
|||
|
||||
return query.Repository.Milestone, nil
|
||||
}
|
||||
|
||||
func GetRepoPROpts(client *Client, repo ghrepo.Interface) (*Repository, error) {
|
||||
query := `
|
||||
query RepositoryInfo($owner: String!, $name: String!) {
|
||||
repository(owner: $owner, name: $name) {
|
||||
mergeCommitAllowed
|
||||
squashMergeAllowed
|
||||
rebaseMergeAllowed
|
||||
}
|
||||
}`
|
||||
variables := map[string]interface{}{
|
||||
"owner": repo.RepoOwner(),
|
||||
"name": repo.RepoName(),
|
||||
}
|
||||
|
||||
result := struct {
|
||||
Repository Repository
|
||||
}{}
|
||||
|
||||
err := client.GraphQL(repo.RepoHost(), query, variables, &result)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &result.Repository, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func mergeRun(opts *MergeOptions) error {
|
|||
crossRepoPR := pr.HeadRepositoryOwner.Login != baseRepo.RepoOwner()
|
||||
|
||||
if opts.InteractiveMode {
|
||||
mergeMethod, deleteBranch, err = prInteractiveMerge(opts.DeleteLocalBranch, crossRepoPR)
|
||||
mergeMethod, deleteBranch, err = prInteractiveMerge(opts.DeleteLocalBranch, crossRepoPR, baseRepo, apiClient)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -237,7 +237,9 @@ func mergeRun(opts *MergeOptions) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func prInteractiveMerge(deleteLocalBranch bool, crossRepoPR bool) (api.PullRequestMergeMethod, bool, error) {
|
||||
func prInteractiveMerge(deleteLocalBranch bool, crossRepoPR bool, repo ghrepo.Interface, apiClient *api.Client) (api.PullRequestMergeMethod, bool, error) {
|
||||
repoMergeOpts, err := api.GetRepoPROpts(apiClient, repo)
|
||||
|
||||
mergeMethodQuestion := &survey.Question{
|
||||
Name: "mergeMethod",
|
||||
Prompt: &survey.Select{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue