Skip to content

Conversation

@luqven
Copy link
Owner

@luqven luqven commented Dec 29, 2025

Summary

Enable gh-stack log and gh-stack status to work without an explicit identifier by inferring the stack from the current branch's PR chain.

New Usage

# Infer stack from current branch (NEW)
gh-stack log
gh-stack status

# Infer from specific branch (NEW)
gh-stack log --branch feat/my-feature
gh-stack status --branch feat/my-feature

# List all stacks, select interactively (NEW)
gh-stack log --all
gh-stack status --all

# CI mode - requires identifier or --branch (NEW)
gh-stack log --branch $GITHUB_HEAD_REF --ci
gh-stack status --branch $GITHUB_HEAD_REF --ci --json

# Existing behavior still works
gh-stack log 'STACK-ID'
gh-stack status 'STACK-ID'

Changes

Modified: src/main.rs

New CLI arguments for log and status commands:

  • --branch, -b - Infer stack from specified branch instead of current
  • --all, -a - List all stacks and select interactively
  • --ci - Non-interactive mode for CI environments
  • --trunk - Override trunk branch detection (default: auto-detect or "main")

Behavior changes:

  • Running gh-stack log or gh-stack status without args infers from current branch
  • On trunk branch: prompts to enter identifier or select stack
  • No PR found: suggests gh pr create command with install hints
  • CI mode requires explicit identifier or --branch flag (fails otherwise)
  • JSON output mode handles errors gracefully with error field in response

Backwards Compatibility

The identifier argument is now optional but still fully supported. Existing scripts using gh-stack log 'STACK-ID' or gh-stack status 'STACK-ID' will continue to work unchanged.

Stacked PR Chain: smart-log

PR Title Merges Into
#35 feat: add stack discovery API -
#36 feat: add rate limit retry logic #35
#37 feat: add identifier detection and prompts #36
#38 feat: add gh CLI helpers #37
#39 👉feat: make log and status identifier optional with branch inference #38
#40 docs: update log and status documentation for smart defaults #39
#41 perf: optimize stack discovery with batch fetch #40
#42 perf: parallelize status check fetches #41

Enable gh-stack log to work without an explicit identifier by
inferring the stack from the current branch's PR chain.

New CLI arguments for log command:
- --branch, -b: Infer stack from specified branch
- --all, -a: List all stacks and select interactively
- --ci: Non-interactive mode for CI environments
- --trunk: Override trunk branch detection

Behavior changes:
- Running 'gh-stack log' without args infers from current branch
- On trunk branch: prompts to enter identifier or select stack
- No PR found: suggests gh pr create command
- CI mode requires explicit identifier or --branch flag

The identifier argument is now optional but still fully supported
for backwards compatibility.
Apply the same smart default behavior from log to status command:

New CLI arguments for status command:
- --branch, -b: Infer stack from specified branch
- --all, -a: List all stacks and select interactively
- --ci: Non-interactive mode for CI environments
- --trunk: Override trunk branch detection

The identifier argument is now optional. Running 'gh-stack status'
without args infers the stack from the current branch's PR chain.

JSON output mode handles errors gracefully with error field in response.
@luqven luqven changed the title [smart-log] feat: make log identifier optional with branch inference [smart-log] feat: make log and status identifier optional with branch inference Dec 29, 2025
@luqven
Copy link
Owner Author

luqven commented Dec 30, 2025

Landed via #42

@luqven luqven closed this Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants