Skip to content

Commit

Permalink
escape forward slashes in gitlab branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Jul 24, 2022
1 parent 07b069c commit c29b3f1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scm/driver/gitlab/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package gitlab
import (
"context"
"fmt"
"net/url"
"strings"
"time"

"github.com/drone/go-scm/scm"
Expand All @@ -33,6 +35,11 @@ func (s *gitService) FindBranch(ctx context.Context, repo, name string) (*scm.Re
}

func (s *gitService) FindCommit(ctx context.Context, repo, ref string) (*scm.Commit, *scm.Response, error) {
// if the reference is a branch, ensure forward slashes
// in the branch name are escaped.
if strings.Contains("ref", "/") {
ref = url.PathEscape(ref)
}
path := fmt.Sprintf("api/v4/projects/%s/repository/commits/%s", encode(repo), scm.TrimRef(ref))
out := new(commit)
res, err := s.client.do(ctx, "GET", path, nil, out)
Expand Down

0 comments on commit c29b3f1

Please sign in to comment.