feat: add directory-scoped host defaults (match_dirs) and repo list --limit
Some checks are pending
CI / lint (push) Waiting to run
CI / build (push) Waiting to run
CI / test (push) Waiting to run
CI / functional (push) Blocked by required conditions

Add match_dirs field to host config entries for directory-based host
resolution. When no --hostname flag, FGJ_HOST env var, or git remote is
detected, the longest matching directory prefix determines the host.
Symlinks are resolved on both sides for macOS compatibility (/tmp →
/private/tmp). Also adds --limit/-L flag to repo list.
This commit is contained in:
sid 2026-03-23 12:39:51 -06:00
parent 113505de95
commit c293e233d2
17 changed files with 252 additions and 79 deletions

View file

@ -125,6 +125,7 @@ func init() {
repoViewCmd.Flags().BoolP("web", "w", false, "Open in web browser")
addJSONFlags(repoListCmd, "Output repositories as JSON")
repoListCmd.Flags().IntP("limit", "L", 0, "Maximum number of repositories to list (0 = no limit)")
repoCloneCmd.Flags().StringP("protocol", "p", "https", "Clone protocol: https or ssh")
@ -158,7 +159,7 @@ func runRepoView(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}
@ -203,7 +204,7 @@ func runRepoList(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}
@ -221,6 +222,11 @@ func runRepoList(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to list repositories: %w", err)
}
limit, _ := cmd.Flags().GetInt("limit")
if limit > 0 && len(repos) > limit {
repos = repos[:limit]
}
if wantJSON(cmd) {
return outputJSON(cmd, repos)
}
@ -257,7 +263,7 @@ func runRepoClone(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}
@ -324,7 +330,7 @@ func runRepoFork(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}
@ -371,7 +377,7 @@ func runRepoCreate(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}
@ -439,7 +445,7 @@ func runRepoCreate(cmd *cobra.Command, args []string) error {
if doClone {
cloneURL := repo.CloneURL
if hostCfg, hostErr := cfg.GetHost("", getDetectedHost()); hostErr == nil {
if hostCfg, hostErr := cfg.GetHost("", getDetectedHost(), getCwd()); hostErr == nil {
if hostCfg.GitProtocol == "ssh" {
cloneURL = repo.SSHURL
}
@ -494,7 +500,7 @@ func runRepoEdit(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}
@ -591,7 +597,7 @@ func runRepoRename(cmd *cobra.Command, args []string) error {
return err
}
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost(), getCwd())
if err != nil {
return err
}