Skip to content

Commit 499fdb8

Browse files
committed
adding more logging
1 parent 0386acd commit 499fdb8

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

cmd/link.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ func LinkCmd(cfg *config.Config) *cobra.Command {
2727
Long: `Create or update a stack on GitHub from branch names or PR numbers.
2828
2929
This command does not rely on gh-stack local tracking state. It is
30-
designed for users who manage branches with external tools (e.g. jj)
31-
and want to use GitHub stacked PRs without adopting local stack
32-
tracking.
30+
designed for users who manage branches with external tools (e.g. jj,
31+
Sapling, ghstack, git-town, etc...) and want to use GitHub stacked
32+
PRs without adopting local stack tracking.
3333
3434
Arguments are provided in stack order (bottom to top). Each argument
3535
can be a branch name or a PR number. For numeric arguments, the
@@ -83,6 +83,7 @@ func runLink(cfg *config.Config, opts *linkOptions, args []string) error {
8383
}
8484

8585
// Phase 2: Find existing PRs for all args (don't create yet)
86+
cfg.Printf("Looking up PRs for %d %s...", len(args), plural(len(args), "branch", "branches"))
8687
found, err := findExistingPRs(cfg, client, args)
8788
if err != nil {
8889
return err
@@ -97,6 +98,7 @@ func runLink(cfg *config.Config, opts *linkOptions, args []string) error {
9798
knownPRNumbers = append(knownPRNumbers, r.prNumber)
9899
}
99100
}
101+
cfg.Printf("Checking existing stacks...")
100102
stacks, err := listStacksSafe(cfg, client)
101103
if err != nil {
102104
return err
@@ -108,6 +110,15 @@ func runLink(cfg *config.Config, opts *linkOptions, args []string) error {
108110
}
109111

110112
// Phase 4: Create PRs for branches that don't have one yet
113+
needsCreation := 0
114+
for _, r := range found {
115+
if r == nil {
116+
needsCreation++
117+
}
118+
}
119+
if needsCreation > 0 {
120+
cfg.Printf("Creating %d %s...", needsCreation, plural(needsCreation, "PR", "PRs"))
121+
}
111122
resolved, err := createMissingPRs(cfg, client, opts, args, found)
112123
if err != nil {
113124
return err
@@ -290,8 +301,8 @@ func prevalidateStack(cfg *config.Config, stacks []github.RemoteStack, knownPRNu
290301
return nil
291302
}
292303

293-
// createMissingPRs creates PRs for args that don't have one yet.
294-
// Returns the fully resolved list with all args mapped to PRs.
304+
// createMissingPRs creates PRs for branches that don't have one yet.
305+
// Returns the fully resolved list with all branches mapped to PRs.
295306
func createMissingPRs(cfg *config.Config, client github.ClientOps, opts *linkOptions, args []string, found []*resolvedArg) ([]resolvedArg, error) {
296307
resolved := make([]resolvedArg, len(args))
297308

0 commit comments

Comments
 (0)