Commit Graph

178 Commits

Author SHA1 Message Date
246987fa68 Signature & tests for fn load_from_file()
This function almost writes itself. I need a thin layer to handle the
file IO errors and report them appropriately, and then all the magic is
a pass-through of the existing read_conf_str.

I've made basic unit tests for the most obvious scenarios. The test for
missing-file behavior is incomplete because I need to create a new error
variant.
2025-07-17 14:21:53 -05:00
551297f46b Remove some debug prints 2025-07-17 14:13:04 -05:00
912a7283fd Externalize the test table
I'm beginning work on the file reading functions, so I need some files
to read in my tests. I'll also need the WholeFile struct to compare
against.

The input string has been moved out into a file and put back into the
test fixture with `include_str!()`. The WholeFile construction has been
moved to a util function so I can reuse it in another test.
2025-07-17 14:04:17 -05:00
247c06dd9e Rename the config-string-reading function 2025-07-17 13:32:55 -05:00
cb314a8b4c Assert empty conf str is an error, TODO: semantics
The empty configuration string is some kind of an error, but I'm not
sure where and how to handle it. It should be treated as a soft error,
where I fall back to some hardcoded defaults.

There's a logic hole at the moment: The error I'm actually getting right
now is "NoSuchTable" because the "[all]" table doesn't exist. For a
totally empty config file, the above response should be used. But what
about a non-empty conf file? Is a missing "[all]" valid or not? For now,
assert the loader returns *an* error and leave behind a TODO for later.
2025-07-17 13:29:25 -05:00
277f638c60 Add a builder-pattern proj-path setter, for flavor
I like being able to chain methods instead of using a temporary variable
in between, so I've made one single function like I'm doing the builder
pattern.

But not really because there's nothing to build or finalize and such.
2025-07-17 12:13:14 -05:00
626973d2bc Extract PartCfg readers to a try_from impl
Don't repeat yourself. These property reading routines are actually
methods on the PartialConfig struct, so make them *actually* methods.

Because the table doesn't know it's own name, the path-specific config
needs to be updated with that external knowledge.
2025-07-17 12:08:35 -05:00
28539f54cc Use the get_table util to extract "[all]" table
I built the function for this purpose and then forgot to use it. I
remembered after doing the per-project bit, so here's the refactor.
2025-07-17 11:49:44 -05:00
5ce20adf2e Create-and-assign struct to whole.all
Minor refactor to make the "[all]" table read look like the per-project
table reads.
2025-07-17 11:47:18 -05:00
fc1e20185e Finish fn lconf(). Project-specific vals load
Loop over the keys (ignore the "all" one) and repeat the same property
extraction process.
2025-07-17 11:41:28 -05:00
15593204e0 Put the per-project test expects in for lconf()
Put all those per-project configs into the unit test. They're in the
input string, so we should expect to see them in the output struct.
2025-07-17 10:28:17 -05:00
330985940f Prototype load-config function
The `lconf()` function will eventually load the whole file, but for now
it reads in only the "[all]" table.

That "[all]" table will be used as the global fallback when per-project
settings are left unspecified.

The unit test "passes" but only because I've discarded those per-project
configs from the expected result. This is just so I can see clearly that
the all-table is loading properly.
2025-07-17 10:25:26 -05:00
213e0b4f4a Add partial- and whole- config structs 2025-07-17 10:23:00 -05:00
d27bea2c43 Util to get sometimes-empty config property
The get_property function needs to say that there is no property so that
the caller can respond appropriately. I'm going to need to frequently
respond to the "no such property" path by treating it as *not* an error.

If the config file doesn't specify a property, that's not an error, it's
just not specified and the default should be used instead. This util fn
makes that a bit more ergonomic.
2025-07-17 09:59:52 -05:00
30d8bcc6de Util fn's can use anything that impl's ToString
I don't want to remember to construct a `String` every single time I
want to call this function with a string literal. So I won't.

Make the functions generic over anything that implements the ToString
trait.
2025-07-17 09:57:49 -05:00
b2b9c8b9d9 Add a get-table util function 2025-07-16 19:16:43 -05:00
f6bab75644 Add property-get utility function
This function will look for a given property in a given table. It gives
back either the property, or an explanation of why it could not be
retrieved.
2025-07-14 21:43:08 -05:00
f9673b715f Update changelog for 2.2.0-2 release debian/2.2.0-2 2025-07-13 17:00:26 -05:00
820a9daaed Fix typo in copyright comment 2025-07-13 16:56:00 -05:00
8d71b81271 Fix: "Source:" URL in debian/copyright
That's what I get for copying other peoples' homework. I should have
used one of the `dh*` commands to build out the packaging boilerplate.
Oh well.
2025-07-13 16:51:22 -05:00
075a2ee921 Scaffold the new config module 2025-07-06 17:28:11 -05:00
8eacb510a2 Add a Cargo.toml & Git tag version comparison
I released the first couple versions without updating the value in
Cargo.toml. This will check for that happening again and abort the
build.
2025-07-06 12:54:52 -05:00
a23bdf3e34 Make the README title singular
It's not the "gt-tools" anymore, so maybe the README should match.
2025-07-05 17:21:59 -05:00
17bde93259 Update changelog for 2.2.0-1 release debian/2.2.0-1 2025-07-04 10:11:04 -05:00
cdb312fe61 Add the new dependencies to debian/control
Debian's package machinery also needs to know about these things, so
throw them into the control file.
2025-07-04 10:07:47 -05:00
cfaa0ceb3f Lift the empty-body string outside the let-if
Patch the string reference lifetime issue, and rediff the other patch
while we're at it.
2025-07-04 09:57:16 -05:00
c0a0181074 Merge tag 'v2.2.0' into deb/bookworm 2025-07-04 09:43:25 -05:00
119831481e Bump to v2.2.0
All checks were successful
/ Compile and upload a release build (release) Successful in 44s
v2.2.0
2025-07-03 18:13:09 -05:00
7246c7afb6 Oops, missed one 2025-07-03 18:05:18 -05:00
84eaaa1dbd Autoformat 2025-07-03 18:03:33 -05:00
c9dda5760c Prefix unused variables to quiet the linter 2025-07-03 17:56:07 -05:00
336f1453b9 Address most of the cargo-clippy lints 2025-07-03 17:56:07 -05:00
f068e8233e Release.colorized(), not std::fmt::Display
I don't know for sure if the string-ified version of a Release struct is
being printed to the terminal. As such, I don't know if the user wants,
does not want, or has mixed intentions for the stringification of this
thing.

