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

[PL-25889]: fix list branches Azure API #195

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[PL-25889]: fix list branches Azure API
  • Loading branch information
bhavya181 committed Jun 15, 2022
commit f5cea0ee897ce9ed2a7ea445958636ccae7c8303
26 changes: 13 additions & 13 deletions scm/driver/azure/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type gitService struct {
func (s *gitService) CreateBranch(ctx context.Context, repo string, params *scm.CreateBranch) (*scm.Response, error) {
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/update-refs?view=azure-devops-rest-6.0
if s.client.project == "" {
return nil, ProjectRequiredError()
}
return nil, ProjectRequiredError()
}
endpoint := fmt.Sprintf("%s/%s/_apis/git/repositories/%s/refs?api-version=6.0", s.client.owner, s.client.project, repo)

in := make(crudBranch, 1)
Expand All @@ -32,16 +32,16 @@ func (s *gitService) CreateBranch(ctx context.Context, repo string, params *scm.

func (s *gitService) FindBranch(ctx context.Context, repo, name string) (*scm.Reference, *scm.Response, error) {
if s.client.project == "" {
return nil, nil, ProjectRequiredError()
}
return nil, nil, ProjectRequiredError()
}
return nil, nil, scm.ErrNotSupported
}

func (s *gitService) FindCommit(ctx context.Context, repo, ref string) (*scm.Commit, *scm.Response, error) {
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get?view=azure-devops-rest-6.0#get-by-id
if s.client.project == "" {
return nil, nil, ProjectRequiredError()
}
return nil, nil, ProjectRequiredError()
}
endpoint := fmt.Sprintf("%s/%s/_apis/git/repositories/%s/commits/%s?api-version=6.0", s.client.owner, s.client.project, repo, ref)
out := new(gitCommit)
res, err := s.client.do(ctx, "GET", endpoint, nil, out)
Expand All @@ -55,9 +55,9 @@ func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Refer
func (s *gitService) ListBranches(ctx context.Context, repo string, _ scm.ListOptions) ([]*scm.Reference, *scm.Response, error) {
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-6.0
if s.client.project == "" {
return nil, nil, ProjectRequiredError()
}
endpoint := fmt.Sprintf("%s/%s/_apis/git/repositories/%s/refs?api-version=6.0", s.client.owner, s.client.project, repo)
return nil, nil, ProjectRequiredError()
}
endpoint := fmt.Sprintf("%s/%s/_apis/git/repositories/%s/refs?includeMyBranches=true&api-version=6.0", s.client.owner, s.client.project, repo)
out := new(branchList)
res, err := s.client.do(ctx, "GET", endpoint, nil, &out)
return convertBranchList(out.Value), res, err
Expand All @@ -66,8 +66,8 @@ func (s *gitService) ListBranches(ctx context.Context, repo string, _ scm.ListOp
func (s *gitService) ListCommits(ctx context.Context, repo string, opts scm.CommitListOptions) ([]*scm.Commit, *scm.Response, error) {
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-commits?view=azure-devops-rest-6.0
if s.client.project == "" {
return nil, nil, ProjectRequiredError()
}
return nil, nil, ProjectRequiredError()
}
endpoint := fmt.Sprintf("%s/%s/_apis/git/repositories/%s/commits?", s.client.owner, s.client.project, repo)
if opts.Ref != "" {
endpoint += fmt.Sprintf("searchCriteria.itemVersion.version=%s&", opts.Ref)
Expand All @@ -93,8 +93,8 @@ func (s *gitService) ListChanges(ctx context.Context, repo, ref string, _ scm.Li
func (s *gitService) CompareChanges(ctx context.Context, repo, source, target string, _ scm.ListOptions) ([]*scm.Change, *scm.Response, error) {
// https://docs.microsoft.com/en-us/rest/api/azure/devops/git/diffs/get?view=azure-devops-rest-6.0
if s.client.project == "" {
return nil, nil, ProjectRequiredError()
}
return nil, nil, ProjectRequiredError()
}
endpoint := fmt.Sprintf("%s/%s/_apis/git/repositories/%s/diffs/commits?", s.client.owner, s.client.project, repo)
// add base
endpoint += fmt.Sprintf("baseVersion=%s&baseVersionType=commit&", source)
Expand Down