Summary
Two related bugs when working with multiple git remotes, plus a CI improvement:
-
#44 : When a repo has multiple remotes (e.g.,
origin+upstream) and the current branch doesn't track any remote,fjerrors with "no repo info specified" instead of falling back toorigin. -
#46 :
pr createcrashes with a git2 config error when the current branch has no tracking remote, even after repo detection succeeds.
Changes
Remote auto-detection fallback (src/repo.rs)
- After checking for branch tracking and
--hosthost-matching, try theoriginremote as a last-resort fallback --hostmatching takes priority over the origin fallback (explicit user directive wins)- Includes
verbose_log!message so users can see the fallback in action
PR create tracking remote fallback (src/prs.rs)
- When
branch.<name>.remoteconfig is missing, fall back to the remote resolved byRepoInfo(ororigin) - When
branch.<name>.mergeconfig is missing, use the local branch name as the head branch - Includes
verbose_log!message for the fallback
CI (.forgejo/workflows/test.yml)
- Switch from
codeberg-mediumtocodeberg-smallrunner -- the build doesn't need the extra resources
Tests
tests/repo_info.rs: 3 new tests -- origin fallback works,--hostmatching takes priority over fallback, no-origin still errors. Refactored helper to support multiple remotes.tests/api_pr.rs: 1 new test -- PR create from untracked branch with multiple remotes succeeds. Usesbody_partial_jsonto verify the correct head branch name is sent to the API.
Test plan
cargo test --all-targetspasses (236 tests)cargo fmt -- --checkcleancargo clippy --all-targets -- -D warningsclean- Manual: checkout untracked branch with origin + upstream remotes, verify
fj repo viewandfj pr creatework without--remote
## Summary
Two related bugs when working with multiple git remotes, plus a CI improvement:
1. **#44**: When a repo has multiple remotes (e.g., `origin` + `upstream`) and the current branch doesn't track any remote, `fj` errors with "no repo info specified" instead of falling back to `origin`.
2. **#46**: `pr create` crashes with a git2 config error when the current branch has no tracking remote, even after repo detection succeeds.
## Changes
### Remote auto-detection fallback (`src/repo.rs`)
- After checking for branch tracking and `--host` host-matching, try the `origin` remote as a last-resort fallback
- `--host` matching takes priority over the origin fallback (explicit user directive wins)
- Includes `verbose_log!` message so users can see the fallback in action
### PR create tracking remote fallback (`src/prs.rs`)
- When `branch.<name>.remote` config is missing, fall back to the remote resolved by `RepoInfo` (or `origin`)
- When `branch.<name>.merge` config is missing, use the local branch name as the head branch
- Includes `verbose_log!` message for the fallback
### CI (`.forgejo/workflows/test.yml`)
- Switch from `codeberg-medium` to `codeberg-small` runner -- the build doesn't need the extra resources
### Tests
- **`tests/repo_info.rs`**: 3 new tests -- origin fallback works, `--host` matching takes priority over fallback, no-origin still errors. Refactored helper to support multiple remotes.
- **`tests/api_pr.rs`**: 1 new test -- PR create from untracked branch with multiple remotes succeeds. Uses `body_partial_json` to verify the correct head branch name is sent to the API.
## Test plan
- [x] `cargo test --all-targets` passes (236 tests)
- [x] `cargo fmt -- --check` clean
- [x] `cargo clippy --all-targets -- -D warnings` clean
- [x] Manual: checkout untracked branch with origin + upstream remotes, verify `fj repo view` and `fj pr create` work without `--remote`
Closes #44
Closes #46