forgejo-contrib/forgejo-cli
20
407
Fork
You've already forked forgejo-cli
51

feat(repo): Add star-status command and checks in star commands #554

Open
Fluffinity wants to merge 1 commit from Fluffinity/forgejo-cli:feat-star-check into main
pull from: Fluffinity/forgejo-cli:feat-star-check
merge into: forgejo-contrib:main
forgejo-contrib:main
forgejo-contrib:renovate/open-5.x-lockfile
forgejo-contrib:renovate/comrak-0.x
forgejo-contrib:renovate/uuid-1.x-lockfile
forgejo-contrib:renovate/lock-file-maintenance
forgejo-contrib:docs/contributing
forgejo-contrib:no-port-in-refspec
forgejo-contrib:login/v16.next.forgejo.org
forgejo-contrib:crates-io-publish
forgejo-contrib:0.5.x
forgejo-contrib:compile-time-fluent
forgejo-contrib:0.4.x
forgejo-contrib:localization-alias-demo
forgejo-contrib:api_url_field
Contributor
Copy link

Changes Made

This PR mirrors the feature sets of the commands for starring and watching repos. This includes checking for the status in the (un)star commands to inform upon attempting a redundant operation.

Now, there is technically code duplication, as the check_repo_*_status and print_* functions for watching and starring repos are almost identical. I did it this way, as it's still fine with only two features (watching and starring repos) are in play right now. That being said, if we want to add more features, that follow this structure, we may want to abstract out the common core.

fixes: #530

Code of Conduct

  • I agree to act in accordance with the CoC & AI Agreement.
  • This contribution was not generated by an LLM, even in part.
### Changes Made This PR mirrors the feature sets of the commands for starring and watching repos. This includes checking for the status in the (un)star commands to inform upon attempting a redundant operation. Now, there is technically code duplication, as the `check_repo_*_status` and `print_*` functions for watching and starring repos are almost identical. I did it this way, as it's still fine with only two features (watching and starring repos) are in play right now. That being said, if we want to add more features, that follow this structure, we may want to abstract out the common core. fixes: #530 ### Code of Conduct - [x] I agree to act in accordance with the CoC & AI Agreement. - [x] This contribution was not generated by an LLM, even in part.
feat(repo): Add star-status command and checks in star commands
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
ff5d807f63
This commit mirrors the feature sets of the commands for starring and
watching repos. This includes checking for the status in the (un)star
commands to inform upon attempting a redundant operation. See
watch-status for the features of the new command.
Fluffinity force-pushed feat-star-check from ff5d807f63
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
to 727e7de524
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
2026年07月11日 19:51:55 +02:00
Compare
Author
Contributor
Copy link

Applied the same changes for printing all starred repos as in #560

Applied the same changes for printing all starred repos as in #560
Cyborus approved these changes 2026年07月11日 21:13:22 +02:00
Dismissed
Fluffinity force-pushed feat-star-check from 727e7de524
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
to 34e3cac21a
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
2026年07月11日 22:24:13 +02:00
Compare
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

Author
Contributor
Copy link

Rebased onto current main and I took the opportunity to also add help text for the --list flag

Rebased onto current main and I took the opportunity to also add help text for the `--list` flag
src/repo.rs Outdated
@ -1242,0 +1306,4 @@
.and_then(|owner|owner.login.as_deref())
.unwrap_or("<>");
letname=repo.name.as_deref().unwrap_or("<>");
ftl_println!("msg-repo-star_status-list-repo",owner=owner,repo=name);
Member
Copy link

owner = owner could just be owner

`owner = owner` could just be `owner`
Author
Contributor
Copy link

done

done
Fluffinity marked this conversation as resolved
@ -869,0 +871,4 @@
msg-repo-star-already_starred = You already starred this repo
msg-repo-unstar-already_unstarred = You already don't star this repo
msg-repo-star_status-starred = You have starred {$owner}/{$repo}
msg-repo-star_status-unstarred = You have not starred {$owner}/{$repo}
Collaborator
Copy link

This sounds a bit strange to me, because if I just unstarred a repo, I must've starred it before, meaning the statement that I have not starred it is incorrect. This should probably be something like "You have unstarred ..." instead.

This sounds a bit strange to me, because if I just unstarred a repo, I must've starred it before, meaning the statement that I have not starred it is incorrect. This should probably be something like "You have unstarred ..." instead.
Author
Contributor
Copy link

Just to be sure, I'm assuming you are talking about line 874. I don't quite get what you mean. If the user queries whether they starred a given repo and they didn't, it doesn't imply that they unstarred it before. It only means that they currently do not star it.

Just to be sure, I'm assuming you are talking about line 874. I don't quite get what you mean. If the user queries whether they starred a given repo and they didn't, it doesn't imply that they unstarred it before. It only means that they currently do not star it.
Collaborator
Copy link

Oh I see now - I misinterpreted the message. I thought it was printed when the user just unstarred a repository, my bad.

Oh I see now - I misinterpreted the message. I thought it was printed when the user just unstarred a repository, my bad.
LordMZTE marked this conversation as resolved
@ -869,0 +872,4 @@
msg-repo-unstar-already_unstarred = You already don't star this repo
msg-repo-star_status-starred = You have starred {$owner}/{$repo}
msg-repo-star_status-unstarred = You have not starred {$owner}/{$repo}
msg-repo-star_status-list-header = You star {$count} repos
Collaborator
Copy link

