feat: logins list/default, actions run delete, date filters, label update alias
- fgj logins {list,default}: complementary UI to 'fgj auth'. 'list'
shows all configured hosts (hostname, user, protocol, default flag,
match_dirs) with --json. 'default [hostname]' gets or sets which
host wins in resolution when no other signal is present.
Adds 'Default bool' field to HostConfig; GetHost consults it between
match_dirs and the codeberg.org fallback. Multiple defaults tolerated
with a stderr warning; alphabetical-first wins.
- fgj actions run delete: delete a completed workflow run via raw
DELETE (SDK v0.23.2 has no DeleteRepoActionRun). Fetches run first
and refuses to delete non-terminal states unless --force; suggests
'actions run cancel' for those. Confirmation prompt unless --yes.
- pr list / issue list gain --since and --before date filter flags.
Accepts YYYY-MM-DD, RFC 3339, YYYY-MM-DD HH:MM:SS, and relative
deltas (7d, 24h, 2w, 1m — months=30 days). Issues use server-side
filter via ListIssueOption.Since/Before; PRs fall back to client-side
(SDK lacks Since/Before on ListPullRequestsOptions).
- fgj label update added as alias for 'fgj label edit' (tea-compat).
All changes:
cmd/logins.go (new, 140 LOC)
cmd/actions_run_delete.go (new, ~85 LOC)
cmd/pr.go, cmd/issue.go (+parseDateArg helper, filter wiring)
cmd/label.go (1-line alias)
internal/config/config.go (Default field + DefaultHost method)
CHANGELOG.md
Built in parallel by three sub-agents; plus the label alias done
serially. go build / go vet / go test -race all clean.
This commit is contained in:
parent
d15deaf064
commit
2d69873f3e
7 changed files with 462 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
|
@ -20,6 +21,7 @@ type HostConfig struct {
|
|||
User string `yaml:"user,omitempty"`
|
||||
GitProtocol string `yaml:"git_protocol,omitempty"`
|
||||
MatchDirs []string `yaml:"match_dirs,omitempty"`
|
||||
Default bool `yaml:"default,omitempty"`
|
||||
Order int `yaml:"-"` // config file order, set at load time
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +136,8 @@ func (c *Config) SaveToPath(path string) error {
|
|||
// 3. Environment variable (FGJ_HOST)
|
||||
// 4. Auto-detected hostname from git remote
|
||||
// 5. match_dirs lookup (longest prefix match)
|
||||
// 6. Default to codeberg.org
|
||||
// 6. Configured default host (HostConfig.Default == true)
|
||||
// 7. Default to codeberg.org
|
||||
func (c *Config) GetHost(hostname string, detectedHost string, cwd string) (HostConfig, error) {
|
||||
if hostname == "" {
|
||||
hostname = viper.GetString("hostname")
|
||||
|
|
@ -152,6 +155,10 @@ func (c *Config) GetHost(hostname string, detectedHost string, cwd string) (Host
|
|||
hostname = c.ResolveHostByPath(cwd)
|
||||
}
|
||||
|
||||
if hostname == "" {
|
||||
hostname = c.DefaultHost()
|
||||
}
|
||||
|
||||
if hostname == "" {
|
||||
hostname = "codeberg.org"
|
||||
}
|
||||
|
|
@ -164,6 +171,27 @@ func (c *Config) GetHost(hostname string, detectedHost string, cwd string) (Host
|
|||
return host, nil
|
||||
}
|
||||
|
||||
// DefaultHost returns the hostname of the host marked Default == true.
|
||||
// If no host is marked default, returns "". If multiple hosts are marked
|
||||
// default (a user-error case), the one that sorts first alphabetically is
|
||||
// returned and a warning is printed to stderr.
|
||||
func (c *Config) DefaultHost() string {
|
||||
var matches []string
|
||||
for hostname, host := range c.Hosts {
|
||||
if host.Default {
|
||||
matches = append(matches, hostname)
|
||||
}
|
||||
}
|
||||
if len(matches) == 0 {
|
||||
return ""
|
||||
}
|
||||
sort.Strings(matches)
|
||||
if len(matches) > 1 {
|
||||
fmt.Fprintf(os.Stderr, "warning: multiple hosts marked default (%s); using %s\n", strings.Join(matches, ", "), matches[0])
|
||||
}
|
||||
return matches[0]
|
||||
}
|
||||
|
||||
// ResolveHostByPath finds the host whose match_dirs entry is the longest
|
||||
// prefix of cwd. Returns "" if no match is found.
|
||||
// Both cwd and match_dirs entries are resolved through filepath.EvalSymlinks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue