Follow-up to #1 (merged), continuing on the same branch, addressing review
feedback and a follow-up request:
Read GITEA_TOKEN from a dedicated file (~/.config/gitea/token,
chmod 600) instead of a global exported shell variable, so the token
isn't visible to every process in every shell — only to gitea-pr itself. GITEA_TOKEN env var still works as a one-off override. Migrated the
existing token out of ~/.profile.local into the new file as part of
this change.
gitea-pr create now checks for an existing open PR on the current
branch before creating a new one (GET .../pulls?state=open, matched on head.ref), returning the existing PR's URL instead of creating a
duplicate. Note: this only matches open PRs by design — once a PR is
merged, new commits on the same branch correctly get a new PR, which is
exactly how PR #2 itself came to exist.
Testing: shellcheck clean (-e SC2029 -e SC2155) on both commits. Live-
tested against the real server: confirmed the missing-token error message,
confirmed comments/reviews still fetch correctly via the new token-file path,
and confirmed the existing-PR check both short-circuits correctly (verified
against this same open PR after creation) and still creates a fresh PR when
none is open.
Follow-up to #1 (merged), continuing on the same branch, addressing review
feedback and a follow-up request:
1. **Read GITEA_TOKEN from a dedicated file** (`~/.config/gitea/token`,
chmod 600) instead of a global exported shell variable, so the token
isn't visible to every process in every shell — only to gitea-pr itself.
`GITEA_TOKEN` env var still works as a one-off override. Migrated the
existing token out of `~/.profile.local` into the new file as part of
this change.
2. **`gitea-pr create` now checks for an existing open PR** on the current
branch before creating a new one (GET .../pulls?state=open, matched on
`head.ref`), returning the existing PR's URL instead of creating a
duplicate. Note: this only matches *open* PRs by design — once a PR is
merged, new commits on the same branch correctly get a new PR, which is
exactly how PR #2 itself came to exist.
**Testing:** shellcheck clean (`-e SC2029 -e SC2155`) on both commits. Live-
tested against the real server: confirmed the missing-token error message,
confirmed comments/reviews still fetch correctly via the new token-file path,
and confirmed the existing-PR check both short-circuits correctly (verified
against this same open PR after creation) and still creates a fresh PR when
none is open.
branderson
changed title from should not matter to gitea-pr: token-file auth + skip duplicate PR creation2026-07-12 22:03:28 -07:00
gitea-pr create now checks for an existing open PR on the current
branch first and returns its URL instead of creating a new one. Only
matches open PRs by design -- once merged, new commits on the same
branch correctly get a new PR.
The lookup was matching on head.ref alone, so running create with a
different --base for the same branch would silently return an
unrelated PR's URL instead of opening a new one. Resolve base before
the check and filter on both head.ref and base.ref.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Follow-up to #1 (merged), continuing on the same branch, addressing review
feedback and a follow-up request:
Read GITEA_TOKEN from a dedicated file (
~/.config/gitea/token,chmod 600) instead of a global exported shell variable, so the token
isn't visible to every process in every shell — only to gitea-pr itself.
GITEA_TOKENenv var still works as a one-off override. Migrated theexisting token out of
~/.profile.localinto the new file as part ofthis change.
gitea-pr createnow checks for an existing open PR on the currentbranch before creating a new one (GET .../pulls?state=open, matched on
head.ref), returning the existing PR's URL instead of creating aduplicate. Note: this only matches open PRs by design — once a PR is
merged, new commits on the same branch correctly get a new PR, which is
exactly how PR #2 itself came to exist.
Testing: shellcheck clean (
-e SC2029 -e SC2155) on both commits. Live-tested against the real server: confirmed the missing-token error message,
confirmed comments/reviews still fetch correctly via the new token-file path,
and confirmed the existing-PR check both short-circuits correctly (verified
against this same open PR after creation) and still creates a fresh PR when
none is open.
should not matterto gitea-pr: token-file auth + skip duplicate PR creation7436311022to06e60bda8c