This should distinguish between singular and plural cases - this could end up saying "You have starred 1 repos".

This should distinguish between singular and plural cases - this could end up saying "You have starred 1 repos".
Author
Contributor
Copy link

I'll get to that later. This is also something to be fixed in the watch-status command.

I'll get to that later. This is also something to be fixed in the `watch-status` command.
src/repo.rs Outdated
@ -703,0 +732,4 @@
.name()
.ok_or_else(||ftl_eyre!("msg-repo-name_needed"))?;
letstarred=check_repo_star_status(&api,name.owner(),name.name()).await?;
ifstarred{
Collaborator
Copy link

This could be simplified to:

ftl_println!(ifstarred{"msg-repo-star_status-starred"}else{"msg-repo-star_status-unstarred"},owner=name.owner(),repo=name.name(),);
This could be simplified to: ```rust ftl_println!( if starred { "msg-repo-star_status-starred" } else { "msg-repo-star_status-unstarred" }, owner = name.owner(), repo = name.name(), ); ```
Author
Contributor
Copy link

Definitely more terse, although I'm not too much of a fan of using anything else than a string literal as the argument for the ftl_ macros. This wouldn't really make the code simpler in my opinion.

Definitely more terse, although I'm not too much of a fan of using anything else than a string literal as the argument for the `ftl_` macros. This wouldn't really make the code simpler in my opinion.
src/repo.rs Outdated
@ -1225,0 +1272,4 @@
letresponse=api.user_current_check_starring(owner,repo).await;
matchresponse{
Ok(_)=>Ok(true),
Err(ForgejoError::ApiError(ApiError{
Collaborator
Copy link

This path is also hit if we ask for that status on a non-existant repo, which should be an error instead:

$ cargo run -- -H git.mzte.de repo star-status lordmzte/blablabla-this-doesnt-exist
 Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
 Running `target/debug/fj -H git.mzte.de repo star-status lordmzte/blablabla-this-doesnt-exist`
You have not starred lordmzte/blablabla-this-doesnt-exist
This path is also hit if we ask for that status on a non-existant repo, which should be an error instead: ``` $ cargo run -- -H git.mzte.de repo star-status lordmzte/blablabla-this-doesnt-exist Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s Running `target/debug/fj -H git.mzte.de repo star-status lordmzte/blablabla-this-doesnt-exist` You have not starred lordmzte/blablabla-this-doesnt-exist ```
Author
Contributor
Copy link

In this case we need to make a second API call to determine whether the repo exists. Unfortunately, Codeberg uses a 404 to signal the status as unstarred/unwatched, so we can not distinguish that from the non-existence of that repo. This is really annoying, but yeah, I can put in the check.

In this case we need to make a second API call to determine whether the repo exists. Unfortunately, Codeberg uses a 404 to signal the status as unstarred/unwatched, so we can not distinguish that from the non-existence of that repo. This is really annoying, but yeah, I can put in the check.
Collaborator
Copy link

Have you compared the responses in both cases? Maybe the message is different.

Have you compared the responses in both cases? Maybe the message is different.
Author
Contributor
Copy link

The response bodies and headers are identical. So we have to make a second API call to determine whether the repo exists

The response bodies and headers are identical. So we have to make a second API call to determine whether the repo exists
Fluffinity force-pushed feat-star-check from 34e3cac21a
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
to a165ee36ca
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
ci/woodpecker/pr/check-clippy Pipeline was successful
2026年07月12日 11:48:23 +02:00
Compare
All checks were successful
ci/woodpecker/pr/check-typos Pipeline was successful
ci/woodpecker/pr/check Pipeline was successful
Required
Details
ci/woodpecker/pr/check-clippy Pipeline was successful
This pull request has changes requested by an official reviewer.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u feat-star-check:Fluffinity-feat-star-check
git switch Fluffinity-feat-star-check
Sign in to join this conversation.
No reviewers
Labels
Clear labels
Kind/Breaking
Breaking change that won't be backward compatible
Kind/Bug
Something is not working
Kind/Design
Discussion about UI/UX design
Kind/Documentation
Documentation changes
Kind/Enhancement
Improve existing functionality
Kind/Feature
New functionality
Kind/Security
This is security issue
Kind/Testing
Issue or pull request related to testing
Kind/Upstream
This is an issue with upstream software (Forgejo) that is probably not our fault
Priority
Critical
The priority is critical
Priority
High
The priority is high
Priority
Low
The priority is low
Priority
Medium
The priority is medium
Reviewed
Confirmed
Issue has been confirmed
Reviewed
Duplicate
This issue or pull request already exists
Reviewed
Invalid
Invalid issue
Reviewed
Won't Fix
This issue won't be fixed
Status
Abandoned
Somebody has started to work on this but abandoned work
Status
Blocked
Something is blocking this issue or pull request
Status
Need More Info
Feedback is required to reproduce issue or to continue work
Suspicious
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo-contrib/forgejo-cli!554
Reference in a new issue
forgejo-contrib/forgejo-cli
No description provided.
Delete branch "Fluffinity/forgejo-cli:feat-star-check"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?