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:
File diff suppressed because one or more lines are too long
543
.beads/issues.jsonl
Normal file
543
.beads/issues.jsonl
Normal file
File diff suppressed because one or more lines are too long
@@ -14,6 +14,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRoutingIntegration(t *testing.T) {
|
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 {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
setupGit func(t *testing.T, dir string)
|
setupGit func(t *testing.T, dir string)
|
||||||
|
|||||||
@@ -43,10 +43,18 @@ func DetectUserRole(repoPath string) (UserRole, error) {
|
|||||||
cmd.Dir = repoPath
|
cmd.Dir = repoPath
|
||||||
}
|
}
|
||||||
output, err = cmd.Output()
|
output, err = cmd.Output()
|
||||||
|
if err != 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 {
|
if err != nil {
|
||||||
// No remote or error - default to contributor
|
// No remote or error - default to contributor
|
||||||
return Contributor, nil
|
return Contributor, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pushURL := strings.TrimSpace(string(output))
|
pushURL := strings.TrimSpace(string(output))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user