Skip to content

Commit b11e4d0

Browse files
committed
feat: hide unlisted-authors' branches by default when display_authors is set
Previously display_authors only dimmed branches from unlisted PR authors; status/interactive still showed every branch, which didn't scale in repos with many unrelated stacks. Now branches whose PR author isn't listed are hidden by default, with a --show-all flag to bypass it for one invocation. The current branch and its ancestor chain to trunk always stay visible, and branches with no PR yet are never hidden. Hiding is tree-aware: a hidden branch's visible descendants reparent for display to the nearest visible ancestor, without touching the underlying git-stack tree state.
1 parent c098049 commit b11e4d0

4 files changed

Lines changed: 384 additions & 104 deletions

File tree

src/github.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ pub struct GitHubConfig {
2323
pub token: String,
2424
pub api_base: String,
2525
/// GitHub usernames whose PRs should be displayed prominently in status.
26-
/// When non-empty, PRs from other authors will be shown dimmed/collapsed.
26+
/// When non-empty, branches whose PR author isn't listed are hidden from
27+
/// `status`/`interactive`, except the current branch, its ancestor chain to trunk, and
28+
/// branches with no PR yet. `--show-all` bypasses this for one invocation.
2729
/// No longer used for filtering during sync.
2830
pub display_authors: Vec<String>,
2931
}
@@ -906,7 +908,9 @@ struct GitHubConfigFile {
906908
default_token: Option<String>,
907909
hosts: Option<std::collections::HashMap<String, String>>,
908910
/// GitHub usernames whose PRs should be displayed prominently in status.
909-
/// When set, PRs from other authors will be shown dimmed/collapsed.
911+
/// When non-empty, branches whose PR author isn't listed are hidden from
912+
/// `status`/`interactive`, except the current branch, its ancestor chain to trunk, and
913+
/// branches with no PR yet. `--show-all` bypasses this for one invocation.
910914
#[serde(default)]
911915
display_authors: Vec<String>,
912916
/// OAuth device-flow token (distinct from `default_token`, which holds a PAT).

src/llms.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ itself has no notion of the stack; `git-stack` is the bookkeeping that remembers
125125

126126
Global flags (valid on any subcommand): `-v`/`--verbose`, `--benchmark` (print
127127
git-command timing stats), `--json` (emit those stats as JSON, implies
128-
`--benchmark`).
128+
`--benchmark`), `--show-all` (bypasses `display_authors`-based hiding for this
129+
invocation).
129130

130131
## 4. State file
131132

@@ -220,6 +221,12 @@ PR columns in `status`) need a token. Config lives at
220221
Graceful degradation: with **no** resolvable token, read-only commands still
221222
work — `git stack status` renders the tree, just without PR numbers/state.
222223

224+
`display_authors` (list of GitHub logins) in `github.yaml` — when non-empty,
225+
`status`/`interactive` hide branches whose PR author isn't listed, except the
226+
current branch and its ancestor chain to trunk, and any branch with no PR yet.
227+
A hidden branch's visible descendants reparent to the nearest visible ancestor
228+
for display purposes only. `--show-all` disables this for one invocation.
229+
223230
## 7. PR workflow
224231

225232
- **`git stack pr create`** creates a GitHub PR for the current branch (or `-b`)

src/main.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ struct Args {
4242
)]
4343
json: bool,
4444

45+
#[arg(
46+
long,
47+
global = true,
48+
help = "Show all branches, bypassing display_authors-based hiding"
49+
)]
50+
show_all: bool,
51+
4552
/// Subcommand to run.
4653
#[command(subcommand)]
4754
command: Option<Command>,
@@ -416,11 +423,19 @@ fn inner_main() -> Result<()> {
416423
&current_branch,
417424
fetch,
418425
args.verbose,
426+
args.show_all,
419427
)
420428
}
421429
Some(Command::Interactive) => {
422430
state.try_auto_mount(&git_repo, &repo, &current_branch)?;
423-
interactive(&git_repo, state, &repo, &current_branch, args.verbose)
431+
interactive(
432+
&git_repo,
433+
state,
434+
&repo,
435+
&current_branch,
436+
args.verbose,
437+
args.show_all,
438+
)
424439
}
425440
Some(Command::Up) => {
426441
state.try_auto_mount(&git_repo, &repo, &current_branch)?;
@@ -483,6 +498,7 @@ fn inner_main() -> Result<()> {
483498
&current_branch,
484499
false,
485500
args.verbose,
501+
args.show_all,
486502
)
487503
}
488504
}
@@ -564,6 +580,7 @@ fn status(
564580
orig_branch: &str,
565581
fetch: bool,
566582
verbose: bool,
583+
show_all: bool,
567584
) -> Result<()> {
568585
if fetch {
569586
git_fetch()?;
@@ -593,6 +610,7 @@ fn status(
593610
verbose,
594611
pr_cache.as_ref(),
595612
&display_authors,
613+
show_all,
596614
);
597615

598616
// Render to CLI
@@ -616,6 +634,7 @@ fn interactive(
616634
repo: &str,
617635
orig_branch: &str,
618636
verbose: bool,
637+
show_all: bool,
619638
) -> Result<()> {
620639
// ensure_trunk creates the tree if it doesn't exist (no-op if no remote)
621640
let _trunk = state.ensure_trunk(git_repo, repo);
@@ -642,6 +661,7 @@ fn interactive(
642661
verbose,
643662
pr_cache.as_ref(),
644663
&display_authors,
664+
show_all,
645665
);
646666

647667
// Run TUI and handle checkout if user selected a branch

0 commit comments

Comments
 (0)