Add repository and account visibility control #13

Open
orchestra wants to merge 2 commits from orchestra/fj:repo-visibility into donach-main
First-time contributor

Add explicit repository visibility to fj repo edit and fj repo create, and account visibility to fj user edit visibility. The account command uses the instance-admin API and reports the server's error message on 403. Repository edits re-read the saved state and warn if it differs from the request. Repository creation checks the state returned by Forgejo.

Measured behavior on git.bitp.cz (Forgejo 16.0.5)

PATCH /api/v1/repos/orchestra/harbour-kieli as the repo owner:

Body Result
{"private":true} private:true, internal:false
{"private":false} private:false, internal:true
{"internal":false} Unchanged (200, no effect)
{"private":false,"internal":false} Unchanged
{"visibility":"public"} Unchanged (unknown field, ignored)

GET /api/v1/users/orchestra returned visibility: private. GET /api/v1/users/donach returned visibility: public. Repositories owned by donach were anonymously readable. Repositories owned by orchestra returned 404 anonymously even with private:false.

Changing a repository from internal to public appears to require instance-admin privileges. An account with private visibility cannot publish a public repository. A successful PATCH alone does not establish that Forgejo applied the requested state.

This feature builds on donach-main, which contains the CLI. The requested main base contains only the initial README, so the comparison includes the existing CLI history.

Add explicit repository visibility to `fj repo edit` and `fj repo create`, and account visibility to `fj user edit visibility`. The account command uses the instance-admin API and reports the server's error message on 403. Repository edits re-read the saved state and warn if it differs from the request. Repository creation checks the state returned by Forgejo. ### Measured behavior on git.bitp.cz (Forgejo 16.0.5) `PATCH /api/v1/repos/orchestra/harbour-kieli` as the repo owner: | Body | Result | |---|---| | `{"private":true}` | `private:true, internal:false` | | `{"private":false}` | `private:false, internal:true` | | `{"internal":false}` | Unchanged (200, no effect) | | `{"private":false,"internal":false}` | Unchanged | | `{"visibility":"public"}` | Unchanged (unknown field, ignored) | `GET /api/v1/users/orchestra` returned `visibility: private`. `GET /api/v1/users/donach` returned `visibility: public`. Repositories owned by `donach` were anonymously readable. Repositories owned by `orchestra` returned 404 anonymously even with `private:false`. Changing a repository from internal to public appears to require instance-admin privileges. An account with private visibility cannot publish a public repository. A successful PATCH alone does not establish that Forgejo applied the requested state. This feature builds on `donach-main`, which contains the CLI. The requested `main` base contains only the initial README, so the comparison includes the existing CLI history.
Author
First-time contributor

Note for the reviewer: the second commit (2209ece) is pre-existing clippy cleanup across src/auth.rs, src/issues.rs, src/prs.rs, src/user.rs — unrelated to visibility, kept separate so it can be dropped when merging. The feature itself is ae64010.

Verified against the live instance with the built binary:

$ fj -H git.bitp.cz repo edit orchestra/harbour-kieli --visibility public
Repository visibility (private=false, internal=true)
Warning: Forgejo did not confirm the requested public repository visibility.

$ fj -H git.bitp.cz user edit visibility public --user orchestra
Error: 403 Forbidden: token does not have at least one of required scope(s): [write:admin]
Note for the reviewer: the second commit (`2209ece`) is pre-existing clippy cleanup across `src/auth.rs`, `src/issues.rs`, `src/prs.rs`, `src/user.rs` — unrelated to visibility, kept separate so it can be dropped when merging. The feature itself is `ae64010`. Verified against the live instance with the built binary: ``` $ fj -H git.bitp.cz repo edit orchestra/harbour-kieli --visibility public Repository visibility (private=false, internal=true) Warning: Forgejo did not confirm the requested public repository visibility. $ fj -H git.bitp.cz user edit visibility public --user orchestra Error: 403 Forbidden: token does not have at least one of required scope(s): [write:admin] ```
Owner

@hermes review

@hermes review
This pull request can be merged automatically.
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 repo-visibility:orchestra-repo-visibility
git switch orchestra-repo-visibility

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch donach-main
git merge --no-ff orchestra-repo-visibility
git switch orchestra-repo-visibility
git rebase donach-main
git switch donach-main
git merge --ff-only orchestra-repo-visibility
git switch orchestra-repo-visibility
git rebase donach-main
git switch donach-main
git merge --no-ff orchestra-repo-visibility
git switch donach-main
git merge --squash orchestra-repo-visibility
git switch donach-main
git merge --ff-only orchestra-repo-visibility
git switch donach-main
git merge orchestra-repo-visibility
git push origin donach-main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 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
donach/fj!13
No description provided.