Skip to content

Combine Brach and Tag Options #153

Open
@codeaucafe

Description

@codeaucafe

Currently Branches and Tags have separate Options structs although they are essentially the same endpoint. RepoBranchesOptions is only different from RepoTagsOptions in that it possess a BranchName field as shown here

go-bitbucket/bitbucket.go

Lines 202 to 211 in dd20750

type RepositoryBranchOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Query string `json:"query"`
Sort string `json:"sort"`
PageNum int `json:"page"`
Pagelen int `json:"pagelen"`
MaxDepth int `json:"max_depth"`
BranchName string `json:"branch_name"`
}

and

go-bitbucket/bitbucket.go

Lines 224 to 232 in dd20750

type RepositoryTagOptions struct {
Owner string `json:"owner"`
RepoSlug string `json:"repo_slug"`
Query string `json:"q"`
Sort string `json:"sort"`
PageNum int `json:"page"`
Pagelen int `json:"pagelen"`
MaxDepth int `json:"max_depth"`
}

I propose that we combine the repo branches and tag option structs into a single RepositoryRefOptions (branches and tags are both refs anyways) and instead of a BranchName field just have a Name field that represents either the branch name or tag name. This would allow us to have a single ListRefs function instead of two separate functions for listing branches and listing tags. That way users can use the same options struct to access a single function for listing refs (i.e. branches or tags) and it can make use of the existing GetBranch function to also get a tag.

So, @ktrysmt If this proposal is acceptable and you agree, can you assign me to do this refactor please. For context, I've already started working on this for fun in my fork.

Thanks in advance.

Best,
dd

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions