forgejo-cli-ops

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Scope

适用范围

  • Authenticate to a Forgejo host and verify access.
  • Run common issue/PR/repo commands with the correct host.
  • Troubleshoot host and login mismatches.
  • 登录Forgejo主机并验证访问权限。
  • 使用正确的主机运行常见的议题/拉取请求/仓库命令。
  • 排查主机与登录不匹配的问题。

Prerequisites

前提条件

  • A Forgejo Personal Access Token (PAT) created in the Forgejo web UI.
  • fj
    installed and available in PATH.
  • Optional:
    secret-tool
    (GNOME Keyring) for secure token storage.
  • 在Forgejo网页界面中创建的Forgejo个人访问令牌(PAT)。
  • 已安装
    fj
    并可在PATH中访问。
  • 可选:
    secret-tool
    (GNOME密钥环)用于安全存储令牌。

Host usage (important)

主机使用方式(重要)

-H/--host
is a global option and must be placed before subcommands.
bash
fj -H <FORGEJO_HOST> repo view <owner>/<repo>
To avoid repeating the host, set
FJ_HOST
:
bash
export FJ_HOST=<FORGEJO_HOST>
-H/--host
全局选项,必须放在子命令之前
bash
fj -H <FORGEJO_HOST> repo view <owner>/<repo>
为避免重复输入主机,可设置
FJ_HOST
环境变量:
bash
export FJ_HOST=<FORGEJO_HOST>

Authentication (secret-tool example)

身份验证(secret-tool示例)

Store your token (one-time) and register with fj:
bash
echo -n "<PAT_VALUE>" | secret-tool store --label="Forgejo PAT" service forgejo user <username>@<FORGEJO_HOST>
echo -n "$(secret-tool lookup service forgejo user <username>@<FORGEJO_HOST>)" | fj -H <FORGEJO_HOST> auth add-key <username>
Verify:
bash
fj -H <FORGEJO_HOST> auth list
fj -H <FORGEJO_HOST> whoami
一次性存储令牌并在fj中注册:
bash
echo -n "<PAT_VALUE>" | secret-tool store --label="Forgejo PAT" service forgejo user <username>@<FORGEJO_HOST>
echo -n "$(secret-tool lookup service forgejo user <username>@<FORGEJO_HOST>)" | fj -H <FORGEJO_HOST> auth add-key <username>
验证:
bash
fj -H <FORGEJO_HOST> auth list
fj -H <FORGEJO_HOST> whoami

Cleanup

清理操作

bash
fj auth logout <FORGEJO_HOST>
secret-tool clear service forgejo user <username>@<FORGEJO_HOST>
bash
fj auth logout <FORGEJO_HOST>
secret-tool clear service forgejo user <username>@<FORGEJO_HOST>

Troubleshooting

故障排查

  • Error: not logged in
    often means the host defaulted to github.com; add
    -H
    or set
    FJ_HOST
    .
  • If
    secret-tool lookup
    returns nothing, unlock your keyring or confirm the stored user/host key.
  • 若出现
    Error: not logged in
    错误,通常意味着主机默认设为github.com;请添加
    -H
    选项或设置
    FJ_HOST
    环境变量。
  • secret-tool lookup
    无返回结果,请解锁密钥环或确认存储的用户/主机密钥是否正确。