mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-21 21:04:07 +08:00
enhancement: show dependencies only with enabled setting
This commit is contained in:
parent
f2ae3bdc01
commit
0df1b3766a
models/repo
modules/structs
options/locale
routers
services
templates
|
@ -118,6 +118,7 @@ func (cfg *IssuesConfig) ToDB() ([]byte, error) {
|
|||
// PullRequestsConfig describes pull requests config
|
||||
type PullRequestsConfig struct {
|
||||
IgnoreWhitespaceConflicts bool
|
||||
ShowDependencies bool
|
||||
AllowMerge bool
|
||||
AllowRebase bool
|
||||
AllowRebaseMerge bool
|
||||
|
|
|
@ -95,6 +95,7 @@ type Repository struct {
|
|||
HasPackages bool `json:"has_packages"`
|
||||
HasActions bool `json:"has_actions"`
|
||||
IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"`
|
||||
ShowDependencies bool `json:"show_dependencies"`
|
||||
AllowMerge bool `json:"allow_merge_commits"`
|
||||
AllowRebase bool `json:"allow_rebase"`
|
||||
AllowRebaseMerge bool `json:"allow_rebase_explicit"`
|
||||
|
@ -191,6 +192,8 @@ type EditRepoOption struct {
|
|||
HasActions *bool `json:"has_actions,omitempty"`
|
||||
// either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace.
|
||||
IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"`
|
||||
// either `true` to show `depends on` and `blocks` in Pull Request list, or `false` to not show them.
|
||||
ShowDependencies *bool `json:"show_dependencies,omitempty"`
|
||||
// either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits.
|
||||
AllowMerge *bool `json:"allow_merge_commits,omitempty"`
|
||||
// either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging.
|
||||
|
|
|
@ -2121,6 +2121,7 @@ settings.enable_timetracker = Enable Time Tracking
|
|||
settings.allow_only_contributors_to_track_time = Let Only Contributors Track Time
|
||||
settings.pulls_desc = Enable Repository Pull Requests
|
||||
settings.pulls.ignore_whitespace = Ignore Whitespace for Conflicts
|
||||
settings.pulls.show_dependencies = Show <b>depends on</b> and <b>blocks</b> in Pull Requests list
|
||||
settings.pulls.enable_autodetect_manual_merge = Enable autodetect manual merge (Note: In some special cases, misjudgments can occur)
|
||||
settings.pulls.allow_rebase_update = Enable updating pull request branch by rebase
|
||||
settings.pulls.default_delete_branch_after_merge = Delete pull request branch after merge by default
|
||||
|
|
|
@ -881,6 +881,7 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||
// Unit type doesn't exist so we make a new config file with default values
|
||||
config = &repo_model.PullRequestsConfig{
|
||||
IgnoreWhitespaceConflicts: false,
|
||||
ShowDependencies: false,
|
||||
AllowMerge: true,
|
||||
AllowRebase: true,
|
||||
AllowRebaseMerge: true,
|
||||
|
@ -900,6 +901,9 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
|
|||
if opts.IgnoreWhitespaceConflicts != nil {
|
||||
config.IgnoreWhitespaceConflicts = *opts.IgnoreWhitespaceConflicts
|
||||
}
|
||||
if opts.ShowDependencies != nil {
|
||||
config.ShowDependencies = *opts.ShowDependencies
|
||||
}
|
||||
if opts.AllowMerge != nil {
|
||||
config.AllowMerge = *opts.AllowMerge
|
||||
}
|
||||
|
|
|
@ -344,6 +344,8 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
|||
return
|
||||
}
|
||||
|
||||
if unit, err := repo.GetUnit(ctx, unit.TypePullRequests); err == nil {
|
||||
if config := unit.PullRequestsConfig(); config.ShowDependencies {
|
||||
blockingDependenciesTemplates := make(map[int64]template.HTML, len(issues))
|
||||
blockedByDependenciesTemplates := make(map[int64]template.HTML, len(issues))
|
||||
|
||||
|
@ -365,6 +367,11 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
|||
blockedByDependenciesTemplates[i] = dependenciesToHTML(ctx, blockedByDependencies)
|
||||
}
|
||||
|
||||
ctx.Data["BlockingDependenciesTemplates"] = blockingDependenciesTemplates
|
||||
ctx.Data["BlockedByDependenciesTemplates"] = blockedByDependenciesTemplates
|
||||
}
|
||||
}
|
||||
|
||||
// Get posters.
|
||||
for i := range issues {
|
||||
// Check read status
|
||||
|
@ -375,8 +382,6 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
|||
return
|
||||
}
|
||||
}
|
||||
ctx.Data["BlockingDependenciesTemplates"] = blockingDependenciesTemplates
|
||||
ctx.Data["BlockedByDependenciesTemplates"] = blockedByDependenciesTemplates
|
||||
|
||||
commitStatuses, lastStatus, err := pull_service.GetIssuesAllCommitStatus(ctx, issues)
|
||||
if err != nil {
|
||||
|
|
|
@ -582,6 +582,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
Type: unit_model.TypePullRequests,
|
||||
Config: &repo_model.PullRequestsConfig{
|
||||
IgnoreWhitespaceConflicts: form.PullsIgnoreWhitespace,
|
||||
ShowDependencies: form.PullsShowDependencies,
|
||||
AllowMerge: form.PullsAllowMerge,
|
||||
AllowRebase: form.PullsAllowRebase,
|
||||
AllowRebaseMerge: form.PullsAllowRebaseMerge,
|
||||
|
|
|
@ -89,6 +89,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInR
|
|||
}
|
||||
hasPullRequests := false
|
||||
ignoreWhitespaceConflicts := false
|
||||
showDependencies := false
|
||||
allowMerge := false
|
||||
allowRebase := false
|
||||
allowRebaseMerge := false
|
||||
|
@ -102,6 +103,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInR
|
|||
config := unit.PullRequestsConfig()
|
||||
hasPullRequests = true
|
||||
ignoreWhitespaceConflicts = config.IgnoreWhitespaceConflicts
|
||||
showDependencies = config.ShowDependencies
|
||||
allowMerge = config.AllowMerge
|
||||
allowRebase = config.AllowRebase
|
||||
allowRebaseMerge = config.AllowRebaseMerge
|
||||
|
@ -221,6 +223,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInR
|
|||
ExternalWiki: externalWiki,
|
||||
HasPullRequests: hasPullRequests,
|
||||
IgnoreWhitespaceConflicts: ignoreWhitespaceConflicts,
|
||||
ShowDependencies: showDependencies,
|
||||
AllowMerge: allowMerge,
|
||||
AllowRebase: allowRebase,
|
||||
AllowRebaseMerge: allowRebaseMerge,
|
||||
|
|
|
@ -149,6 +149,7 @@ type RepoSettingForm struct {
|
|||
EnablePulls bool
|
||||
EnableActions bool
|
||||
PullsIgnoreWhitespace bool
|
||||
PullsShowDependencies bool
|
||||
PullsAllowMerge bool
|
||||
PullsAllowRebase bool
|
||||
PullsAllowRebaseMerge bool
|
||||
|
|
|
@ -645,6 +645,12 @@
|
|||
<label>{{ctx.Locale.Tr "repo.settings.pulls.ignore_whitespace"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input name="pulls_show_dependencies" type="checkbox" {{if and $pullRequestEnabled ($prUnit.PullRequestsConfig.ShowDependencies)}}checked{{end}}>
|
||||
<label>{{ctx.Locale.Tr "repo.settings.pulls.show_dependencies"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
|
|
|
@ -118,12 +118,16 @@
|
|||
</span>
|
||||
</span>
|
||||
{{end}}
|
||||
{{if $.BlockedByDependenciesTemplates}}
|
||||
{{template "shared/issue_dependency" (dict
|
||||
"Dependencies" (index $.BlockedByDependenciesTemplates .ID)
|
||||
"TitleKey" "repo.issues.dependency.blocked_by_following")}}
|
||||
{{end}}
|
||||
{{if $.BlockingDependenciesTemplates}}
|
||||
{{template "shared/issue_dependency" (dict
|
||||
"Dependencies" (index $.BlockingDependenciesTemplates .ID)
|
||||
"TitleKey" "repo.issues.dependency.blocks_following")}}
|
||||
{{end}}
|
||||
{{if .IsPull}}
|
||||
{{$approveOfficial := call $approvalCounts .ID "approve"}}
|
||||
{{$rejectOfficial := call $approvalCounts .ID "reject"}}
|
||||
|
|
9
templates/swagger/v1_json.tmpl
generated
9
templates/swagger/v1_json.tmpl
generated
|
@ -19834,6 +19834,11 @@
|
|||
"type": "boolean",
|
||||
"x-go-name": "IgnoreWhitespaceConflicts"
|
||||
},
|
||||
"show_dependencies": {
|
||||
"description": "either `true` to show `depends on` and `blocks` in Pull Request list, or `false` to not show them.",
|
||||
"type": "boolean",
|
||||
"x-go-name": "ShowDependencies"
|
||||
},
|
||||
"internal_tracker": {
|
||||
"$ref": "#/definitions/InternalTracker"
|
||||
},
|
||||
|
@ -22707,6 +22712,10 @@
|
|||
"type": "boolean",
|
||||
"x-go-name": "IgnoreWhitespaceConflicts"
|
||||
},
|
||||
"show_dependencies": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "ShowDependencies"
|
||||
},
|
||||
"internal": {
|
||||
"type": "boolean",
|
||||
"x-go-name": "Internal"
|
||||
|
|
Loading…
Reference in New Issue
Block a user