Giter Site home page Giter Site logo

Comments (6)

Mseller avatar Mseller commented on August 15, 2024 1

Created an issue in https://github.com/google/go-github: google/go-github#2402

from multi-gitter.

Mseller avatar Mseller commented on August 15, 2024

The issue seems to come from a dependency, namely: github.com/google/go-github/v39

If we see the https://github.com/google/go-github/blob/master/github/pulls.go#L265 there they are expecting the value *PullRequest to be returned, but in fact, we get returned a []PullRequest. So I did the following change locally:

Original

// Create a new pull request on the specified repository.
//
// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request
func (s *PullRequestsService) Create(ctx context.Context, owner string, repo string, pull *NewPullRequest) (*PullRequest, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo)
	req, err := s.client.NewRequest("POST", u, pull)
	if err != nil {
		return nil, nil, err
	}

	p := new(PullRequest)
	resp, err := s.client.Do(ctx, req, p)
	if err != nil {
		return nil, resp, err
	}

	return p, resp, nil
}

Change

// Create a new pull request on the specified repository.
//
// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-pull-request
func (s *PullRequestsService) Create(ctx context.Context, owner string, repo string, pull *NewPullRequest) (*PullRequest, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo)
	req, err := s.client.NewRequest("POST", u, pull)
	if err != nil {
		return nil, nil, err
	}

	p := &[]PullRequest{}
	resp, err := s.client.Do(ctx, req, p)
	if err != nil {
		return nil, resp, err
	}

	return &(*p)[0], resp, nil
}

I actually the PR created as expected and see no error output. Not sure if there is anything to do here in multi-gitter about this though? ๐Ÿค”

from multi-gitter.

lindell avatar lindell commented on August 15, 2024

Hi and thanks for the detailed report.
As you alluded to, I think this is a change that needs to be made in the go-github package. Please create a issue there, Iรคm happy to be a part of that discussion.

Do you know when this change happened, and if it is intended to come to none enterprise GitHub? The link in the updated code does 404 for me (https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-pull-request)

from multi-gitter.

Mseller avatar Mseller commented on August 15, 2024

I did some further investigation on this, and what happens is that when the PR is created, I get back a list of PRs (as if the endpoint GET /repos/{owner}/{repo}/pulls was called). However, that list only includes another open PR, not the one I actually created via the script. This is super weird. So I am not sure if it is actually a problem with the github package itself or our Enterprise instance.

Ahh, sorry about that, I also tried to upgrade the github.com/google/go-github package to see if that was the issue, so the change code is actually using version v45.2.0. However, from my use case above, there was no difference between the two versions.

from multi-gitter.

lindell avatar lindell commented on August 15, 2024

Any updates on this? Did you figure out why your instance returned an array?

from multi-gitter.

Mseller avatar Mseller commented on August 15, 2024

Sorry, I have been on vacation for 5 weeks, so I have not had time to look into this further. However, I believe we can safely say that the issue I am having is not due to this service, so I can close this issue ๐Ÿ˜„

from multi-gitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.