Skip to content

Commit

Permalink
Merge branch 'main' into fix-17942
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Dec 14, 2021
2 parents 1d99d85 + bd475f5 commit 75144ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (issue *Issue) isTimetrackerEnabled(ctx context.Context) bool {
log.Error(fmt.Sprintf("loadRepo: %v", err))
return false
}
return issue.Repo.IsTimetrackerEnabled()
return issue.Repo.IsTimetrackerEnabledCtx(ctx)
}

// GetPullRequest returns the issue pull request
Expand Down
9 changes: 7 additions & 2 deletions models/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ func (repo *Repository) CanEnableTimetracker() bool {

// IsTimetrackerEnabled returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.
func (repo *Repository) IsTimetrackerEnabled() bool {
return repo.IsTimetrackerEnabledCtx(db.DefaultContext)
}

// IsTimetrackerEnabledCtx returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.
func (repo *Repository) IsTimetrackerEnabledCtx(ctx context.Context) bool {
if !setting.Service.EnableTimetracking {
return false
}

var u *RepoUnit
var err error
if u, err = repo.GetUnit(unit.TypeIssues); err != nil {
if u, err = repo.GetUnitCtx(ctx, unit.TypeIssues); err != nil {
return setting.Service.DefaultEnableTimetracking
}
return u.IssuesConfig().EnableTimetracker
Expand All @@ -59,7 +64,7 @@ func (repo *Repository) IsDependenciesEnabled() bool {
func (repo *Repository) IsDependenciesEnabledCtx(ctx context.Context) bool {
var u *RepoUnit
var err error
if u, err = repo.getUnit(ctx, unit.TypeIssues); err != nil {
if u, err = repo.GetUnitCtx(ctx, unit.TypeIssues); err != nil {
log.Trace("%s", err)
return setting.Service.DefaultEnableDependencies
}
Expand Down
5 changes: 3 additions & 2 deletions models/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,11 @@ func (repo *Repository) MustGetUnit(tp unit.Type) *RepoUnit {

// GetUnit returns a RepoUnit object
func (repo *Repository) GetUnit(tp unit.Type) (*RepoUnit, error) {
return repo.getUnit(db.DefaultContext, tp)
return repo.GetUnitCtx(db.DefaultContext, tp)
}

func (repo *Repository) getUnit(ctx context.Context, tp unit.Type) (*RepoUnit, error) {
// GetUnitCtx returns a RepoUnit object
func (repo *Repository) GetUnitCtx(ctx context.Context, tp unit.Type) (*RepoUnit, error) {
if err := repo.LoadUnits(ctx); err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ license_desc=Go get <a target="_blank" rel="noopener noreferrer" href="https://c
install=インストール
title=初期設定
docker_helper=GiteaをDocker内で実行する場合は、設定を変更する前に<a target="_blank" rel="noopener noreferrer" href="%s">ドキュメント</a>を読んでください。
require_db_desc=Giteaには、MySQL、PostgreSQL、MSSQL、SQLite3、またはTiDB(MySQL プロトコル) が必要です。
db_title=データベース設定
db_type=データベースのタイプ
host=ホスト
Expand Down

0 comments on commit 75144ee

Please sign in to comment.