File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ func (issue *Issue) isTimetrackerEnabled(ctx context.Context) bool {
141141 log .Error (fmt .Sprintf ("loadRepo: %v" , err ))
142142 return false
143143 }
144- return issue .Repo .IsTimetrackerEnabled ( )
144+ return issue .Repo .IsTimetrackerEnabledCtx ( ctx )
145145}
146146
147147// GetPullRequest returns the issue pull request
Original file line number Diff line number Diff line change @@ -28,13 +28,18 @@ func (repo *Repository) CanEnableTimetracker() bool {
2828
2929// IsTimetrackerEnabled returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.
3030func (repo * Repository ) IsTimetrackerEnabled () bool {
31+ return repo .IsTimetrackerEnabledCtx (db .DefaultContext )
32+ }
33+
34+ // IsTimetrackerEnabledCtx returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.
35+ func (repo * Repository ) IsTimetrackerEnabledCtx (ctx context.Context ) bool {
3136 if ! setting .Service .EnableTimetracking {
3237 return false
3338 }
3439
3540 var u * RepoUnit
3641 var err error
37- if u , err = repo .GetUnit ( unit .TypeIssues ); err != nil {
42+ if u , err = repo .GetUnitCtx ( ctx , unit .TypeIssues ); err != nil {
3843 return setting .Service .DefaultEnableTimetracking
3944 }
4045 return u .IssuesConfig ().EnableTimetracker
@@ -59,7 +64,7 @@ func (repo *Repository) IsDependenciesEnabled() bool {
5964func (repo * Repository ) IsDependenciesEnabledCtx (ctx context.Context ) bool {
6065 var u * RepoUnit
6166 var err error
62- if u , err = repo .getUnit (ctx , unit .TypeIssues ); err != nil {
67+ if u , err = repo .GetUnitCtx (ctx , unit .TypeIssues ); err != nil {
6368 log .Trace ("%s" , err )
6469 return setting .Service .DefaultEnableDependencies
6570 }
Original file line number Diff line number Diff line change @@ -312,10 +312,11 @@ func (repo *Repository) MustGetUnit(tp unit.Type) *RepoUnit {
312312
313313// GetUnit returns a RepoUnit object
314314func (repo * Repository ) GetUnit (tp unit.Type ) (* RepoUnit , error ) {
315- return repo .getUnit (db .DefaultContext , tp )
315+ return repo .GetUnitCtx (db .DefaultContext , tp )
316316}
317317
318- func (repo * Repository ) getUnit (ctx context.Context , tp unit.Type ) (* RepoUnit , error ) {
318+ // GetUnitCtx returns a RepoUnit object
319+ func (repo * Repository ) GetUnitCtx (ctx context.Context , tp unit.Type ) (* RepoUnit , error ) {
319320 if err := repo .LoadUnits (ctx ); err != nil {
320321 return nil , err
321322 }
You can’t perform that action at this time.
0 commit comments