Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change all fields from time.Time to github.Timestamp #2646

Merged
merged 4 commits into from Jan 26, 2023

Conversation

zombieleet
Copy link
Contributor

This PR introduces breaking API changes as described here #2645
It also fix the related test for the breaking API changes

@gmlewis gmlewis added the Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). label Jan 26, 2023
@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #2646 (d65736f) into master (36c47d1) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2646   +/-   ##
=======================================
  Coverage   98.05%   98.05%           
=======================================
  Files         130      130           
  Lines       11242    11244    +2     
=======================================
+ Hits        11023    11025    +2     
  Misses        150      150           
  Partials       69       69           
Impacted Files Coverage Δ
github/apps.go 95.16% <ø> (ø)
github/event.go 100.00% <ø> (ø)
github/gists.go 96.68% <ø> (ø)
github/gists_comments.go 100.00% <ø> (ø)
github/git_commits.go 100.00% <ø> (ø)
github/issues.go 97.41% <ø> (ø)
github/issues_comments.go 100.00% <ø> (ø)
github/issues_events.go 100.00% <ø> (ø)
github/issues_milestones.go 100.00% <ø> (ø)
github/issues_timeline.go 100.00% <ø> (ø)
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Composites checks prevents using unkeyed fields, which is not needed in the examples project because
`time.Time` is embedded into `github.Timestamp`
Comment on lines +24 to +26
issues:
exclude:
- composites
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the examples project was having a type error, it was fixed by using github.Timestamp, which caused another error in go vet relating to unkeyed fields. excluding composites fixes the error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious what we were missing by excluding composites, I ran across these issues:

in case anyone in the future finds this and wonders about it.

@gmlewis gmlewis changed the title Change type in time related fields Change all fields from time.Time to github.Timestamp Jan 26, 2023
@gmlewis
Copy link
Collaborator

gmlewis commented Jan 26, 2023

@willnorris - this is a significant breaking change affecting a large number of fields.

Personally, I'm fine with it, but before we make such a sweeping change, I'd like to make sure you are fine with this too.

@willnorris
Copy link
Collaborator

In general, I don't really love moving away from standard Go types where it's not actually necessary. It makes it harder to interop with other libraries and existing code. In hindsight, I kinda wonder if we could have made Timestamp a time.Time rather than a struct containing a Time. (type Timestamp time.Time) But whatever, that ship has long sailed.

It looks like github.Timestamp was introduced in c6d364f for timestamps in the repo struct. It looks like we're already using github.Timestamp quite a bit in the library, though I'm curious how much of that is actually needing to parse unix timestamps versus just doing what other parts of the library are doing. At the end of the day, I guess it probably doesn't matter too much.

Given that timestamps are almost exclusively read (I don't know of any GitHub API off the top of my head that involves providing a timestamp), and github.Timestamp includes all of the same methods as time.Time, I think this is probably fine. I haven't reviewed all of the changes in this PR, but the general approach sounds okay.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @willnorris and @zombieleet !
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

Copy link
Contributor

@ganeshkumarsv ganeshkumarsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 26, 2023

Thank you, @ganeshkumarsv !
Merging.

@gmlewis gmlewis merged commit cdecead into google:master Jan 26, 2023
@gmlewis
Copy link
Collaborator

gmlewis commented Jan 26, 2023

Fixes: #2645.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants