Kiln » gitkiln Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master

fix URL extraction

Changeset 711cfb4a6886

Parent ad6ac7646c4c

by Benjamin Pollack

Changes to one file · Browse files at 711cfb4a6886 Showing diff from parent ad6ac7646c4c Diff from another changeset...

Change 1 of 1 Show Entire File main.go Stacked
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
 
 
 
 
82
83
84
85
86
87
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
90
91
 
66
67
68
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70
71
72
73
74
 
 
 
 
 
 
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
@@ -66,26 +66,36 @@
  out, err := exec.Command("git", "config", "kiln.url").Output()   if err == nil && len(out) > 0 {   base, err = url.Parse(strings.TrimSpace(string(out))) - } else { - if strings.HasPrefix(s, "ssh://") { - components := strings.SplitN(strings.TrimPrefix(s, "ssh://"), "/", 2) - fullDomain := strings.Split(components[0], "@") - domain := fullDomain[len(fullDomain)-1] - rest := "" - if len(components) > 1 { - rest = components[1] - } - if strings.HasSuffix(domain, ".kilnhg.com") { - s = "https://" + domain + "/Code/" + rest + ".git" - } - } + if err != nil { + err = fmt.Errorf("unable to parse kiln.url \"%s\"", string(out)) + return + } + } else {   base, err = url.Parse(s) - if err != nil || (base.Scheme != "http" && base.Scheme != "https") { - err = fmt.Errorf("must either have an HTTP remote or kiln.url specified in config") - return - } - } - + if err != nil { + err = fmt.Errorf("unable to parse remote URL \"%s\"", s) + return + } + if base.Scheme != "http" && base.Scheme != "https" && base.Scheme != "ssh" { + err = fmt.Errorf("unsupport Kiln URL scheme: \"%s\"", s) + return + } + if base.Scheme == "ssh" { + if strings.HasPrefix(base.Host, "our.fogbugz.com") { + base.Host = "our.fogbugz.com" + base.Path = "/kiln/Code" + base.Path + ".git" + base.Scheme = "http" + } else if !strings.HasSuffix(base.Host, ".kilnhg.com") { + err = fmt.Errorf("cannot infer HTTP path to Kiln repository; please specify using kiln.url") + return + } else { + base.Scheme = "https" + base.Path = "/Code" + base.Path + ".git" + } + } + } + + base.User = nil   components := strings.Split(base.Path, "/")   l := len(components)   components[l-1] = strings.TrimSuffix(components[l-1], ".git")