No Display impl, instead just a `colorized()` method.
2025-07-03 17:47:50 -05:00
d4ef21e243 Change to free-fn intersperse for stdlib compat
Itertools warns that the standard library may be stabilizing the
intersperse method soon and recommends using this function instead.
2025-07-02 22:44:06 -05:00
d94c350cde Galaxy-brained newline intersperse function
Itertools already has an intersperse method for me. Why would I build my
own when I can do this? There's even a `fold()` over the units that come
out of the print routine.
2025-07-02 22:29:07 -05:00
8120cb0489 Remove trailing newline in Release item printout 2025-07-02 22:08:45 -05:00
b82cfdb822 Colorize the output! 2025-07-02 22:06:36 -05:00
ea046c929f Print releases in reverse order for easier reading
The result list has the newest item first, but I want to print them the
other way around. This way the newest (and presumably most interesting)
release is always the visible item, regardless of how many others have
printed and scrolled off screen.
2025-07-02 21:42:41 -05:00
135acf09b7 Basic impl Display for the Release struct
I'm not certain what info I want to present when listing the Releases.

The idea is that the release version is the most important, and that it
matches the git-tag associated with the release. I'll print that first.

Next, the name of the release followed by the body text. The list of
releases will become quite large for some projects, and the body text
may include a changelog. Both of these will cause the output to become
quite large. I will need to create a size limiter, but I'm ignoring that
for now.

Who created the release and when may be useful when searching for a
release, so I've included that as the final section.
2025-07-02 12:56:17 -05:00
bbae6b4395 Update changelog for 2.1.0-1 release debian/2.1.0-1 2025-06-12 17:51:23 -05:00
2c03c5ba4d Merge tag 'v2.1.0' into deb/bookworm
Hotfix for Attachment decode error
2025-06-12 17:48:09 -05:00
136c051c82 Fix: incorrect field names for Attachment
All checks were successful
/ Compile and upload a release build (release) Successful in 37s
I think I got the names from the Go source code, but the API emits JSON
that has these names instead. The api/swagger guide even says as much.

This caused the super fun quirk that the upload actually succeedes, but
the program reports an error condition because of the deserialization
failure. Time to bump a minor revision!
v2.1.0
2025-06-12 17:21:48 -05:00
6a9ec25d1a Update changelog for 2.0.0-1 release debian/2.0.0-1 2025-06-12 16:28:43 -05:00
395ce8a804 Rediff patches
Drop 0002-Use-pre-Rust-1.81-compatible-file-exists-test.patch: <REASON>
2025-06-12 16:24:48 -05:00
616be020f0 Merge tag 'v2.0.0' into deb/bookworm
Mark release for v2

Now with better error diagnostics!... better... They're still not great.
2025-06-12 16:22:33 -05:00
a0ba8e7ea8 Use pre Rust 1.81 compatible file-exists test
The function `std::fs::exists(...)` was stabilized in Rust 1.81, which
means it can't be used in the Debian Bookworm build. This patch swaps to
a compatible implementation leaning on the std::path::Path struct.

I'm both "upstreaming" a Debian-specific patch I had to make for the
package, and fixing the additional usage now in `main.rs`. There doesn't
seem to be any compelling reason to avoid using this function, so I
figure I should merge it into the base release.
v2.0.0
2025-06-12 16:05:51 -05:00
324c7e67a7 Re-assign v1.0.0-1 to 'unstable'
I should have done this before publishing the build, but it's too late
now. Instead, I'll update it here and continue forward with gbp-dch to
help generate more correct changelogs.
2025-06-12 12:55:16 -05:00
984974c240 Update debian/gbp.conf to use new branch name
I'm switching to use nested tags for the packaging branches. I want to
have a deb/bookworm and a deb/experimental branch. The gbp-pq tool
already seems to do this, so I'll follow it's lead.
2025-06-12 12:50:48 -05:00
88cafc096f Drop unused import in api/release.rs 2025-06-08 10:43:32 -05:00
b200785e71 ... and the unit testing notes in README.md 2025-06-08 10:40:54 -05:00