go-github icon indicating copy to clipboard operation
go-github copied to clipboard

PushEvent GetCommits() Method

Open midnightconman opened this issue 3 years ago • 2 comments

I would like to use an interface for this event in a local implementation, but unfortunately a getter for this type doesn't exist. Can we create a getter for PushEvent.GetCommits?

type PushEvent struct {
...
Commits      []*HeadCommit
...
}

func (p *PushEvent) GetCommits() []*HeadCommit {
    return p.Commits
}

midnightconman avatar Jul 29 '22 23:07 midnightconman

In general, getters are only provided for anything where a nil might be a problem (which is not the case for slices of anything), and all getters are auto-generated.

So if you want to add one for this, then I suppose we have a few options:

  1. add getters for all fields, but that seems wasteful
  2. modify the auto-generator to add a list of "special" getters that we want to always add (e.g. PushEvent.Commits)
  3. manually add a getter to the main source code and completely ignore the auto-generator

I'm kinda leaning toward option 2.

Thoughts?

gmlewis avatar Jul 29 '22 23:07 gmlewis

2 sounds good to me 😸 Let me take a look at the auto-generator code. Thank you!

midnightconman avatar Jul 29 '22 23:07 midnightconman

I would like to propose some changes and request for a review.

  • https://github.com/google/go-github/pull/2776

I would appreciate it if you could check it out!

olibaa avatar Apr 30 '23 12:04 olibaa