mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
refactor: load settings once per run and reuse shared helpers
The application caches the settings snapshot and reloads it only after an update through the store, so output and prompt helpers no longer read and parse config.yml and hosts.yml several times per command. canPrompt and chooser replace the inline prompt-policy checks. Checks are tallied by one services.Tally, terminal.Plural replaces the two app copies, refKind.article/noun replace the comment group's own words, list commands use servicePage, and web URLs are built by repositoryURL and webURL in browser.go. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
42 files changed
+157
-204
No files matched your search
@@ -104,7 +104,7 @@ $ tea branch list -R alice/project --limit 100 --json name,sha`,
|
||||
},
|
||||
Context: "branches in " + target.Repo, Empty: "no branches in " + target.Repo,
|
||||
}
|
||||
return writeTable(a, cmd, result.Items, spec, listPage{Number: page, More: result.More, Total: result.Total, Counted: result.Counted})
|
||||
return writeTable(a, cmd, result.Items, spec, servicePage(result, page))
|
||||
},
|
||||
}
|
||||
pageFlags(command, &limit, &page)
|
||||
@@ -145,7 +145,7 @@ func (a *application) branchViewCommand() *cobra.Command {
|
||||
protection := ""
|
||||
if item.Protected {
|
||||
badges = append(badges, terminal.Cell{Text: "protected", Color: "yellow"})
|
||||
protection = countNoun(int(item.RequiredApprovals), "required approval")
|
||||
protection = terminal.Plural(int(item.RequiredApprovals), "required approval")
|
||||
}
|
||||
meta := ""
|
||||
if updated := terminal.ParseTime(item.UpdatedAt); !updated.IsZero() {
|
||||
@@ -358,7 +358,7 @@ $ tea branch protect --pattern 'release/*' --allow-push acme/release`,
|
||||
|
||||
// protectionSummary describes a protection rule, as in "1 approval required, no direct pushes".
|
||||
func protectionSummary(rule services.Protection) string {
|
||||
parts := []string{countNoun(int(rule.RequiredApprovals), "approval") + " required"}
|
||||
parts := []string{terminal.Plural(int(rule.RequiredApprovals), "approval") + " required"}
|
||||
if pushers := len(rule.PushUsers) + len(rule.PushTeams); pushers > 0 {
|
||||
parts = append(parts, "pushes by "+strings.Join(append(append([]string{}, rule.PushUsers...), rule.PushTeams...), ", "))
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user