← back to joescharf__wt

Function bodies 244 total

All specs Real LLM only Function bodies
mocks.NewMockCleanupFunc function · go · L69-L79 (11 LOC)
pkg/ops/mocks/mock_CleanupFunc.go
func NewMockCleanupFunc(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockCleanupFunc {
	mock := &MockCleanupFunc{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockLogger.Info method · go · L21-L26 (6 LOC)
pkg/ops/mocks/mock_Logger.go
func (_m *MockLogger) Info(format string, args ...interface{}) {
	var _ca []interface{}
	_ca = append(_ca, format)
	_ca = append(_ca, args...)
	_m.Called(_ca...)
}
mocks.MockLogger_Info_Call.Run method · go · L41-L52 (12 LOC)
pkg/ops/mocks/mock_Logger.go
func (_c *MockLogger_Info_Call) Run(run func(format string, args ...interface{})) *MockLogger_Info_Call {
	_c.Call.Run(func(args mock.Arguments) {
		variadicArgs := make([]interface{}, len(args)-1)
		for i, a := range args[1:] {
			if a != nil {
				variadicArgs[i] = a.(interface{})
			}
		}
		run(args[0].(string), variadicArgs...)
	})
	return _c
}
mocks.MockLogger.Success method · go · L65-L70 (6 LOC)
pkg/ops/mocks/mock_Logger.go
func (_m *MockLogger) Success(format string, args ...interface{}) {
	var _ca []interface{}
	_ca = append(_ca, format)
	_ca = append(_ca, args...)
	_m.Called(_ca...)
}
mocks.MockLogger_Success_Call.Run method · go · L85-L96 (12 LOC)
pkg/ops/mocks/mock_Logger.go
func (_c *MockLogger_Success_Call) Run(run func(format string, args ...interface{})) *MockLogger_Success_Call {
	_c.Call.Run(func(args mock.Arguments) {
		variadicArgs := make([]interface{}, len(args)-1)
		for i, a := range args[1:] {
			if a != nil {
				variadicArgs[i] = a.(interface{})
			}
		}
		run(args[0].(string), variadicArgs...)
	})
	return _c
}
mocks.MockLogger.Verbose method · go · L109-L114 (6 LOC)
pkg/ops/mocks/mock_Logger.go
func (_m *MockLogger) Verbose(format string, args ...interface{}) {
	var _ca []interface{}
	_ca = append(_ca, format)
	_ca = append(_ca, args...)
	_m.Called(_ca...)
}
mocks.MockLogger_Verbose_Call.Run method · go · L129-L140 (12 LOC)
pkg/ops/mocks/mock_Logger.go
func (_c *MockLogger_Verbose_Call) Run(run func(format string, args ...interface{})) *MockLogger_Verbose_Call {
	_c.Call.Run(func(args mock.Arguments) {
		variadicArgs := make([]interface{}, len(args)-1)
		for i, a := range args[1:] {
			if a != nil {
				variadicArgs[i] = a.(interface{})
			}
		}
		run(args[0].(string), variadicArgs...)
	})
	return _c
}
Same scanner, your repo: https://repobility.com — Repobility
mocks.MockLogger.Warning method · go · L153-L158 (6 LOC)
pkg/ops/mocks/mock_Logger.go
func (_m *MockLogger) Warning(format string, args ...interface{}) {
	var _ca []interface{}
	_ca = append(_ca, format)
	_ca = append(_ca, args...)
	_m.Called(_ca...)
}
mocks.MockLogger_Warning_Call.Run method · go · L173-L184 (12 LOC)
pkg/ops/mocks/mock_Logger.go
func (_c *MockLogger_Warning_Call) Run(run func(format string, args ...interface{})) *MockLogger_Warning_Call {
	_c.Call.Run(func(args mock.Arguments) {
		variadicArgs := make([]interface{}, len(args)-1)
		for i, a := range args[1:] {
			if a != nil {
				variadicArgs[i] = a.(interface{})
			}
		}
		run(args[0].(string), variadicArgs...)
	})
	return _c
}
mocks.NewMockLogger function · go · L198-L208 (11 LOC)
pkg/ops/mocks/mock_Logger.go
func NewMockLogger(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockLogger {
	mock := &MockLogger{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockPRCreateFunc.Execute method · go · L21-L46 (26 LOC)
pkg/ops/mocks/mock_PRCreateFunc.go
func (_m *MockPRCreateFunc) Execute(args []string) (string, error) {
	ret := _m.Called(args)

	if len(ret) == 0 {
		panic("no return value specified for Execute")
	}

	var r0 string
	var r1 error
	if rf, ok := ret.Get(0).(func([]string) (string, error)); ok {
		return rf(args)
	}
	if rf, ok := ret.Get(0).(func([]string) string); ok {
		r0 = rf(args)
	} else {
		r0 = ret.Get(0).(string)
	}

	if rf, ok := ret.Get(1).(func([]string) error); ok {
		r1 = rf(args)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
mocks.MockPRCreateFunc_Execute_Call.Run method · go · L59-L64 (6 LOC)
pkg/ops/mocks/mock_PRCreateFunc.go
func (_c *MockPRCreateFunc_Execute_Call) Run(run func(args []string)) *MockPRCreateFunc_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run(args[0].([]string))
	})
	return _c
}
mocks.NewMockPRCreateFunc function · go · L78-L88 (11 LOC)
pkg/ops/mocks/mock_PRCreateFunc.go
func NewMockPRCreateFunc(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockPRCreateFunc {
	mock := &MockPRCreateFunc{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockSafetyCheckFunc.Execute method · go · L21-L46 (26 LOC)
pkg/ops/mocks/mock_SafetyCheckFunc.go
func (_m *MockSafetyCheckFunc) Execute(wtPath string) (bool, error) {
	ret := _m.Called(wtPath)

	if len(ret) == 0 {
		panic("no return value specified for Execute")
	}

	var r0 bool
	var r1 error
	if rf, ok := ret.Get(0).(func(string) (bool, error)); ok {
		return rf(wtPath)
	}
	if rf, ok := ret.Get(0).(func(string) bool); ok {
		r0 = rf(wtPath)
	} else {
		r0 = ret.Get(0).(bool)
	}

	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(wtPath)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
mocks.MockSafetyCheckFunc_Execute_Call.Run method · go · L59-L64 (6 LOC)
pkg/ops/mocks/mock_SafetyCheckFunc.go
func (_c *MockSafetyCheckFunc_Execute_Call) Run(run func(wtPath string)) *MockSafetyCheckFunc_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run(args[0].(string))
	})
	return _c
}
Open data scored by Repobility · https://repobility.com
mocks.NewMockSafetyCheckFunc function · go · L78-L88 (11 LOC)
pkg/ops/mocks/mock_SafetyCheckFunc.go
func NewMockSafetyCheckFunc(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockSafetyCheckFunc {
	mock := &MockSafetyCheckFunc{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockStateAdopter.Execute method · go · L21-L36 (16 LOC)
pkg/ops/mocks/mock_StateAdopter.go
func (_m *MockStateAdopter) Execute(path string, repo string, branch string) error {
	ret := _m.Called(path, repo, branch)

	if len(ret) == 0 {
		panic("no return value specified for Execute")
	}

	var r0 error
	if rf, ok := ret.Get(0).(func(string, string, string) error); ok {
		r0 = rf(path, repo, branch)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
mocks.MockStateAdopter_Execute_Call.Run method · go · L51-L56 (6 LOC)
pkg/ops/mocks/mock_StateAdopter.go
func (_c *MockStateAdopter_Execute_Call) Run(run func(path string, repo string, branch string)) *MockStateAdopter_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run(args[0].(string), args[1].(string), args[2].(string))
	})
	return _c
}
mocks.NewMockStateAdopter function · go · L70-L80 (11 LOC)
pkg/ops/mocks/mock_StateAdopter.go
func NewMockStateAdopter(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStateAdopter {
	mock := &MockStateAdopter{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockStateChecker.Execute method · go · L21-L46 (26 LOC)
pkg/ops/mocks/mock_StateChecker.go
func (_m *MockStateChecker) Execute(path string) (bool, error) {
	ret := _m.Called(path)

	if len(ret) == 0 {
		panic("no return value specified for Execute")
	}

	var r0 bool
	var r1 error
	if rf, ok := ret.Get(0).(func(string) (bool, error)); ok {
		return rf(path)
	}
	if rf, ok := ret.Get(0).(func(string) bool); ok {
		r0 = rf(path)
	} else {
		r0 = ret.Get(0).(bool)
	}

	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(path)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
mocks.MockStateChecker_Execute_Call.Run method · go · L59-L64 (6 LOC)
pkg/ops/mocks/mock_StateChecker.go
func (_c *MockStateChecker_Execute_Call) Run(run func(path string)) *MockStateChecker_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run(args[0].(string))
	})
	return _c
}
mocks.NewMockStateChecker function · go · L78-L88 (11 LOC)
pkg/ops/mocks/mock_StateChecker.go
func NewMockStateChecker(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStateChecker {
	mock := &MockStateChecker{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockStatePruner.Execute method · go · L21-L46 (26 LOC)
pkg/ops/mocks/mock_StatePruner.go
func (_m *MockStatePruner) Execute() (int, error) {
	ret := _m.Called()

	if len(ret) == 0 {
		panic("no return value specified for Execute")
	}

	var r0 int
	var r1 error
	if rf, ok := ret.Get(0).(func() (int, error)); ok {
		return rf()
	}
	if rf, ok := ret.Get(0).(func() int); ok {
		r0 = rf()
	} else {
		r0 = ret.Get(0).(int)
	}

	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
Repobility — same analyzer, your code, free for public repos · /scan/
mocks.MockStatePruner_Execute_Call.Run method · go · L58-L63 (6 LOC)
pkg/ops/mocks/mock_StatePruner.go
func (_c *MockStatePruner_Execute_Call) Run(run func()) *MockStatePruner_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run()
	})
	return _c
}
mocks.NewMockStatePruner function · go · L77-L87 (11 LOC)
pkg/ops/mocks/mock_StatePruner.go
func NewMockStatePruner(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockStatePruner {
	mock := &MockStatePruner{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
mocks.MockTrustPruner.Execute method · go · L21-L46 (26 LOC)
pkg/ops/mocks/mock_TrustPruner.go
func (_m *MockTrustPruner) Execute(dir string) (int, error) {
	ret := _m.Called(dir)

	if len(ret) == 0 {
		panic("no return value specified for Execute")
	}

	var r0 int
	var r1 error
	if rf, ok := ret.Get(0).(func(string) (int, error)); ok {
		return rf(dir)
	}
	if rf, ok := ret.Get(0).(func(string) int); ok {
		r0 = rf(dir)
	} else {
		r0 = ret.Get(0).(int)
	}

	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(dir)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
mocks.MockTrustPruner_Execute_Call.Run method · go · L59-L64 (6 LOC)
pkg/ops/mocks/mock_TrustPruner.go
func (_c *MockTrustPruner_Execute_Call) Run(run func(dir string)) *MockTrustPruner_Execute_Call {
	_c.Call.Run(func(args mock.Arguments) {
		run(args[0].(string))
	})
	return _c
}
mocks.NewMockTrustPruner function · go · L78-L88 (11 LOC)
pkg/ops/mocks/mock_TrustPruner.go
func NewMockTrustPruner(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockTrustPruner {
	mock := &MockTrustPruner{}
	mock.Mock.Test(t)

	t.Cleanup(func() { mock.AssertExpectations(t) })

	return mock
}
ops.Prune function · go · L8-L57 (50 LOC)
pkg/ops/prune.go
func Prune(git gitops.Client, log Logger, opts PruneOptions, statePrune StatePruner, trustPrune TrustPruner) (*PruneResult, error) {
	result := &PruneResult{}

	// Prune stale state entries
	if statePrune != nil {
		pruned, err := statePrune()
		if err != nil {
			log.Warning("Failed to prune state: %v", err)
		}
		if pruned > 0 {
			log.Info("Pruned %d stale state entries", pruned)
		}
		result.StatePruned = pruned
	}

	// Prune stale trust entries
	if trustPrune != nil {
		wtDir, err := git.WorktreesDir(opts.RepoPath)
		if err == nil {
			pruned, err := trustPrune(wtDir)
			if err != nil {
				log.Warning("Failed to prune trust entries: %v", err)
			} else if pruned > 0 {
				log.Info("Pruned %d stale trust entries", pruned)
			}
			result.TrustPruned = pruned
		}
	}

	// Run git worktree prune
	if opts.DryRun {
		log.Info("Would run git worktree prune")
	} else {
		if err := git.WorktreePrune(opts.RepoPath); err != nil {
			log.Warning("Failed to run git worktree prune: %v", err)
		
ops.Sync function · go · L12-L97 (86 LOC)
pkg/ops/sync.go
func Sync(git gitops.Client, log Logger, opts SyncOptions) (*SyncResult, error) {
	result := &SyncResult{
		Branch:   opts.Branch,
		Strategy: opts.Strategy,
	}
	dirname := filepath.Base(opts.WtPath)

	// Safety check: dirty worktree
	if !opts.Force {
		dirty, err := git.IsWorktreeDirty(opts.WtPath)
		if err != nil {
			log.Warning("Could not check worktree status: %v", err)
		}
		if dirty {
			return result, fmt.Errorf("worktree '%s' has uncommitted changes (use --force to skip)", dirname)
		}
	}

	// Check if a merge or rebase is already in progress (idempotent — pick up where we left off)
	mergeInProgress, err := git.IsMergeInProgress(opts.WtPath)
	if err != nil {
		log.Verbose("Could not check merge status: %v", err)
	}
	if mergeInProgress {
		return syncContinueMerge(git, log, opts, result)
	}

	rebaseInProgress, err := git.IsRebaseInProgress(opts.WtPath)
	if err != nil {
		log.Verbose("Could not check rebase status: %v", err)
	}
	if rebaseInProgress {
		return syncContinueRebase(
ops.syncContinueMerge function · go · L100-L124 (25 LOC)
pkg/ops/sync.go
func syncContinueMerge(git gitops.Client, log Logger, opts SyncOptions, result *SyncResult) (*SyncResult, error) {
	dirname := filepath.Base(opts.WtPath)
	log.Info("Merge in progress — continuing sync of '%s' with '%s'", opts.Branch, opts.BaseBranch)

	hasConflicts, err := git.HasConflicts(opts.WtPath)
	if err != nil {
		log.Verbose("Could not check conflict status: %v", err)
	}
	if hasConflicts {
		result.Conflict = true
		return result, fmt.Errorf("worktree '%s' has unresolved conflicts — resolve all conflicts and stage files, then run sync again", dirname)
	}

	if opts.DryRun {
		log.Info("Would run: git merge --continue")
		result.Success = true
	} else {
		if err := git.MergeContinue(opts.WtPath); err != nil {
			return result, fmt.Errorf("merge --continue failed: %w", err)
		}
		log.Success("Sync continued — '%s' synced with '%s'", opts.Branch, opts.BaseBranch)
		result.Success = true
	}
	return result, nil
}
Repobility's GitHub App fixes findings like these · https://github.com/apps/repobility-bot
ops.syncContinueRebase function · go · L127-L151 (25 LOC)
pkg/ops/sync.go
func syncContinueRebase(git gitops.Client, log Logger, opts SyncOptions, result *SyncResult) (*SyncResult, error) {
	dirname := filepath.Base(opts.WtPath)
	log.Info("Rebase in progress — continuing sync of '%s' with '%s'", opts.Branch, opts.BaseBranch)

	hasConflicts, err := git.HasConflicts(opts.WtPath)
	if err != nil {
		log.Verbose("Could not check conflict status: %v", err)
	}
	if hasConflicts {
		result.Conflict = true
		return result, fmt.Errorf("worktree '%s' has unresolved conflicts — resolve all conflicts and stage files, then run sync again (or 'git -C %s rebase --abort' to cancel)", dirname, opts.WtPath)
	}

	if opts.DryRun {
		log.Info("Would run: git rebase --continue")
		result.Success = true
	} else {
		if err := git.RebaseContinue(opts.WtPath); err != nil {
			return result, fmt.Errorf("rebase --continue failed: %w", err)
		}
		log.Success("Sync continued — '%s' rebased onto '%s'", opts.Branch, opts.BaseBranch)
		result.Success = true
	}
	return result, nil
}
ops.SyncAll function · go · L155-L282 (128 LOC)
pkg/ops/sync.go
func SyncAll(git gitops.Client, log Logger, opts SyncOptions) ([]SyncResult, error) {
	worktrees, err := git.WorktreeList(opts.RepoPath)
	if err != nil {
		return nil, err
	}

	// Filter out main repo entry
	type wtEntry struct {
		path   string
		branch string
	}
	var entries []wtEntry
	for _, wt := range worktrees {
		if wt.Path == opts.RepoPath {
			continue
		}
		entries = append(entries, wtEntry{path: wt.Path, branch: wt.Branch})
	}

	if len(entries) == 0 {
		log.Info("No worktrees to sync")
		return nil, nil
	}

	// Fetch once if remote exists
	mergeSource, _ := resolveMergeSource(git, log, opts.RepoPath, opts.BaseBranch, opts.DryRun)

	var results []SyncResult
	for _, entry := range entries {
		dirname := filepath.Base(entry.path)

		// Skip if dirty
		dirty, err := git.IsWorktreeDirty(entry.path)
		if err != nil {
			log.Warning("Could not check status of '%s': %v (skipping)", dirname, err)
			results = append(results, SyncResult{Branch: entry.branch, Skipped: true, SkipReason:
ops.FormatSyncStatus function · go · L136-L147 (12 LOC)
pkg/ops/types.go
func FormatSyncStatus(ahead, behind int) string {
	switch {
	case ahead > 0 && behind > 0:
		return fmt.Sprintf("↑%d ↓%d", ahead, behind)
	case ahead > 0:
		return fmt.Sprintf("↑%d", ahead)
	case behind > 0:
		return fmt.Sprintf("↓%d", behind)
	default:
		return "clean"
	}
}
ops.classifySource function · go · L150-L155 (6 LOC)
pkg/ops/types.go
func classifySource(wtPath, standardDir string) string {
	if len(wtPath) > len(standardDir) && wtPath[:len(standardDir)] == standardDir {
		return "wt"
	}
	return "external"
}
ops.resolveMergeSource function · go · L164-L183 (20 LOC)
pkg/ops/types.go
func resolveMergeSource(git gitops.Client, log Logger, repoPath, baseBranch string, dryRun bool) (mergeSource string, hasRemote bool) {
	hasRemote, err := git.HasRemote(repoPath)
	if err != nil {
		log.Verbose("Could not check for remote: %v", err)
	}

	mergeSource = baseBranch
	if hasRemote {
		if dryRun {
			log.Info("Would fetch from remote")
		} else {
			log.Info("Fetching latest changes")
			if err := git.Fetch(repoPath); err != nil {
				log.Warning("Fetch failed: %v (continuing with local state)", err)
			}
		}
		mergeSource = "origin/" + baseBranch
	}
	return mergeSource, hasRemote
}
ops.resolveEffectiveMergeSource function · go · L187-L210 (24 LOC)
pkg/ops/types.go
func resolveEffectiveMergeSource(git gitops.Client, log Logger, wtPath, baseBranch, mergeSource string) (effectiveSource string, ahead, behind int) {
	ahead, err := git.CommitsAhead(wtPath, mergeSource)
	if err != nil {
		log.Verbose("Could not check ahead status: %v", err)
	}
	behind, err = git.CommitsBehind(wtPath, mergeSource)
	if err != nil {
		log.Verbose("Could not check behind status: %v", err)
	}

	effectiveSource = mergeSource
	if mergeSource != baseBranch {
		localBehind, err := git.CommitsBehind(wtPath, baseBranch)
		if err != nil {
			log.Verbose("Could not check local behind status: %v", err)
		}
		if localBehind > behind {
			behind = localBehind
			effectiveSource = baseBranch
			ahead, _ = git.CommitsAhead(wtPath, effectiveSource)
		}
	}
	return effectiveSource, ahead, behind
}
wtstate.FlexTime.UnmarshalJSON method · go · L20-L40 (21 LOC)
pkg/wtstate/wtstate.go
func (ft *FlexTime) UnmarshalJSON(data []byte) error {
	var s string
	if err := json.Unmarshal(data, &s); err != nil {
		return err
	}
	if s == "" {
		ft.Time = time.Time{}
		return nil
	}
	// Try RFC3339 first, then fall back to bare datetime (assume UTC)
	t, err := time.Parse(time.RFC3339, s)
	if err != nil {
		t, err = time.Parse("2006-01-02T15:04:05", s)
		if err != nil {
			return err
		}
		t = t.UTC()
	}
	ft.Time = t
	return nil
}
wtstate.Manager.Load method · go · L72-L89 (18 LOC)
pkg/wtstate/wtstate.go
func (m *Manager) Load() (*State, error) {
	data, err := os.ReadFile(m.path)
	if err != nil {
		if os.IsNotExist(err) {
			return &State{Worktrees: make(map[string]*WorktreeState)}, nil
		}
		return nil, err
	}

	var s State
	if err := json.Unmarshal(data, &s); err != nil {
		return nil, err
	}
	if s.Worktrees == nil {
		s.Worktrees = make(map[string]*WorktreeState)
	}
	return &s, nil
}
Same scanner, your repo: https://repobility.com — Repobility
wtstate.Manager.Save method · go · L92-L108 (17 LOC)
pkg/wtstate/wtstate.go
func (m *Manager) Save(s *State) error {
	dir := filepath.Dir(m.path)
	if err := os.MkdirAll(dir, 0755); err != nil {
		return err
	}

	data, err := json.MarshalIndent(s, "", "  ")
	if err != nil {
		return err
	}

	tmp := m.path + ".tmp"
	if err := os.WriteFile(tmp, data, 0644); err != nil {
		return err
	}
	return os.Rename(tmp, m.path)
}
wtstate.Manager.SetWorktree method · go · L111-L118 (8 LOC)
pkg/wtstate/wtstate.go
func (m *Manager) SetWorktree(path string, ws *WorktreeState) error {
	s, err := m.Load()
	if err != nil {
		return err
	}
	s.Worktrees[path] = ws
	return m.Save(s)
}
wtstate.Manager.RemoveWorktree method · go · L121-L128 (8 LOC)
pkg/wtstate/wtstate.go
func (m *Manager) RemoveWorktree(path string) error {
	s, err := m.Load()
	if err != nil {
		return err
	}
	delete(s.Worktrees, path)
	return m.Save(s)
}
wtstate.Manager.GetWorktree method · go · L131-L137 (7 LOC)
pkg/wtstate/wtstate.go
func (m *Manager) GetWorktree(path string) (*WorktreeState, error) {
	s, err := m.Load()
	if err != nil {
		return nil, err
	}
	return s.Worktrees[path], nil
}
wtstate.Manager.Prune method · go · L141-L161 (21 LOC)
pkg/wtstate/wtstate.go
func (m *Manager) Prune() (int, error) {
	s, err := m.Load()
	if err != nil {
		return 0, err
	}

	pruned := 0
	for path := range s.Worktrees {
		if _, err := os.Stat(path); os.IsNotExist(err) {
			delete(s.Worktrees, path)
			pruned++
		}
	}

	if pruned > 0 {
		if err := m.Save(s); err != nil {
			return pruned, err
		}
	}
	return pruned, nil
}
‹ prevpage 5 / 5