diff --git a/bzr.go b/bzr.go index 5c9f1ce..2b0130c 100644 --- a/bzr.go +++ b/bzr.go @@ -54,7 +54,7 @@ func NewBzrRepo(remote, local string) (*BzrRepo, error) { // If no remote was passed in but one is configured for the locally // checked out Bzr repo use that one. - if m[1] != "" { + if m != nil && m[1] != "" { r.setRemote(m[1]) } } diff --git a/hg.go b/hg.go index 75a26f5..0e28ec7 100644 --- a/hg.go +++ b/hg.go @@ -46,14 +46,16 @@ func NewHgRepo(remote, local string) (*HgRepo, error) { } m := hgDetectURL.FindStringSubmatch(string(out)) - if remote != "" && m[1] != remote { - return nil, ErrWrongRemote - } - - // If no remote was passed in but one is configured for the locally - // checked out Hg repo use that one. - if remote == "" && m[1] != "" { - r.setRemote(m[1]) + if m != nil { + if remote != "" && m[1] != remote { + return nil, ErrWrongRemote + } + + // If no remote was passed in but one is configured for the locally + // checked out Hg repo use that one. + if remote == "" && m[1] != "" { + r.setRemote(m[1]) + } } }