From f9d3072b0ec164720bebe070dcd8b01530610bab Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 29 Aug 2022 22:46:53 -0500 Subject: [PATCH] added repository list to onyx-pkg; bugfix in io.reader --- core/io/reader.onyx | 2 +- scripts/onyx-pkg.onyx | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/io/reader.onyx b/core/io/reader.onyx index ab7fa0d1..890b0138 100644 --- a/core/io/reader.onyx +++ b/core/io/reader.onyx @@ -90,7 +90,7 @@ read_all :: (use reader: ^Reader, allocator := context.allocator) -> [] u8 { break; } - if error != .None && error != .ReadPending { + if error != .None && error != .ReadPending && error != .EOF { reader_consume_error(reader); break; } diff --git a/scripts/onyx-pkg.onyx b/scripts/onyx-pkg.onyx index c77e4d91..e4420d1e 100644 --- a/scripts/onyx-pkg.onyx +++ b/scripts/onyx-pkg.onyx @@ -1,8 +1,20 @@ #load "core/std" +// +// A list of repository URLs to get packages from. +// These should be formatted to have one formatted +// argument, which the package name. +Known_Repositories :: str.[ + "{}", + "git://onyxlang.io/repo/{}" +] + Version :: SemVer.{0, 1, 1} + + + use core global_arguments: struct { @@ -131,6 +143,8 @@ run_add_command :: (args: [] cstr) { } dep := string.as_str(args[0]); + dep = Git.get_full_repo_uri(dep); + version: SemVer; if args.count > 1 { if !conv.parse_any(^version, string.as_str(args[1])) { @@ -624,6 +638,18 @@ Package :: struct { } Git :: struct { + get_full_repo_uri :: (repo: str) -> str { + for Known_Repositories { + r := tprintf(it, repo); + git_proc := os.process_spawn(git_path, .["ls-remote", "--tags", r]); + if os.process_wait(^git_proc) == .Success { + return r |> string.alloc_copy(); + } + } + + return ""; + } + get_available_versions :: (repo: str) -> [] SemVer { versions := make([..] SemVer); -- 2.25.1