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

Create RepositoryRefsOptions and ListRefs method with helper funcs #155

Merged

Conversation

DataDavD
Copy link
Contributor

TL;DR: this PR creates a RepositoryRefsOptions type and starts the groundwork to eventually remove RepositoryBranchOptions and RepositoryTagOptions and those methods that relies on these types.

This PR creates a RepositoryRefsOptions and a ListRefs method on the Repository type. This new refs type will allow users to specific their refs options once and be able to operate on all kinds of refs (i.e. tags and branches) without specifying 2 separate options. Right now, users have to specify a RepositoryBranchOptions and RepositoryTagOptions in order to call ListBranches and ListTags.

This current iteration of the code doesn't adhere to the fact that git refers to all branches and tags as refs and this is reflected in the Bitbucket API since both tags and branches endpoints are build off of the refs endpoint.

I want to add a test for this new ListRefs function, but in the meantime I wanted to create this PR s that we could discuss future plans. Currently, I think it is best to keep Refs options alongside the branches and tags options since if we remove those 2 option types then it imparts a breaking change on users. So we should slowly move towards removing those option types and their methods instead removing support all at once and making a bunch of breaking changes.

Once we have built out the same functionality for branches and tags build upon the refs options type then we can move to completely remove the branches and tags options types and release for a breaking change.

This commit creates a ListRefs method of the Repository type.
Specifically, it creates a RepositoryRefs struct type that is returned
from the decoodeRepositoryRefs function that is a helper function
for decoding the reponse from the refs GET API Bitbucket endpoint.
@ktrysmt
Copy link
Owner

ktrysmt commented Jul 27, 2021

Exactly. First, we should add the new apis in it. after that, we update old apis to show deprecated notifications for an end user. Finally, delete the old apis.
So, I think that only this PR should create new api first. @DataDavD

@ktrysmt
Copy link
Owner

ktrysmt commented Jul 27, 2021

And, Looks good for me, may be.

@ktrysmt
Copy link
Owner

ktrysmt commented Jul 27, 2021

I'll carefully read it later.

This commit creates a test case for ListRefs based on setting up the
test repo with a new branch and then listing the refs and making sure
properly created the test repo. So, this test case technically also
tests a portion of the functionality of the CreateBranch function.
@DataDavD
Copy link
Contributor Author

Hey @ktrysmt FYI I added a test case for the ListRefs method. I only ran the test_repository.go test cases which passed. My test isn't the greatest but it works. I believe the PR is good now. I will work on adding the delete branch and tag methods next in #154.

Copy link
Owner

@ktrysmt ktrysmt left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you.

@DataDavD
Copy link
Contributor Author

Great thank you @ktrysmt. I'll look out for the merge! 💯 . I'm going to start working on the delete branch and tag methods which I think will be useful for setting up testing that tests methods that work on branches/tags.

DataDavD added a commit to DataDavD/go-bitbucket that referenced this pull request Jul 30, 2021
This commit refactors the existing RepositoryBranchTarget and
RepositoryTagTarget types to a single RepositoryRefTarget since tags and
branches are both refs and the two Target variables represented the
same type anyways. This will also help us move to removing branch
and tag specific options types into a single refs options type.

See ktrysmt#155 and
ktrysmt#153 (comment)
@ktrysmt ktrysmt merged commit f3ac86c into ktrysmt:master Jul 30, 2021
@DataDavD DataDavD changed the title Create RepositoryRefsOptions and ListRefs method with helper funds Create RepositoryRefsOptions and ListRefs method with helper funcs Jul 30, 2021
DataDavD added a commit to DataDavD/go-bitbucket that referenced this pull request Dec 8, 2021
This commit refactors the existing RepositoryBranchTarget and
RepositoryTagTarget types to a single RepositoryRefTarget since tags and
branches are both refs and the two Target variables represented the
same type anyways. This will also help us move to removing branch
and tag specific options types into a single refs options type.

See ktrysmt#155 and
ktrysmt#153 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants