Commit Graph
100 Commits
Author SHA1 Message Date
robert 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
robert c0a0181074 Merge tag 'v2.2.0' into deb/bookworm 2025-07-04 09:43:25 -05:00
robert 119831481e Bump to v2.2.0
/ Compile and upload a release build (release) Successful in 44s
2025-07-03 18:13:09 -05:00
robert 7246c7afb6 Oops, missed one 2025-07-03 18:05:18 -05:00
robert 84eaaa1dbd Autoformat 2025-07-03 18:03:33 -05:00
robert c9dda5760c Prefix unused variables to quiet the linter 2025-07-03 17:56:07 -05:00
robert 336f1453b9 Address most of the cargo-clippy lints 2025-07-03 17:56:07 -05:00
robert 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
robert 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
robert 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
robert 8120cb0489 Remove trailing newline in Release item printout 2025-07-02 22:08:45 -05:00
robert b82cfdb822 Colorize the output! 2025-07-02 22:06:36 -05:00
robert 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
robert 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
robert bbae6b4395 Update changelog for 2.1.0-1 release 2025-06-12 17:51:23 -05:00
robert 2c03c5ba4d Merge tag 'v2.1.0' into deb/bookworm
Hotfix for Attachment decode error
2025-06-12 17:48:09 -05:00
robert 136c051c82 Fix: incorrect field names for Attachment
/ 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!
2025-06-12 17:21:48 -05:00
robert 6a9ec25d1a Update changelog for 2.0.0-1 release 2025-06-12 16:28:43 -05:00
robert 395ce8a804 Rediff patches
Drop 0002-Use-pre-Rust-1.81-compatible-file-exists-test.patch: <REASON>
2025-06-12 16:24:48 -05:00
robert 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
robert 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.
2025-06-12 16:05:51 -05:00
robert 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
robert 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
robert 88cafc096f Drop unused import in api/release.rs 2025-06-08 10:43:32 -05:00
robert b200785e71 ... and the unit testing notes in README.md 2025-06-08 10:40:54 -05:00
robert 8246337ae4 Delete the unit tests
They aren't useful anyway.
2025-06-08 00:06:59 -05:00
robert 06795df3f7 Update main.rs to use new attachment iface 2025-06-07 23:57:19 -05:00
robert a5f6335b5f Add Attachment struct, new iface for create-rel
The Attachment struct exists, but this makes it glaringly obvious that
I've made a bad interface. The create_release_attachment should only
accept one file at a time and the loop over all files should happen in
main.rs

I've changed the signature, removed the loops, and wired in the newer
error handling routines. Needs fixing at call sites.
2025-06-07 23:50:16 -05:00
robert 4a0addda67 Fold client-error-decode into a util function 2025-06-07 23:40:58 -05:00
robert 0c70b584ba Interrogate create_release_attachment result 2025-06-07 23:30:56 -05:00
robert 8a11c21b73 "Fix" the test case
I can't meaningfully unit test these things like this. I'll explore creating a tarball of a known Gitea configuration and using Docker to test against that. For now, just... kinda keep the test building.
2025-06-07 23:24:16 -05:00
robert d42cbbc1ec Drop unused imports 2025-06-07 23:22:48 -05:00
robert 96e9ff4ce6 Interrogate create_release result more closely 2025-06-07 23:22:20 -05:00
robert 6bdad44cc6 Interrogate list_releases result more closely 2025-06-07 23:15:39 -05:00
robert 4c05749d02 Rediff patches
Add 0002-Use-pre-Rust-1.81-compatible-file-exists-test.patch: <REASON>
Add 0001-Rust-edition-downgrade-to-2021.patch: <REASON>
2025-06-06 19:22:09 -05:00
robert c0e6c5d89d Create Debian packaging files 2025-06-06 19:19:39 -05:00
robert e8d0d5db74 Mark crate version 1.0
/ Compile and upload a release build (release) Successful in 36s
2025-06-06 18:28:06 -05:00
robert 2501213d4f Rename the project to be gt-tool singular 2025-06-06 18:20:15 -05:00
robert b76d5f836d Basic automated build-and-upload 2025-06-06 17:16:39 -05:00
robert aadaff5db4 Add "No such release" error variant 2025-06-05 20:58:46 -05:00
robert 33f7fc6515 Fix the release_attachment file-existence loop
I only dealt with the scenario where I get back an Err(_) value. This is
not what happens when the file is missing, it's what happens when there
was some other problem interacting with the file. Instead, an Ok(bool)
is returned to indicate positive identification of the presence or
absence of the file.

Something should be done about the std::io::error::Error that gets
handed back. Since I'm not expecting to see it very often, nor to really
do anything about it, I'm just emitting an error message and panicking.
2025-06-04 18:20:23 -05:00
robert a08466c834 Test fix: uploading missing file shouldn't panic
There's a check in the create_release_attachment() function to ensure
the files exist before attempting to read them. Clearly, it isn't
working correctly.

I've dropped the `#[should_panic]` annotation and added a better Result
unpacking routine. It will report specific messages based on the result.
2025-06-04 14:03:17 -05:00
robert b8225cbc04 Test should-panic when uploading missing file
I'm not sure I want this code path to panic, actually... It should
probably return some error result so the app can print an error
diagonstic.

Oh well. That's a future problem. The end result is functionally
identical.
2025-06-04 11:41:24 -05:00
robert 098f967174 Create a TestConfig struct to separate setup
I was about to copy-paste the entire body of the attach_file_exists test
function into the attach_file_missing function. The only difference is
the file that they upload -- or don't, in the second case. I could make
a try-file-upload function and pass it many different files, but I don't
think I need that. Instead, I'll separate the test setup from the test
sequence itself.
2025-06-04 11:34:46 -05:00
robert e7e8a2871b Add unit test for release_attachment function
I need some kind of automated testing, and Cargo has a test framework
built-in. This isn't the smartest test and depends upon another
test-less function.

Building a mocking environment is possible but means I'm trying to
emulate some behavior I don't fully understand -- that's why I need
tests in the first place. That path leads to tests for my tests and
that's stupid.

Instead, I'm having the test read config from the environment and hit a
real Gitea server. It's up to the user to ensure they have one.
2025-06-04 11:14:12 -05:00
robert 340b37cf05 Disable the unimplemented "create" arg for uploads
I never got around to implementing the create-and-upload behavior for
the file attachment command. I'll do it later, but for now I'm disabling
the code to quiet down the compiler warnings.
2025-06-01 20:44:56 -05:00
robert 0a4de1cb92 Drop the prerelease flag for create-release
Releases in a "pre-release" state are... weird. I'm not going to deal
with their oddities right now, so instead I'm dropping the command
option and hard-coding a `false` at it's usage site.
2025-06-01 20:42:05 -05:00
robert 8213ddaf46 Drop default-false for flag arguments
These arguments don't accept a value, they *are* the value. Presence or
absence tells the program everything it needs, so there's no point in
setting a default.
2025-06-01 15:06:30 -05:00
robert bbf1eecc52 Rename the user-agent string, include pkg version
It's no longer a test agent, it's the release one. We're including the
package version (as specified in Cargo.toml).
2025-06-01 15:03:08 -05:00
robert e0c21fceaf Autoformat the whole thing
I've been putting this off because I don't want to have many small
formatting commits, and I don't have any kind of pre-commit hook to do
it for me. So here it is :v
2025-06-01 13:28:06 -05:00
robert 442c8a97f8 Create a usage guide 2025-06-01 13:27:45 -05:00
robert 448aac531a Find matching release ID for release-attachment
I've finally implemented the by-tag release matching thing. The info put
in on the command line actually gets used to attach files to the
release!
2025-06-01 12:24:16 -05:00
robert fac607719d Move the CreateResult enum into the releases mod
This thing only needs to exist so Serde can decode the response JSON
properly. I'll either get a success, a missing token, *no body at all
which doesnt' make sense*, or some other ApiError text. In all cases,
the crate::Result is returned. This thing doesn't need to be public.
2025-06-01 11:07:11 -05:00
robert ee42e09620 Fix API response decoding -- sometimes it's an err
The reqwest might work, but the API still returns an error message.
I forgot about this old hack I had left around because I'm a big dummy.
2025-05-31 22:46:54 -05:00
robert 8ab1f77b0e Only apply the Auth token header if a token exists 2025-05-31 22:21:41 -05:00
robert 508e2ac802 Fix auth token header, needs "token" prefix
https://docs.gitea.com/development/api-usage#authentication

I had this right earlier, but dropped it after the switch to a pre-
configured client via ClientBuilder a few commits ago.
2025-05-31 20:53:36 -05:00
robert baf0117a74 Delete the error mapper utility
Now that all API functions are the new versions using my gt_tools::Error
type natively, I don't need to map from the reqwest::Error into the
wrapped variant.
2025-05-29 17:46:00 -05:00
robert 3e563d4bb0 Clean up now-unused imports in main.rs 2025-05-29 17:45:46 -05:00
robert e848d9ace5 Delete old do_upload_release 2025-05-29 17:42:54 -05:00
robert 6b537c8992 Hook in new create_release_attachment to main 2025-05-29 17:42:31 -05:00
robert 6d95e54bc7 Transfer impl of release_attach to new home
A bunch of code has been dropped because it's no longer necessary -- yay for better data builder usage and real error handling!
2025-05-29 17:42:26 -05:00
robert 29172bae0b Delete old do_create_release function 2025-05-28 20:29:41 -05:00
robert 4250deb419 Implement new fn create_release() 2025-05-28 20:27:52 -05:00
robert a212dc3ceb Drop unused imports 2025-05-28 20:27:31 -05:00
robert 766703b8ec Load API token at startup, not API calls 2025-05-28 20:21:13 -05:00
robert a16594f5a9 Use our own Error enum in fn main 2025-05-28 19:33:52 -05:00
robert d3a0d3f67e Fix the URL path to actually go to the API 2025-05-28 19:27:32 -05:00
robert 90ae47abb2 Delete old do_list_releases, wire in the new one
With an `.unwrap()` because the error types don't match right now.
2025-05-27 23:05:03 -05:00
robert 472e592400 Implement the new ::api::list_releases function 2025-05-27 23:03:09 -05:00
robert e19602925e Add release_attachment module
For whatever reason, releases and release attachments are separate modules in the Gitea codebase. I'm going to continue mirroring that structure for now.
2025-05-27 23:02:27 -05:00
robert 36adabb4fd Start our own Error enum 2025-05-27 23:01:49 -05:00
robert 84bd7fe990 Fix release API module's name 2025-05-27 20:52:23 -05:00
robert 5db1134257 Move CreateReleaseOption to new tree 2025-05-27 20:46:04 -05:00
robert 5f666a8179 Move the Release info structs to new tree 2025-05-27 20:43:39 -05:00
robert 351c4902ae Create new module layout based on Gitea's own 2025-05-27 20:40:13 -05:00
robert b26436d5be Remove already commented-out code & dbg prints 2025-05-27 19:26:11 -05:00
robert 053ee8def9 Use file name, not whole path as upload name 2025-05-27 19:21:05 -05:00
robert c731cd963c Some but not all of the upload routine 2025-05-27 19:19:09 -05:00
robert 54487622c0 Add CLI option for uploading files + dummy hookup
I think this is the interface I want for uploading release files. There is an extra option to create the release ahead of the upload just in case it doesn't exist. One *should* create it with the create command or through the Gitea GUI so that everything can be properly written into the release info.
2025-05-25 09:08:22 -05:00
robert 8843640385 Thread the primary args through the operation fn's 2025-05-24 19:33:46 -05:00
robert 6b409c56d4 Change primary arguments
Owner and repo are combined into one string the same way Go dependencies or GitHub Actions are named. `<owner>/<repo>`

Each will be fetched from a matching environment variable if not specified on the command line.
2025-05-24 19:33:21 -05:00
robert 1210b168ee Demo: missing CLI args can be filled via env vars 2025-05-24 19:00:35 -05:00
robert 985c411902 Wire in the release CLI args to the creation fn 2025-05-24 18:47:51 -05:00
robert c5efb0e9f7 Add remaining release creation CLI args 2025-05-24 18:47:35 -05:00
robert 973d9aa6c6 Fix: missing slash between owner and repo 2025-05-24 18:29:49 -05:00
robert 0f4f2ee48f TODO: Serde won't make empty-vec 2025-05-24 18:17:41 -05:00
robert d4ec677b28 Internal-ize API endpoint assembly for create-release 2025-05-24 18:15:01 -05:00
robert 2c9cd5b958 Move list-releases code to its own function 2025-05-24 18:13:39 -05:00
robert f7ba2e99aa Assemble fragments to get API endpoint 2025-05-24 18:13:10 -05:00
robert da15506896 Sort derive macros 2025-05-24 17:59:25 -05:00
robert 2705900e10 Lint 2025-05-24 17:59:17 -05:00
robert 80637ca76c Move create-release code to it's own function 2025-05-24 17:56:10 -05:00
robert 19cb224598 Hook up the new deserialization structs 2025-05-24 17:07:08 -05:00
robert 26fa57a24f Additional structs & enums for API error responses
Obviously the Gitea API can return errors, which are also JSON strings.
Theres a new error response struct to collect these, and an enum for
Serde to unpack which ever variant happens to come back.
2025-05-24 17:04:08 -05:00
robert f1da1b508a Releases can now be created... sorta
The API token is read from the environment variable `RELEASE_KEY_GITEA`.
"GITEA" is on the end because Gitea itself will refuse to allow users to
configure Act variables starting with the name "GITEA_".

All information about the release is hard-coded right now. I just needed
to see it hit the API and appear on the Gitea page. Hooking up the extra
options is up next.
2025-05-24 15:14:53 -05:00
robert f31f5b49da Move the URL and HTTP Client out of match block
I'm going to need these in several of the arms.
2025-05-24 14:53:16 -05:00
robert 013c797e1f Drop nested list variable in command
The enum variant is the value this code-path requires. The inner bool doesn't do anything, so it can go away.
2025-05-24 14:31:07 -05:00
robert 8b0f60d348 Wire in the ListReleases primary command
Hey, look at that. I can do the thing what with the stuff and such.
2025-05-24 14:18:38 -05:00
robert 408b0108a5 Starting the Clap CLI parser 2025-05-24 13:52:32 -05:00
robert 2067964a80 Demo use of JSON deserialization
It Just Works. Praise the Rust macros.
2025-05-22 18:23:32 -05:00