Fix TestRoutingIntegration and improve DetectUserRole robustness
Amp-Thread-ID: https://ampcode.com/threads/T-fc47ce9d-88a4-4bcd-b9cb-79327d98dee7 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -14,6 +14,10 @@ import (
|
||||
)
|
||||
|
||||
func TestRoutingIntegration(t *testing.T) {
|
||||
// Isolate from user's git config (e.g. url.insteadOf) to ensure deterministic URLs
|
||||
t.Setenv("GIT_CONFIG_GLOBAL", "/dev/null")
|
||||
t.Setenv("GIT_CONFIG_SYSTEM", "/dev/null")
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
setupGit func(t *testing.T, dir string)
|
||||
|
||||
@@ -44,8 +44,16 @@ func DetectUserRole(repoPath string) (UserRole, error) {
|
||||
}
|
||||
output, err = cmd.Output()
|
||||
if err != nil {
|
||||
// No remote or error - default to contributor
|
||||
return Contributor, nil
|
||||
// Fallback to standard fetch URL if push URL fails (some git versions/configs)
|
||||
cmd = exec.Command("git", "remote", "get-url", "origin")
|
||||
if repoPath != "" {
|
||||
cmd.Dir = repoPath
|
||||
}
|
||||
output, err = cmd.Output()
|
||||
if err != nil {
|
||||
// No remote or error - default to contributor
|
||||
return Contributor, nil
|
||||
}
|
||||
}
|
||||
|
||||
pushURL := strings.TrimSpace(string(output))
|
||||
|
||||
Reference in New Issue
Block a user