Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func runAdopt(cmd *cobra.Command, args []string) error {
return err
}

cfg, err := config.Load(cwd)
g := git.New(cwd)

cfg, err := config.New(g)
if err != nil {
return err
}

g := git.New(cwd)

// Parent is the required positional argument
parent := args[0]

Expand Down
10 changes: 5 additions & 5 deletions cmd/adopt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
func TestAdoptBranch(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand All @@ -40,8 +40,8 @@ func TestAdoptBranch(t *testing.T) {
func TestAdoptRejectsAlreadyTracked(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand All @@ -60,8 +60,8 @@ func TestAdoptRejectsAlreadyTracked(t *testing.T) {
func TestAdoptRejectsUntrackedParent(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand All @@ -81,8 +81,8 @@ func TestAdoptRejectsUntrackedParent(t *testing.T) {
func TestAdoptDetectsCycle(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand Down Expand Up @@ -117,8 +117,8 @@ func TestAdoptDetectsCycle(t *testing.T) {
func TestAdoptStoresForkPoint(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand Down
6 changes: 3 additions & 3 deletions cmd/cascade.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func runCascade(cmd *cobra.Command, args []string) error {
return err
}

cfg, err := config.Load(cwd)
g := git.New(cwd)

cfg, err := config.New(g)
if err != nil {
return err
}

g := git.New(cwd)

// Check if cascade already in progress
if state.Exists(g.GetGitDir()) {
return errors.New("operation already in progress; use 'gh stack continue' or 'gh stack abort'")
Expand Down
2 changes: 1 addition & 1 deletion cmd/continue.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func runContinue(cmd *cobra.Command, args []string) error {

fmt.Printf("%s Completed %s\n", s.SuccessIcon(), s.Branch(st.Current))

cfg, err := config.Load(cwd)
cfg, err := config.New(g)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func runCreate(cmd *cobra.Command, args []string) error {
return err
}

cfg, err := config.Load(cwd)
g := git.New(cwd)

cfg, err := config.New(g)
if err != nil {
return err
}

g := git.New(cwd)

// Get current branch
currentBranch, err := g.CurrentBranch()
if err != nil {
Expand Down
15 changes: 7 additions & 8 deletions cmd/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import (
func TestCreateFromTrunk(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
cfg.SetTrunk("main")

g := git.New(dir)
cfg, _ := config.New(g)
cfg.SetTrunk("main")

// Simulate what create command does
currentBranch, _ := g.CurrentBranch()
Expand Down Expand Up @@ -57,8 +56,8 @@ func TestCreateFromTrunk(t *testing.T) {
func TestCreateFromTrackedBranch(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

currentBranch, _ := g.CurrentBranch()
cfg.SetTrunk(currentBranch)
Expand Down Expand Up @@ -86,8 +85,8 @@ func TestCreateFromTrackedBranch(t *testing.T) {
func TestCreateRejectsUntrackedBranch(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand Down Expand Up @@ -119,8 +118,8 @@ func TestCreateRejectsUntrackedBranch(t *testing.T) {
func TestCreateWithStagedChanges(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand Down Expand Up @@ -151,8 +150,8 @@ func TestCreateWithStagedChanges(t *testing.T) {
func TestCreateEmptyWithStagedChanges(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand Down Expand Up @@ -197,8 +196,8 @@ func TestBranchAlreadyExists(t *testing.T) {
func TestCreateStoresForkPoint(t *testing.T) {
dir := setupTestRepo(t)

cfg, _ := config.Load(dir)
g := git.New(dir)
cfg, _ := config.New(g)

trunk, _ := g.CurrentBranch()
cfg.SetTrunk(trunk)
Expand Down
Loading