feat: auto detect hostname
This commit is contained in:
parent
2c27823e18
commit
c0baf4fa3b
13 changed files with 300 additions and 125 deletions
27
cmd/pr.go
27
cmd/pr.go
|
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
"codeberg.org/romaintb/fgj/internal/api"
|
||||
"codeberg.org/romaintb/fgj/internal/config"
|
||||
"codeberg.org/romaintb/fgj/internal/git"
|
||||
)
|
||||
|
||||
var prCmd = &cobra.Command{
|
||||
|
|
@ -88,7 +87,7 @@ func runPRList(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client, err := api.NewClientFromConfig(cfg, "")
|
||||
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -144,7 +143,7 @@ func runPRView(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client, err := api.NewClientFromConfig(cfg, "")
|
||||
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -198,7 +197,7 @@ func runPRCreate(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client, err := api.NewClientFromConfig(cfg, "")
|
||||
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -252,7 +251,7 @@ func runPRMerge(cmd *cobra.Command, args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
client, err := api.NewClientFromConfig(cfg, "")
|
||||
client, err := api.NewClientFromConfig(cfg, "", getDetectedHost())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -281,21 +280,3 @@ func runPRMerge(cmd *cobra.Command, args []string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func parseRepo(repo string) (string, string, error) {
|
||||
// If repo flag is provided, use it
|
||||
if repo != "" {
|
||||
parts := strings.Split(repo, "/")
|
||||
if len(parts) != 2 {
|
||||
return "", "", fmt.Errorf("invalid repository format: %s (expected: owner/name)", repo)
|
||||
}
|
||||
return parts[0], parts[1], nil
|
||||
}
|
||||
|
||||
// Try to auto-detect from git
|
||||
owner, name, err := git.DetectRepo()
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("repository flag is required (use -R owner/name) or run from a git repository: %w", err)
|
||||
}
|
||||
|
||||
return owner, name, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue