INNER CODE UNIT · Go
getCurrentBranch
umputun/ralphex · cmd/ralphex/main.go:387
func getCurrentBranch(gitSvc *git.Service) string {
branch, err := gitSvc.CurrentBranch()
if err != nil || branch == "" {
return "unknown"
}
return branch
}
// tryAutoPlanMode attempts to switch to plan mode when no plans are found on the default branch.
// when no plans are found but auto-plan-mode does not apply, it returns (true, err) with an
// explanatory error so the user always learns why interactive plan creation was not offered.
// returns (true, nil) if the user canceled, (true, err) if plan mode was attempted or refused
// with a reason, or (false, nil) if the selection error is unrelated to missing plans.
func tryAutoPlanMode(ctx context.Context, err error, o opts, req executePlanRequest,
selector *plan.Selector) (bool, error) {
// only a missing-plans error is a candidate for auto-plan-mode; other errors propagate as-is.
if !errors.Is(err, plan.ErrNoPlansFound) {
return false, nil