@@ -60,7 +60,6 @@ func (f *GogsDownloaderFactory) GitServiceType() structs.GitServiceType {
6060// from gogs via API
6161type GogsDownloader struct {
6262 base.NullDownloader
63- ctx context.Context
6463 client * gogs.Client
6564 baseURL string
6665 repoOwner string
@@ -85,9 +84,8 @@ func (g *GogsDownloader) LogString() string {
8584}
8685
8786// NewGogsDownloader creates a gogs Downloader via gogs API
88- func NewGogsDownloader (ctx context.Context , baseURL , userName , password , token , repoOwner , repoName string ) * GogsDownloader {
87+ func NewGogsDownloader (_ context.Context , baseURL , userName , password , token , repoOwner , repoName string ) * GogsDownloader {
8988 downloader := GogsDownloader {
90- ctx : ctx ,
9189 baseURL : baseURL ,
9290 userName : userName ,
9391 password : password ,
@@ -108,24 +106,15 @@ func NewGogsDownloader(ctx context.Context, baseURL, userName, password, token,
108106 downloader .transport = transport
109107
110108 client = gogs .NewClient (baseURL , "" )
111- client .SetHTTPClient (& http.Client {
112- Transport : & downloader ,
113- })
114109 }
115110
116111 downloader .client = client
117112 return & downloader
118113}
119114
120- // RoundTrip wraps the provided request within this downloader's context and passes it to our internal http.Transport.
121- // This implements http.RoundTripper and makes the gogs client requests cancellable even though it is not cancellable itself
122- func (g * GogsDownloader ) RoundTrip (req * http.Request ) (* http.Response , error ) {
123- return g .transport .RoundTrip (req .WithContext (g .ctx ))
124- }
125-
126115// GetRepoInfo returns a repository information
127- func (g * GogsDownloader ) GetRepoInfo (_ context.Context ) (* base.Repository , error ) {
128- gr , err := g .client .GetRepo (g .repoOwner , g .repoName )
116+ func (g * GogsDownloader ) GetRepoInfo (ctx context.Context ) (* base.Repository , error ) {
117+ gr , err := g .client .GetRepo (ctx , g .repoOwner , g .repoName )
129118 if err != nil {
130119 return nil , err
131120 }
@@ -143,11 +132,11 @@ func (g *GogsDownloader) GetRepoInfo(_ context.Context) (*base.Repository, error
143132}
144133
145134// GetMilestones returns milestones
146- func (g * GogsDownloader ) GetMilestones (_ context.Context ) ([]* base.Milestone , error ) {
135+ func (g * GogsDownloader ) GetMilestones (ctx context.Context ) ([]* base.Milestone , error ) {
147136 perPage := 100
148137 milestones := make ([]* base.Milestone , 0 , perPage )
149138
150- ms , err := g .client .ListRepoMilestones (g .repoOwner , g .repoName )
139+ ms , err := g .client .ListRepoMilestones (ctx , g .repoOwner , g .repoName )
151140 if err != nil {
152141 return nil , err
153142 }
@@ -166,10 +155,10 @@ func (g *GogsDownloader) GetMilestones(_ context.Context) ([]*base.Milestone, er
166155}
167156
168157// GetLabels returns labels
169- func (g * GogsDownloader ) GetLabels (_ context.Context ) ([]* base.Label , error ) {
158+ func (g * GogsDownloader ) GetLabels (ctx context.Context ) ([]* base.Label , error ) {
170159 perPage := 100
171160 labels := make ([]* base.Label , 0 , perPage )
172- ls , err := g .client .ListRepoLabels (g .repoOwner , g .repoName )
161+ ls , err := g .client .ListRepoLabels (ctx , g .repoOwner , g .repoName )
173162 if err != nil {
174163 return nil , err
175164 }
@@ -182,7 +171,7 @@ func (g *GogsDownloader) GetLabels(_ context.Context) ([]*base.Label, error) {
182171}
183172
184173// GetIssues returns issues according start and limit, perPage is not supported
185- func (g * GogsDownloader ) GetIssues (_ context.Context , page , _ int ) ([]* base.Issue , bool , error ) {
174+ func (g * GogsDownloader ) GetIssues (ctx context.Context , page , _ int ) ([]* base.Issue , bool , error ) {
186175 var state string
187176 if g .openIssuesFinished {
188177 state = string (gogs .STATE_CLOSED )
@@ -192,7 +181,7 @@ func (g *GogsDownloader) GetIssues(_ context.Context, page, _ int) ([]*base.Issu
192181 g .openIssuesPages = page
193182 }
194183
195- issues , isEnd , err := g .getIssues (page , state )
184+ issues , isEnd , err := g .getIssues (ctx , page , state )
196185 if err != nil {
197186 return nil , false , err
198187 }
@@ -207,10 +196,10 @@ func (g *GogsDownloader) GetIssues(_ context.Context, page, _ int) ([]*base.Issu
207196 return issues , false , nil
208197}
209198
210- func (g * GogsDownloader ) getIssues (page int , state string ) ([]* base.Issue , bool , error ) {
199+ func (g * GogsDownloader ) getIssues (ctx context. Context , page int , state string ) ([]* base.Issue , bool , error ) {
211200 allIssues := make ([]* base.Issue , 0 , 10 )
212201
213- issues , err := g .client .ListRepoIssues (g .repoOwner , g .repoName , gogs.ListIssueOption {
202+ issues , err := g .client .ListRepoIssues (ctx , g .repoOwner , g .repoName , gogs.ListIssueOption {
214203 Page : page ,
215204 State : state ,
216205 })
@@ -229,10 +218,10 @@ func (g *GogsDownloader) getIssues(page int, state string) ([]*base.Issue, bool,
229218}
230219
231220// GetComments returns comments according issueNumber
232- func (g * GogsDownloader ) GetComments (_ context.Context , commentable base.Commentable ) ([]* base.Comment , bool , error ) {
221+ func (g * GogsDownloader ) GetComments (ctx context.Context , commentable base.Commentable ) ([]* base.Comment , bool , error ) {
233222 allComments := make ([]* base.Comment , 0 , 100 )
234223
235- comments , err := g .client .ListIssueComments (g .repoOwner , g .repoName , commentable .GetForeignIndex ())
224+ comments , err := g .client .ListIssueComments (ctx , g .repoOwner , g .repoName , commentable .GetForeignIndex ())
236225 if err != nil {
237226 return nil , false , fmt .Errorf ("error while listing repos: %w" , err )
238227 }
0 commit comments