8000 Require Inko 0.18.0 or newer · yorickpeterse/clogs@030ae53 · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Require Inko 0.18.0 or newer
Browse files Browse the repository at this point in the history
Changelog: changed
  • Loading branch information
yorickpeterse committed Jan 27, 2025
1 parent 85ed5d6 commit 030ae53
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ changelog.

## Requirements

- Inko 0.17.0 or newer
- Inko 0.18.0 or newer
- Git

Generating changelogs comes with the following workflow requirements:
Expand Down
2 changes: 1 addition & 1 deletion inko.pkg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require inko 0.17.0
require inko 0.18.0
4 changes: 2 additions & 2 deletions src/clogs/changelog.inko
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn format_date(date: ref DateTime) -> String {
'${date.year}-${date.month.to_string.pad_start('0', chars: 2)}-${date.day.to_string.pad_start('0', chars: 2)}'
}

class Release {
type Release {
let @config: ref Config
let @version: Version
let @previous_version: Option[Version]
Expand Down Expand Up @@ -75,7 +75,7 @@ impl ToString for Release {
}
}

class Changelog {
type Changelog {
let @path: Path
let @data: String

Expand Down
15 changes: 6 additions & 9 deletions src/clogs/config.inko
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let DEFAULT_CATEGORIES = [
['other', 'Other'],
]

class enum Error {
type enum Error {
# The configuration file couldn't be loaded (e.g. it doesn't exist).
case InvalidFile(IoError)

Expand Down Expand Up @@ -59,7 +59,7 @@ impl ToString for Error {
}
}

class Config {
type Config {
let @url: String
let @changelog: Path
let @categories: Map[String, String]
Expand All @@ -76,14 +76,11 @@ class Config {
}

fn static load(path: ref Path) -> Result[Config, Error] {
let buf = ByteArray.new

try ReadOnlyFile
.new(path.clone)
.then(fn (file) { file.read_all(buf) })
.map_error(fn (e) { Error.InvalidFile(e) })
let file = try ReadOnlyFile.new(path.clone).map_error(fn (e) {
Error.InvalidFile(e)
})

let doc = match Json.parse(buf) {
let doc = match Json.parse(file) {
case Ok(Object(map)) -> map
case Ok(_) -> throw Error.InvalidRoot
case Error(e) -> throw Error.InvalidSyntax(e.to_string)
Expand Down
8 changes: 4 additions & 4 deletions src/clogs/git.inko
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let REVERT_TEXT = 'This reverts commit '
let SHA_SIZE = 40

# An error produced when running Git commands.
class enum Error {
type enum Error {
# The Git command failed to run, such as due to it not existing, or a lack of
# permissions.
case Invalid(IoError)
Expand All @@ -47,7 +47,7 @@ impl ToString for Error {
# An iterator over the lines of a process' STDOUT stream.
#
# The produced lines _don't_ include the trailing newline.
class Output {
type Output {
let @child: sys.ChildProcess
let @stdout: BufferedReader[sys.Stdout]
let @buffer: ByteArray
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Iter[String] for Output {
}
}

class Commit {
type Commit {
let @id: String
let @subject: String
let @category: String
Expand All @@ -91,7 +91,7 @@ class Commit {
}
}

class Repository {
type Repository {
let @path: Path

fn static new(path: ref Path) -> Repository {
Expand Down
2 changes: 1 addition & 1 deletion src/clogs/version.inko
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import std.string (ToString)

# A type that represents a version number, per semantic versioning
# (https://semver.org/).
class Version {
type Version {
let @major: Int
let @minor: Int
let @patch: Int
Expand Down
2 changes: 1 addition & 1 deletion src/main.inko
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import std.io (Write)
import std.stdio (Stderr, Stdout)
import std.sys (exit)

class async Main {
type async Main {
fn async main {
# This is needed to work around
# https://github.com/inko-lang/inko/issues/631.
Expand Down
13 changes: 4 additions & 9 deletions test/clogs/test_changelog.inko
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clogs.git (Commit)
import clogs.helpers (with_file_path, write)
import clogs.version (Version)
import std.test (Tests)
import std.time (DateTime)
import std.time (Date, DateTime, Time)

fn config -> Config {
let conf = Config.default
Expand All @@ -18,14 +18,9 @@ fn release(config: ref Config) -> Release {
config,
version: Version.new(1, 0, 1),
previous_version: Option.Some(Version.new(1, 0, 0)),
date: DateTime(
year: 2023,
month: 8,
day: 5,
hour: 12,
minute: 15,
second: 30,
sub_second: 0.0,
date: DateTime.new(
date: Date.new(year: 2023, month: 8, day: 5).get,
time: Time.new(hour: 12, minute: 15, second: 30, nanosecond: 0).get,
utc_offset: 0,
),
)
Expand Down
10 changes: 5 additions & 5 deletions test/clogs/test_cli.inko
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import clogs.cli
import clogs.config (CONFIG_FILE, Config)
import clogs.git (Repository)
import clogs.helpers (read, with_directory, with_repository)
import std.io (Write)
import std.io (Error, Write)
import std.optparse (Options)
import std.test (Tests)

class Writer {
type Writer {
let @buffer: mut ByteArray
}

impl Write for Writer {
fn pub mut write_string(string: String) -> Result[Nil, Never] {
fn pub mut write_string(string: String) -> Result[Nil, Error] {
@buffer.append(string.to_byte_array)
Result.Ok(nil)
}

fn pub mut write_bytes(bytes: ref ByteArray) -> Result[Nil, Never] {
fn pub mut write_bytes(bytes: ref ByteArray) -> Result[Nil, Error] {
@buffer.copy_from(bytes, at: 0, size: bytes.size)
Result.Ok(nil)
}

fn pub mut flush -> Result[Nil, Never] {
fn pub mut flush -> Result[Nil, Error] {
Result.Ok(nil)
}
}
Expand Down

0 comments on commit 030ae53

Please sign in to comment.
0