Skip to content

Commit

Permalink
refactor: remove owner param from get commits range (#1050)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Dagelic <[email protected]>
  • Loading branch information
idagelic authored Sep 4, 2024
1 parent 1d15289 commit 690d0c5
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/testing/gitprovider/mocks/git_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func (m *MockGitProvider) UnregisterPrebuildWebhook(repo *gitprovider.GitReposit
return args.Error(0)
}

func (m *MockGitProvider) GetCommitsRange(repo *gitprovider.GitRepository, owner string, initialSha string, currentSha string) (int, error) {
args := m.Called(repo, owner, initialSha, currentSha)
func (m *MockGitProvider) GetCommitsRange(repo *gitprovider.GitRepository, initialSha string, currentSha string) (int, error) {
args := m.Called(repo, initialSha, currentSha)
return args.Int(0), args.Error(1)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gitprovider/git_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type GitProvider interface {
RegisterPrebuildWebhook(repo *GitRepository, endpointUrl string) (string, error)
GetPrebuildWebhook(repo *GitRepository, endpointUrl string) (*string, error)
UnregisterPrebuildWebhook(repo *GitRepository, id string) error
GetCommitsRange(repo *GitRepository, owner string, initialSha string, currentSha string) (int, error)
GetCommitsRange(repo *GitRepository, initialSha string, currentSha string) (int, error)
ParseEventData(request *http.Request) (*GitEventData, error)
}

Expand Down Expand Up @@ -175,7 +175,7 @@ func (g *AbstractGitProvider) UnregisterPrebuildWebhook(repo *GitRepository, id
return errors.New("prebuilds not yet implemented for this git provider")
}

func (g *AbstractGitProvider) GetCommitsRange(repo *GitRepository, owner string, initialSha string, currentSha string) (int, error) {
func (g *AbstractGitProvider) GetCommitsRange(repo *GitRepository, initialSha string, currentSha string) (int, error) {
return 0, errors.New("prebuilds not yet implemented for this git provider")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/gitprovider/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ func (g *GitHubGitProvider) UnregisterPrebuildWebhook(repo *GitRepository, id st
return err
}

func (g *GitHubGitProvider) GetCommitsRange(repo *GitRepository, owner string, initialSha string, currentSha string) (int, error) {
func (g *GitHubGitProvider) GetCommitsRange(repo *GitRepository, initialSha string, currentSha string) (int, error) {
client := g.getApiClient()

commits, _, err := client.Repositories.CompareCommits(context.Background(), owner, repo.Name, initialSha, currentSha)
commits, _, err := client.Repositories.CompareCommits(context.Background(), repo.Owner, repo.Name, initialSha, currentSha)
if err != nil {
return 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gitprovider/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func (g *GitLabGitProvider) UnregisterPrebuildWebhook(repo *GitRepository, hookI
return nil
}

func (g *GitLabGitProvider) GetCommitsRange(repo *GitRepository, owner string, initialSha string, currentSha string) (int, error) {
func (g *GitLabGitProvider) GetCommitsRange(repo *GitRepository, initialSha string, currentSha string) (int, error) {
client := g.getApiClient()

projectID := fmt.Sprintf("%s/%s", repo.Owner, repo.Name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/projectconfig/prebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (s *ProjectConfigService) ProcessGitEvent(data gitprovider.GitEventData) er
continue
}

commitsRange, err := gitProvider.GetCommitsRange(repo, data.Owner, newestBuild.Repository.Sha, data.Sha)
commitsRange, err := gitProvider.GetCommitsRange(repo, newestBuild.Repository.Sha, data.Sha)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/projectconfig/prebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s *ProjectConfigServiceTestSuite) TestProcessGitEventCommitInterval() {
AffectedFiles: []string{},
}

s.gitProvider.On("GetCommitsRange", repository1, data.Owner, repository1.Sha, data.Sha).Return(3, nil)
s.gitProvider.On("GetCommitsRange", repository1, repository1.Sha, data.Sha).Return(3, nil)

err := s.projectConfigService.ProcessGitEvent(data)
require.Nil(err)
Expand Down

0 comments on commit 690d0c5

Please sign in to comment.