-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add driver abstraction for PR stacking tool support #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nvandessel
wants to merge
8
commits into
main
Choose a base branch
from
feature/frond-graphite
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a79341
feat: add driver abstraction for PR stacking tool support
nvandessel ad7b13e
fix: address self-review findings
nvandessel a54a28d
fix: parse gt submit output for PR numbers, remove gh dependency
nvandessel d523a8f
fix: address code review findings
nvandessel aa00a72
test: add sandbox integration tests for Graphite driver
nvandessel da84d19
feat: make stack comments driver-aware via SupportsStackComments
nvandessel 64e9bf3
fix: use driver's Checkout method instead of git.Checkout directly
nvandessel b4a8e5e
Merge branch 'main' into feature/frond-graphite
nvandessel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/nvandessel/frond/internal/driver" | ||
| "github.com/nvandessel/frond/internal/state" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var initCmd = &cobra.Command{ | ||
| Use: "init", | ||
| Short: "Initialize frond state with an optional driver", | ||
| Example: ` # Initialize with the default native driver | ||
| frond init | ||
|
|
||
| # Initialize with the Graphite driver | ||
| frond init --driver graphite`, | ||
| RunE: runInit, | ||
| } | ||
|
|
||
| func init() { | ||
| initCmd.Flags().String("driver", "", "Driver to use: native (default), graphite") | ||
| rootCmd.AddCommand(initCmd) | ||
| } | ||
|
|
||
| func runInit(cmd *cobra.Command, args []string) error { | ||
| ctx := cmd.Context() | ||
| driverName, _ := cmd.Flags().GetString("driver") | ||
|
|
||
| // Validate the driver is known and its CLI is available. | ||
| drv, err := driver.Resolve(driverName) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Lock state. | ||
| unlock, err := state.Lock(ctx) | ||
| if err != nil { | ||
| return fmt.Errorf("acquiring lock: %w", err) | ||
| } | ||
| defer unlock() | ||
|
|
||
| // ReadOrInit creates state if needed. | ||
| s, err := state.ReadOrInit(ctx) | ||
| if err != nil { | ||
| return fmt.Errorf("reading state: %w", err) | ||
| } | ||
|
|
||
| // Set the driver if specified (or clear to native default). | ||
| if driverName == "native" { | ||
| driverName = "" | ||
| } | ||
| s.Driver = driverName | ||
|
|
||
| if err := state.Write(ctx, s); err != nil { | ||
| return fmt.Errorf("writing state: %w", err) | ||
| } | ||
|
|
||
| if jsonOut { | ||
| return printJSON(initResult{ | ||
| Driver: drv.Name(), | ||
| Trunk: s.Trunk, | ||
| }) | ||
| } | ||
| fmt.Printf("Initialized frond (driver: %s, trunk: %s)\n", drv.Name(), s.Trunk) | ||
| return nil | ||
| } | ||
|
|
||
| type initResult struct { | ||
| Driver string `json:"driver"` | ||
| Trunk string `json:"trunk"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR number silently dropped for Graphite
(updated)resultWith the Graphite driver,
gt submitalways submits the entire stack. When a user first pushes branch B (downstream),gt submitcreates PRs for both branch A and branch B — but frond only records the PR number for branch B (since that isopts.Branch). Later, when the user runsfrond pushon branch A,gt submitoutputs(updated)for branch A because its PR already exists on GitHub.parseSubmitResultcorrectly extracts the PR number, butresult.Createdisfalse, so this block is skipped and the PR number is never persisted to state.This leaves branch A's
br.PR == nilpermanently, so futurefrond status --fetchandfrond syncoperations cannot see or retarget the PR.The condition should also save the number when frond doesn't yet have a record of the PR (
br.PR == nil):