Skip to content

Commit

Permalink
[hx download] allow 'hx download [sha]' syntax (skip 'nightlies' arg)
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Apr 24, 2024
1 parent 088ad65 commit cd7be22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/HaxeDownload.hx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class HaxeDownload {
case [v] if (SemVer.isValid(v)): downloadRelease(v);
case [v, alias] if (SemVer.isValid(v)): downloadRelease(v, alias);

case [v] if (HaxeNightlies.isValid(v)): downloadNightly(v);
case [v, alias] if (HaxeNightlies.isValid(v)): downloadNightly(v, alias);

case [v] | [v, _]:
Utils.displayError('hx download: $v is not a valid release version\n');
displayUsage();
Expand Down
6 changes: 5 additions & 1 deletion src/HaxeNightlies.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ class HaxeNightlies {
static var ref_check = ~/^[a-f0-9]{7,}$/i;

public static function resolve(ref:String):String {
if (ref_check.match(ref)) return getNightly(ref);
if (SemVer.isValid(ref)) return getNightly(ref, true);
if (isValid(ref)) return getNightly(ref);
return ref;
}

public static function isValid(ref:String):Bool {
return ref_check.match(ref);
}

static function getNightly(ref:String, ?isTag:Bool = false):Null<String> {
final date = getCommitDate(ref);
if (date == null) {
Expand Down

0 comments on commit cd7be22

Please sign in to comment.