Skip to content

Commit

Permalink
escape branch names in the query as well
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzacy authored and andygrunwald committed Dec 7, 2018
1 parent 43cfd7a commit 7b0d1f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions projects_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *ProjectsService) ListBranches(projectName string, opt *BranchOptions) (
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-branch
func (s *ProjectsService) GetBranch(projectName, branchID string) (*BranchInfo, *Response, error) {
u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), branchID)
u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), url.QueryEscape(branchID))

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
Expand All @@ -93,7 +93,7 @@ func (s *ProjectsService) GetBranch(projectName, branchID string) (*BranchInfo,
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-reflog
func (s *ProjectsService) GetReflog(projectName, branchID string) (*[]ReflogEntryInfo, *Response, error) {
u := fmt.Sprintf("projects/%s/branches/%s/reflog", url.QueryEscape(projectName), branchID)
u := fmt.Sprintf("projects/%s/branches/%s/reflog", url.QueryEscape(projectName), url.QueryEscape(branchID))

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
Expand All @@ -114,7 +114,7 @@ func (s *ProjectsService) GetReflog(projectName, branchID string) (*[]ReflogEntr
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#create-branch
func (s *ProjectsService) CreateBranch(projectName, branchID string, input *BranchInput) (*BranchInfo, *Response, error) {
u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), branchID)
u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), url.QueryEscape(branchID))

req, err := s.client.NewRequest("PUT", u, input)
if err != nil {
Expand All @@ -134,7 +134,7 @@ func (s *ProjectsService) CreateBranch(projectName, branchID string, input *Bran
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#delete-branch
func (s *ProjectsService) DeleteBranch(projectName, branchID string) (*Response, error) {
u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), branchID)
u := fmt.Sprintf("projects/%s/branches/%s", url.QueryEscape(projectName), url.QueryEscape(branchID))
return s.client.DeleteRequest(u, nil)
}

Expand All @@ -152,6 +152,6 @@ func (s *ProjectsService) DeleteBranches(projectName string, input *DeleteBranch
//
// Gerrit API docs: https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-content
func (s *ProjectsService) GetBranchContent(projectName, branchID, fileID string) (string, *Response, error) {
u := fmt.Sprintf("projects/%s/branches/%s/files/%s/content", url.QueryEscape(projectName), branchID, fileID)
u := fmt.Sprintf("projects/%s/branches/%s/files/%s/content", url.QueryEscape(projectName), url.QueryEscape(branchID), fileID)
return getStringResponseWithoutOptions(s.client, u)
}

0 comments on commit 7b0d1f8

Please sign in to comment.