Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
832fd56
refactor(plan): use gion-core planner diff
tasuku43 Feb 4, 2026
c0daaa3
refactor(apply): delegate destructive checks to gion-core
tasuku43 Feb 4, 2026
f64aeac
refactor(apply): use gion-core execution ordering
tasuku43 Feb 4, 2026
887e467
refactor(apply): use gion-core prefetch repo keys
tasuku43 Feb 4, 2026
6f4cdce
refactor(apply): move base branch helper to gion-core
tasuku43 Feb 4, 2026
cdefe35
refactor(repospec): delegate parser to gion-core
tasuku43 Feb 4, 2026
daa4926
refactor(repospec): route display helpers through gion-core
tasuku43 Feb 4, 2026
c2f51fc
refactor(repo): use gion-core repostore helpers
tasuku43 Feb 4, 2026
572ce62
refactor(git): use gion-core remote HEAD parser
tasuku43 Feb 4, 2026
61f6275
refactor(gc): use gion-core remote branch parser
tasuku43 Feb 4, 2026
c4a32b4
refactor(repo): use gion-core worktree parser
tasuku43 Feb 4, 2026
b1cb157
refactor(import): use gion-core importplan
tasuku43 Feb 4, 2026
967e853
refactor(manifestls): use gion-core drift planner
tasuku43 Feb 4, 2026
33daaf7
refactor(manifestls): use gion-core risk aggregation
tasuku43 Feb 4, 2026
7b03aaa
refactor(gc): use gion-core fetch planner
tasuku43 Feb 4, 2026
011ba54
refactor(git): use gion-core origin HEAD helpers
tasuku43 Feb 4, 2026
98c4d78
refactor(repo): use gion-core fetch-head helpers
tasuku43 Feb 4, 2026
bde8c88
refactor(repo): use gion-core head prune planner
tasuku43 Feb 4, 2026
44fcd8a
refactor(repo): delegate store normalization to gion-core
tasuku43 Feb 4, 2026
c07acce
refactor(gc): use gion-core merge-check refs
tasuku43 Feb 4, 2026
d7d27b2
refactor(repo): use gion-core store access flow
tasuku43 Feb 4, 2026
efdd366
ci: fetch gion-core for local replace dependency
tasuku43 Feb 4, 2026
acb01a1
refactor(repo): remove unused local hash helpers
tasuku43 Feb 4, 2026
478e925
refactor(workspace): use gion-core status parser
tasuku43 Feb 4, 2026
b231177
refactor(workspace): delegate repo risk classification
tasuku43 Feb 4, 2026
6a7ebcb
refactor(gc): use gion-core strict merge checker
tasuku43 Feb 4, 2026
91ed319
refactor(gc): delegate fetch orchestration to gion-core
tasuku43 Feb 4, 2026
9b965fe
refactor(workspace): use gion-core state aggregation
tasuku43 Feb 4, 2026
bbdf39f
ci: pin gion-core ref for dependency checkout
tasuku43 Feb 5, 2026
2bd730b
chore(deps): pin gion-core to v0.1.0
tasuku43 Feb 5, 2026
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
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ require (
github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.0
github.com/charmbracelet/x/ansi v0.10.1
github.com/mattn/go-isatty v0.0.20
github.com/muesli/termenv v0.16.0
github.com/pmezard/go-difflib v1.0.0
github.com/tasuku43/gion-core v0.1.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/x/ansi v0.10.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
Expand All @@ -23,8 +26,6 @@ require (
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/tasuku43/gion-core v0.1.0 h1:qM9lKdYaEikZHrAzxg9jUe0Tzuzk93PABK+MY4pn8hA=
github.com/tasuku43/gion-core v0.1.0/go.mod h1:yfrhcgAMaFzkNJ01E7wTlM+PZ85HrqLma6p+3hfTdik=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
Expand Down
87 changes: 32 additions & 55 deletions internal/app/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"
"time"

coreapplyplan "github.com/tasuku43/gion-core/applyplan"
"github.com/tasuku43/gion/internal/app/add"
"github.com/tasuku43/gion/internal/app/create"
"github.com/tasuku43/gion/internal/app/manifestplan"
Expand All @@ -26,7 +27,9 @@ type Options struct {
}

func Apply(ctx context.Context, rootDir string, plan manifestplan.Result, opts Options) error {
for _, change := range plan.Changes {
execPlan := coreapplyplan.BuildExecution(plan.Changes)

for _, change := range execPlan.WorkspaceRemovals {
if change.Kind != manifestplan.WorkspaceRemove {
continue
}
Expand All @@ -36,28 +39,39 @@ func Apply(ctx context.Context, rootDir string, plan manifestplan.Result, opts O
}
}

for _, change := range plan.Changes {
for _, change := range execPlan.WorkspaceUpdateRemovals {
if change.Kind != manifestplan.WorkspaceUpdate {
continue
}
if err := applyRepoRemovals(ctx, rootDir, change, opts); err != nil {
return err
}
}

for _, change := range execPlan.WorkspaceUpdateRenames {
if change.Kind != manifestplan.WorkspaceUpdate {
continue
}
if err := applyRepoBranchRenames(ctx, rootDir, change, opts.Step); err != nil {
return err
}
}

for _, change := range plan.Changes {
switch change.Kind {
case manifestplan.WorkspaceAdd:
if err := applyWorkspaceAdd(ctx, rootDir, plan.Desired, change, opts); err != nil {
return err
}
case manifestplan.WorkspaceUpdate:
if err := applyRepoAdds(ctx, rootDir, plan.Desired, change, opts); err != nil {
return err
}
for _, change := range execPlan.WorkspaceAdds {
if change.Kind != manifestplan.WorkspaceAdd {
continue
}
if err := applyWorkspaceAdd(ctx, rootDir, plan.Desired, change, opts); err != nil {
return err
}
}

for _, change := range execPlan.WorkspaceUpdateAdds {
if change.Kind != manifestplan.WorkspaceUpdate {
continue
}
if err := applyRepoAdds(ctx, rootDir, plan.Desired, change, opts); err != nil {
return err
}
}

Expand Down Expand Up @@ -98,7 +112,7 @@ func applyWorkspaceAdd(ctx context.Context, rootDir string, desired manifest.Fil
return err
}
if createdBranch {
baseBranchToRecord, baseBranchMixed = updateBaseBranchCandidate(baseBranchToRecord, baseBranchMixed, baseBranch)
baseBranchToRecord, baseBranchMixed = coreapplyplan.UpdateBaseBranchCandidate(baseBranchToRecord, baseBranchMixed, baseBranch)
}
}
if baseBranchMixed {
Expand Down Expand Up @@ -155,7 +169,7 @@ func applyRepoRemovals(ctx context.Context, rootDir string, change manifestplan.
for _, repoChange := range change.Repos {
switch repoChange.Kind {
case manifestplan.RepoRemove, manifestplan.RepoUpdate:
if canRenameRepoBranchInPlace(repoChange) {
if coreapplyplan.IsInPlaceBranchRename(repoChange) {
continue
}
logStep(opts.Step, fmt.Sprintf("worktree remove %s", repoChange.Alias))
Expand All @@ -172,7 +186,7 @@ func applyRepoRemovals(ctx context.Context, rootDir string, change manifestplan.

func applyRepoBranchRenames(ctx context.Context, rootDir string, change manifestplan.WorkspaceChange, step func(text string)) error {
for _, repoChange := range change.Repos {
if !canRenameRepoBranchInPlace(repoChange) {
if !coreapplyplan.IsInPlaceBranchRename(repoChange) {
continue
}
worktreePath := workspace.WorktreePath(rootDir, change.WorkspaceID, repoChange.Alias)
Expand Down Expand Up @@ -210,10 +224,10 @@ func applyRepoAdds(ctx context.Context, rootDir string, desired manifest.File, c
return err
}
if createdBranch {
baseBranchToRecord, baseBranchMixed = updateBaseBranchCandidate(baseBranchToRecord, baseBranchMixed, baseBranch)
baseBranchToRecord, baseBranchMixed = coreapplyplan.UpdateBaseBranchCandidate(baseBranchToRecord, baseBranchMixed, baseBranch)
}
case manifestplan.RepoUpdate:
if canRenameRepoBranchInPlace(repoChange) {
if coreapplyplan.IsInPlaceBranchRename(repoChange) {
continue
}
logStep(opts.Step, fmt.Sprintf("worktree add %s", repoChange.Alias))
Expand All @@ -223,7 +237,7 @@ func applyRepoAdds(ctx context.Context, rootDir string, desired manifest.File, c
return err
}
if createdBranch {
baseBranchToRecord, baseBranchMixed = updateBaseBranchCandidate(baseBranchToRecord, baseBranchMixed, baseBranch)
baseBranchToRecord, baseBranchMixed = coreapplyplan.UpdateBaseBranchCandidate(baseBranchToRecord, baseBranchMixed, baseBranch)
}
}
}
Expand All @@ -236,43 +250,6 @@ func applyRepoAdds(ctx context.Context, rootDir string, desired manifest.File, c
return nil
}

func updateBaseBranchCandidate(candidate string, mixed bool, baseBranch string) (string, bool) {
if mixed {
return candidate, mixed
}
baseBranch = strings.TrimSpace(baseBranch)
if baseBranch == "" {
return candidate, mixed
}
if candidate == "" {
return baseBranch, mixed
}
if candidate != baseBranch {
return candidate, true
}
return candidate, mixed
}

func canRenameRepoBranchInPlace(change manifestplan.RepoChange) bool {
if change.Kind != manifestplan.RepoUpdate {
return false
}
fromRepo := strings.TrimSpace(change.FromRepo)
toRepo := strings.TrimSpace(change.ToRepo)
fromBranch := strings.TrimSpace(change.FromBranch)
toBranch := strings.TrimSpace(change.ToBranch)
if fromRepo == "" || toRepo == "" || fromBranch == "" || toBranch == "" {
return false
}
if fromRepo != toRepo {
return false
}
if fromBranch == toBranch {
return false
}
return true
}

func logStep(step func(text string), text string) {
if step == nil {
return
Expand Down
8 changes: 6 additions & 2 deletions internal/app/apply/apply_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package apply

import "testing"
import (
"testing"

coreapplyplan "github.com/tasuku43/gion-core/applyplan"
)

func TestUpdateBaseBranchCandidate(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -55,7 +59,7 @@ func TestUpdateBaseBranchCandidate(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotCandidate, gotMixed := updateBaseBranchCandidate(tt.candidate, tt.mixed, tt.input)
gotCandidate, gotMixed := coreapplyplan.UpdateBaseBranchCandidate(tt.candidate, tt.mixed, tt.input)
if gotCandidate != tt.wantCandidate {
t.Fatalf("candidate: got %q, want %q", gotCandidate, tt.wantCandidate)
}
Expand Down
49 changes: 36 additions & 13 deletions internal/app/manifestimport/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"context"
"fmt"
"os"
"sort"
"strings"

coreimportplan "github.com/tasuku43/gion-core/importplan"
"github.com/tasuku43/gion/internal/domain/manifest"
"github.com/tasuku43/gion/internal/domain/workspace"
"github.com/tasuku43/gion/internal/infra/paths"
Expand Down Expand Up @@ -52,14 +52,16 @@ func Build(ctx context.Context, rootDir string) (manifest.File, []error, error)
}
var warnings []error

var workspaceIDs []string
var workspaceNames []string
for _, entry := range entries {
if !entry.IsDir() {
continue
}
workspaceIDs = append(workspaceIDs, entry.Name())
workspaceNames = append(workspaceNames, entry.Name())
}
sort.Strings(workspaceIDs)
workspaceIDs := coreimportplan.CollectWorkspaceIDs(workspaceNames)

snapshots := make([]coreimportplan.WorkspaceSnapshot, 0, len(workspaceIDs))

for _, wsID := range workspaceIDs {
wsDir := workspace.WorkspaceDir(rootDir, wsID)
Expand All @@ -79,28 +81,26 @@ func Build(ctx context.Context, rootDir string) (manifest.File, []error, error)
}
}

repoEntries := make([]manifest.Repo, 0, len(repos))
repoEntries := make([]coreimportplan.RepoSnapshot, 0, len(repos))
for _, repoEntry := range repos {
repoEntries = append(repoEntries, manifest.Repo{
repoEntries = append(repoEntries, coreimportplan.RepoSnapshot{
Alias: strings.TrimSpace(repoEntry.Alias),
RepoKey: strings.TrimSpace(repoEntry.RepoKey),
Branch: strings.TrimSpace(repoEntry.Branch),
BaseRef: strings.TrimSpace(meta.BaseBranch),
})
}
sort.Slice(repoEntries, func(i, j int) bool {
return repoEntries[i].Alias < repoEntries[j].Alias
})

wsEntry := manifest.Workspace{
snapshots = append(snapshots, coreimportplan.WorkspaceSnapshot{
ID: wsID,
Description: strings.TrimSpace(meta.Description),
Mode: strings.TrimSpace(meta.Mode),
PresetName: strings.TrimSpace(meta.PresetName),
SourceURL: strings.TrimSpace(meta.SourceURL),
BaseBranch: strings.TrimSpace(meta.BaseBranch),
Repos: repoEntries,
}
file.Workspaces[wsID] = wsEntry
})
}
file.Workspaces = toManifestWorkspaces(coreimportplan.BuildInventory(snapshots).Workspaces)

return file, warnings, nil
}
Expand All @@ -119,3 +119,26 @@ func Write(rootDir string, file manifest.File, warnings []error) (Result, error)
func Path(rootDir string) string {
return manifest.Path(rootDir)
}

func toManifestWorkspaces(workspaces map[string]coreimportplan.Workspace) map[string]manifest.Workspace {
converted := make(map[string]manifest.Workspace, len(workspaces))
for id, ws := range workspaces {
repos := make([]manifest.Repo, 0, len(ws.Repos))
for _, repoEntry := range ws.Repos {
repos = append(repos, manifest.Repo{
Alias: repoEntry.Alias,
RepoKey: repoEntry.RepoKey,
Branch: repoEntry.Branch,
BaseRef: repoEntry.BaseRef,
})
}
converted[id] = manifest.Workspace{
Description: ws.Description,
Mode: ws.Mode,
PresetName: ws.PresetName,
SourceURL: ws.SourceURL,
Repos: repos,
}
}
return converted
}
Loading