Skip to content

Commit

Permalink
[path] Do not error if current version is invalid
Browse files Browse the repository at this point in the history
For backwards compatibility
  • Loading branch information
tobil4sk committed Apr 13, 2022
1 parent bc3730e commit 3a26569
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/haxelib/api/LibraryData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ abstract Version(String) to String from SemVer from VcsID {
return new Version(s);
}

static function ofStringUnsafe(s:String):Version {
return new Version(s);
}

/** Returns whether `s` constitues a valid library version. **/
public static function isValid(s:String):Bool {
return VcsID.isValid(s) || SemVer.isValid(s);
Expand Down
12 changes: 7 additions & 5 deletions src/haxelib/api/Repository.hx
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@ class Repository {
throw new CurrentVersionException('Library $name is not installed');

final content = getCurrentFileContent(name);
return try
Version.ofString(content)
catch (e:LibraryDataException)
throw new CurrentVersionException('Current set version of $name is invalid.');
// return try
// Version.ofString(content)
// catch (e:LibraryDataException)
// throw new CurrentVersionException('Current set version of $name is invalid.');
return @:privateAccess Version.ofStringUnsafe(content);
}

/**
Expand Down Expand Up @@ -364,7 +365,8 @@ class Repository {
case v if (SemVer.isValid(v)): v;
case (try Vcs.VcsID.ofString(_) catch(_) null) => vcs if (vcs != null):
Vcs.getDirectoryFor(vcs);
case _: throw 'Unknown library version: $version'; // we shouldn't get here
//case _: throw 'Unknown library version: $version'; // we shouldn't get here
case custom: custom;
}
return addToRepoPath(name, Data.safe(versionDir).toLowerCase()).addTrailingSlash();
}
Expand Down

0 comments on commit 3a26569

Please sign in to comment.