If a meta file heater was present but no sha, a panic would occur. Return an error instead.
This commit is contained in:
parent
f1276a1d04
commit
d1f05fb202
@ -32,6 +32,10 @@ func Decode(reader io.Reader) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(lines) < 2 {
|
||||
return "", errors.New("No sha in meta file")
|
||||
}
|
||||
|
||||
if matched {
|
||||
return string(lines[1]), nil
|
||||
}
|
||||
|
@ -51,3 +51,10 @@ func TestDecodeInvalid(t *testing.T) {
|
||||
t.Errorf("Decoded invalid sha")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeWithValidHeaderNoSha(t *testing.T) {
|
||||
buf := bytes.NewBufferString("# git-media")
|
||||
if _, err := Decode(buf); err == nil {
|
||||
t.Errorf("Decoded with header but no sha")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user