Skip to content

Add compatibility with jj (Jujutsu VCS) #268

@chicks-net

Description

@chicks-net

Summary

gh-observer currently assumes the user is working in a git repository and relies on gh pr view for auto-detecting the current PR. Users of jj (Jujutsu) — a Git-compatible VCS — may hit issues because jj's internal working copy model differs from git's, even though jj interoperates with git remotes.

Problem Areas

1. PR auto-detection fails (GetCurrentPR / GetCurrentPRWithRepo)

Both functions in internal/github/pr.go shell out to gh pr view --json number,url, which in turn inspects the current git branch. jj doesn't create a traditional git working tree or HEAD ref in the same way, so gh pr view may fail or return unexpected results.

  • GetCurrentPR() — line 32
  • GetCurrentPRWithRepo() — line 83

2. Remote URL parsing may fail

parseOwnerRepoFromURL() in internal/github/pr.go:106 reads git remote origin via the git config. jj can work without a traditional .git directory structure, so remote discovery could break.

3. Branch model assumptions

jj uses a "working copy commit" model instead of git branches. The concept of "current branch" maps differently, which affects any logic that assumes a 1:1 mapping between a branch name and a PR.

Suggested Approach

  • Detect when running inside a jj repo (e.g., check for .jj/ directory or jj on $PATH with jj root succeeding).
  • When jj is detected, convert jj operations to equivalent git operations jj supports (e.g., jj git remote list instead of git remote -v, jj log to determine the current change/branch).
  • Alternatively, support a fallback where the user can explicitly pass --owner/repo or --pr-url when auto-detection fails (partially covered by existing positional args, but could be more ergonomic).
  • Consider using jj's native jj git subcommands where they map 1:1.

Workaround

Users can currently work around this by passing a full PR URL or PR number explicitly:

gh-observer https://github.com/owner/repo/pull/123
gh-observer 123

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions