fix: remove cabal.project.freeze panic on last pkg (#1363)

This commit is contained in:
Christopher Angelo Phillips 2022-11-23 17:33:18 -05:00 committed by GitHub
parent bcfe38c009
commit b290a445ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -34,6 +34,14 @@ func parseCabalFreeze(_ source.FileResolver, _ *generic.Environment, reader sour
line = strings.TrimSpace(line) line = strings.TrimSpace(line)
startPkgEncoding, endPkgEncoding := strings.Index(line, "any.")+4, strings.Index(line, ",") startPkgEncoding, endPkgEncoding := strings.Index(line, "any.")+4, strings.Index(line, ",")
// case where comma not found for last package in constraint list
if endPkgEncoding == -1 {
endPkgEncoding = len(line)
}
if startPkgEncoding >= endPkgEncoding || startPkgEncoding < 0 {
continue
}
line = line[startPkgEncoding:endPkgEncoding] line = line[startPkgEncoding:endPkgEncoding]
fields := strings.Split(line, " ==") fields := strings.Split(line, " ==")

View File

@ -12,6 +12,6 @@ constraints: any.Cabal ==3.2.1.0,
any.RSA ==2.4.1, any.RSA ==2.4.1,
any.SHA ==1.6.4.4, any.SHA ==1.6.4.4,
void -safe, void -safe,
any.Spock ==0.14.0.0, any.Spock ==0.14.0.0
index-state: hackage.haskell.org 2022-07-07T01:01:53Z index-state: hackage.haskell.org 2022-07-07T01:01:53Z