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

clean up URL parsing logic

Changeset 0395beaa5088

Parent bd8f5ebeb023

by Benjamin Pollack

Changes to one file · Browse files at 0395beaa5088 Showing diff from parent bd8f5ebeb023 Diff from another changeset...

Change 1 of 1 Show Entire File main.go Stacked
 
63
64
65
66
67
68
69
70
71
72
73
74
75
 
 
 
 
 
 
 
 
 
76
77
78
 
63
64
65
 
 
 
 
 
 
 
 
 
 
66
67
68
69
70
71
72
73
74
75
76
77
@@ -63,16 +63,15 @@
 const kilnUrlSuffix = "kiln/"    func extractUrlsAndPaths(s string) (base *url.URL, path string, err error) { - base, err = url.Parse(s) - if err != nil || (base.Scheme != "http" && base.Scheme != "https") { - out, err := exec.Command("git", "config", "kiln.url").Output() - if err == nil { - base, err = url.Parse(strings.TrimSpace(string(out))) - } - } - 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 + out, err := exec.Command("git", "config", "kiln.url").Output() + if err == nil && len(out) > 0 { + base, err = url.Parse(strings.TrimSpace(string(out))) + } 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 + }   }     components := strings.Split(base.Path, "/")