@@ -10,7 +10,7 @@ import (
1010 "github.com/simondanielsson/apPRoved/cmd/internal/dto/responses"
1111 "github.com/simondanielsson/apPRoved/cmd/internal/models"
1212 "github.com/simondanielsson/apPRoved/cmd/internal/repositories"
13- "github.com/simondanielsson/apPRoved/pkg/utils"
13+ "github.com/simondanielsson/apPRoved/pkg/utils/git "
1414 "github.com/simondanielsson/apPRoved/pkg/utils/mq"
1515 "gorm.io/gorm"
1616)
@@ -47,7 +47,7 @@ func (rs *ReviewsService) GetRepositories(tx *gorm.DB, userID uint) ([]*response
4747}
4848
4949// RegisterRepository registers a new repository and its pull requests
50- func (rs * ReviewsService ) RegisterRepository (ctx context.Context , tx * gorm.DB , githubClient utils. GithubClient , userID uint , name , owner , url string ) (* responses.GetRepositoriesResponse , error ) {
50+ func (rs * ReviewsService ) RegisterRepository (ctx context.Context , tx * gorm.DB , gitClient git. GitClient , userID uint , name , owner , url string ) (* responses.GetRepositoriesResponse , error ) {
5151 repo := & models.Repository {
5252 UserID : userID ,
5353 Name : name ,
@@ -59,7 +59,7 @@ func (rs *ReviewsService) RegisterRepository(ctx context.Context, tx *gorm.DB, g
5959 return nil , err
6060 }
6161
62- prs , err := rs .findPullRequests (ctx , githubClient , repo , userID )
62+ prs , err := rs .findPullRequests (ctx , gitClient , repo , userID )
6363 if err != nil {
6464 return nil , err
6565 }
@@ -97,7 +97,7 @@ func (rs *ReviewsService) GetRepository(tx *gorm.DB, repoID uint) (*responses.Ge
9797 return response , nil
9898}
9999
100- func (rs * ReviewsService ) RefreshPullRequests (ctx context.Context , tx * gorm.DB , githubClient utils. GithubClient , userID , repoID uint ) error {
100+ func (rs * ReviewsService ) RefreshPullRequests (ctx context.Context , tx * gorm.DB , gitClient git. GitClient , userID , repoID uint ) error {
101101 repository , err := rs .reviewsRepository .GetRepository (tx , repoID )
102102 if err != nil {
103103 return err
@@ -108,7 +108,7 @@ func (rs *ReviewsService) RefreshPullRequests(ctx context.Context, tx *gorm.DB,
108108 return err
109109 }
110110
111- currentOpenPRs , err := githubClient .ListPullRequests (ctx , repository .Name , repository .Owner , userID )
111+ currentOpenPRs , err := gitClient .ListPullRequests (ctx , repository .Name , repository .Owner , userID )
112112 if err != nil {
113113 return err
114114 }
@@ -166,8 +166,8 @@ func (rs *ReviewsService) RefreshPullRequests(ctx context.Context, tx *gorm.DB,
166166 return nil
167167}
168168
169- func (rs * ReviewsService ) findPullRequests (ctx context.Context , githubClient utils. GithubClient , repo * models.Repository , userID uint ) ([]* models.PullRequest , error ) {
170- fetched_prs , err := githubClient .ListPullRequests (ctx , repo .Name , repo .Owner , userID )
169+ func (rs * ReviewsService ) findPullRequests (ctx context.Context , gitClient git. GitClient , repo * models.Repository , userID uint ) ([]* models.PullRequest , error ) {
170+ fetched_prs , err := gitClient .ListPullRequests (ctx , repo .Name , repo .Owner , userID )
171171 if err != nil {
172172 return nil , err
173173 }
@@ -319,7 +319,7 @@ func (rs *ReviewsService) GetFileReviews(tx *gorm.DB, reviewID uint) (*responses
319319 return response , nil
320320}
321321
322- func (rs * ReviewsService ) CreateReview (tx * gorm.DB , ctx context.Context , queue mq.MessageQueue , githubClient utils. GithubClient , repoID , prID uint , name string , userID uint ) (* responses.GetReviewsResponse , error ) {
322+ func (rs * ReviewsService ) CreateReview (tx * gorm.DB , ctx context.Context , queue mq.MessageQueue , gitClient git. GitClient , repoID , prID uint , name string , userID uint ) (* responses.GetReviewsResponse , error ) {
323323 repo , err := rs .reviewsRepository .GetRepository (tx , repoID )
324324 if err != nil {
325325 return nil , err
@@ -350,7 +350,7 @@ func (rs *ReviewsService) CreateReview(tx *gorm.DB, ctx context.Context, queue m
350350 // fetch file diffs for the PR from github using github client
351351 // send info over RabbitMQ to call external review service api to retrieve file reviews
352352 go func () {
353- fileDiffs , err := githubClient .FetchFileDiffs (ctx , repo .Name , repo .Owner , pr .Number , userID )
353+ fileDiffs , err := gitClient .FetchFileDiffs (ctx , repo .Name , repo .Owner , pr .Number , userID )
354354 if err != nil {
355355 log .Println ("Error fetching file diffs:" , err )
356356 return
0 commit comments