Skip to content

refactor!: Change required params from pointers to values #3654

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rupokghosh
Copy link

@rupokghosh rupokghosh commented Jul 27, 2025

BREAKING CHANGE: GitService endpoints now pass required params by-value instead of by-ref.

What problem are you solving?

Notes

This is most likely going to be a multi PR issue, since this is my first time working on this codebase. I started by picking a "service" area ( Git ) and converted each function that I thought met the criteria set in the issue mentioned, which are:

  1. The input is required (not optional)
  2. The function does not modify the input

@rupokghosh rupokghosh marked this pull request as ready for review July 27, 2025 21:32
@gmlewis gmlewis changed the title refactor: convert required pointer params to values refactor: Change required params from pointers to values Jul 27, 2025
@gmlewis
Copy link
Collaborator

gmlewis commented Jul 27, 2025

Please follow step 4 in CONTRIBUTING.md and push the changes to this PR.

@rupokghosh rupokghosh force-pushed the rupok/change-pointer-params-to-values branch from d124f0e to 826440e Compare July 28, 2025 01:26
@rupokghosh
Copy link
Author

done ✔️ @gmlewis

Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@6dda213). Learn more about missing BASE report.
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
example/commitpr/main.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3654   +/-   ##
=========================================
  Coverage          ?   91.24%           
=========================================
  Files             ?      184           
  Lines             ?    16299           
  Branches          ?        0           
=========================================
  Hits              ?    14872           
  Misses            ?     1245           
  Partials          ?      182           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if ref == nil {
return nil, nil, errors.New("reference must be provided")
}
func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref Reference) (*Reference, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are breaking compatibility here, I propose refactoring:

// CreateRef represents the payload for creating a reference.
type CreateRef struct {
	Ref string `json:"ref"`
	SHA string `json:"sha"`
}

func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref CreateRef) (*Reference, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo)
	req, err := s.client.NewRequest("POST", u, ref)
	if err != nil {
		return nil, nil, err
	}
	// ...

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sounds good to me. And while you are here, this should be owner, repo string instead of owner string, repo string.

Copy link
Contributor

Choose a reason for hiding this comment

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

And while you are here, this should be owner, repo string instead of owner string, repo string.

Fixed in a separate PR #3655

Copy link
Author

Choose a reason for hiding this comment

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

can this change come in a separate PR or should I ship this in this PR? I see that this would require some heavy changes in test cases and I am thinking it might be out of scope of this PR? what do you guys think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is already a disruptive API-breaking PR, I suggest we go ahead and address it here within this PR instead of breaking the API twice.

@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 Jul 31, 2025
@gmlewis gmlewis changed the title refactor: Change required params from pointers to values refactor!: Change required params from pointers to values Jul 31, 2025
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.

3 participants