Skip to content

Commit

Permalink
switch graphql client to use fezzik
Browse files Browse the repository at this point in the history
commit-id:6060076e
  • Loading branch information
ejoffe authored and Eitan Joffe committed Jul 25, 2022
1 parent 51f9f7d commit 72d297b
Show file tree
Hide file tree
Showing 16 changed files with 49,594 additions and 277 deletions.
12 changes: 6 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/ejoffe/rake"
"github.com/ejoffe/spr/git"
"github.com/shurcooL/githubv4"
"github.com/ejoffe/spr/github/githubclient/gen/genclient"
)

type Config struct {
Expand Down Expand Up @@ -125,16 +125,16 @@ func GitHubRemoteSource(config *Config, gitcmd git.GitInterface) *remoteSource {
}
}

func (c Config) MergeMethod() (githubv4.PullRequestMergeMethod, error) {
var mergeMethod githubv4.PullRequestMergeMethod
func (c Config) MergeMethod() (genclient.PullRequestMergeMethod, error) {
var mergeMethod genclient.PullRequestMergeMethod
var err error
switch strings.ToLower(c.Repo.MergeMethod) {
case "merge":
mergeMethod = githubv4.PullRequestMergeMethodMerge
mergeMethod = genclient.PullRequestMergeMethod_MERGE
case "squash":
mergeMethod = githubv4.PullRequestMergeMethodSquash
mergeMethod = genclient.PullRequestMergeMethod_SQUASH
case "rebase", "":
mergeMethod = githubv4.PullRequestMergeMethodRebase
mergeMethod = genclient.PullRequestMergeMethod_REBASE
default:
err = fmt.Errorf(
`unknown merge method %q, choose from "merge", "squash", or "rebase"`,
Expand Down
12 changes: 6 additions & 6 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/ejoffe/spr/git/mockgit"
"github.com/shurcooL/githubv4"
"github.com/ejoffe/spr/github/githubclient/gen/genclient"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -126,23 +126,23 @@ func TestGitHubRemoteSource(t *testing.T) {
func TestMergeMethodHelper(t *testing.T) {
for _, tc := range []struct {
configValue string
expected githubv4.PullRequestMergeMethod
expected genclient.PullRequestMergeMethod
}{
{
configValue: "rebase",
expected: githubv4.PullRequestMergeMethodRebase,
expected: genclient.PullRequestMergeMethod_REBASE,
},
{
configValue: "",
expected: githubv4.PullRequestMergeMethodRebase,
expected: genclient.PullRequestMergeMethod_REBASE,
},
{
configValue: "Merge",
expected: githubv4.PullRequestMergeMethodMerge,
expected: genclient.PullRequestMergeMethod_MERGE,
},
{
configValue: "SQUASH",
expected: githubv4.PullRequestMergeMethodSquash,
expected: genclient.PullRequestMergeMethod_SQUASH,
},
} {
tcName := tc.configValue
Expand Down

0 comments on commit 72d297b

Please sign in to comment.