Skip to content

Commit c5c118a

Browse files
committed
Fixing some possible panics
Signed-off-by: Matt Farina <matt.farina@suse.com>
1 parent 30b4d39 commit c5c118a

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

bzr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewBzrRepo(remote, local string) (*BzrRepo, error) {
5454

5555
// If no remote was passed in but one is configured for the locally
5656
// checked out Bzr repo use that one.
57-
if m[1] != "" {
57+
if m != nil && m[1] != "" {
5858
r.setRemote(m[1])
5959
}
6060
}

hg.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ func NewHgRepo(remote, local string) (*HgRepo, error) {
4646
}
4747

4848
m := hgDetectURL.FindStringSubmatch(string(out))
49-
if remote != "" && m[1] != remote {
50-
return nil, ErrWrongRemote
51-
}
52-
53-
// If no remote was passed in but one is configured for the locally
54-
// checked out Hg repo use that one.
55-
if remote == "" && m[1] != "" {
56-
r.setRemote(m[1])
49+
if m != nil {
50+
if remote != "" && m[1] != remote {
51+
return nil, ErrWrongRemote
52+
}
53+
54+
// If no remote was passed in but one is configured for the locally
55+
// checked out Hg repo use that one.
56+
if remote == "" && m[1] != "" {
57+
r.setRemote(m[1])
58+
}
5759
}
5860
}
5961

0 commit comments

Comments
 (0)