You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deprecate the ActiveRecord-style branch objects and their facade entry points in favor of the Git::BranchInfo-based API, following the same pattern used for remotes.
Scope of deprecation:
Git::Branch (class)
Git::Branches (collection class)
Git::Repository#branch — returns Git::Branch
Git::Repository#branches — returns Git::Branches
Not deprecated: the rest of Git::Repository::Branching. That module is the replacement — branch_list, checkout, branch_new, branch_delete, branch_contains, update_ref, current_branch, etc. all stay. Only the two methods that hand back AR objects (#branch, #branches) are in scope.
Proposed timeline: deprecate as early as 5.0.0, remove in 6.0.0.
Motivation
Git::BranchInfo (immutable, remote-aware) already exists and is returned by Git::Repository#branch_list. Git::Branch/Git::Branches are the legacy def initialize(base, …) rich objects that both hold data and perform operations. Steering users to branch_list + facade operations aligns branches with the *Info DAO direction (see umbrella #1636) and sidesteps the legacy string-constructor bug in #1631.
Capability audit — no gap
Every Git::Branch operation is already a thin delegate to an existing Git::Repository facade method that accepts a name/string:
Git::Branch method
Facade equivalent
checkout
Git::Repository#checkout (see note on create-if-missing)
create
Git::Repository#branch_new
delete
Git::Repository#branch_delete
current
Git::Repository#current_branch
contains?
Git::Repository#branch_contains
update_ref
Git::Repository#update_ref
merge
Git::Repository#merge (see note on the merge(branch) overload)
archive
Git::Repository#archive
gcommit
Git::Repository#gcommit
stashes
Git::Repository#stashes_all (tracked separately in #1637)
Preconditions (do before deprecating the composites)
Two Git::Branch methods are multi-step conveniences with no single facade equivalent. Provide replacements first so the deprecation notes can point somewhere real:
in_branch(message) { … } — temp checkout → commit-or-reset → restore original branch. Re-home as a Git::Repository#in_branch facade method (or document a recipe).
merge(branch) overload — "merge X into branch Y without checking out Y first." The bare facade #merge merges into the current branch, so add a facade path or document the recipe.
Semantic wrinkles to document in the deprecation notes
checkout auto-creates:Git::Branch#checkout calls check_if_create before checking out; Git::Repository#checkout(name) does not. Call this out so migrators aren't surprised.
Return-shape change:#branches returns an enumerable of Git::Branch; branch_list returns Array<Git::BranchInfo>. Access shifts from branch.name to info.short_name, etc.
Use the existing Git::Deprecation.warn pattern (as in Git::Repository#stash_list).
Suggested sequencing
Land the in_branch and merge-into-branch facade replacements.
Deprecate the 1:1-replaceable methods/accessors first (#branch, #branches, and the Git::Branch operation methods that already have exact facade equivalents).
Hold deprecation of in_branch / merge(branch) until step 1 ships.
Ensure deprecation messages don't point at other about-to-be-deprecated APIs (e.g., don't route #stashes users through Git::Stashes).
Blast radius
Git::Branch, Git::Branches, #branch, #branches are core, high-traffic, @api public. Expect significant deprecation-warning volume; phasing (above) keeps 5.0.0 warnings honest and each pointed at a real replacement.
Testing
Unit specs asserting each deprecation warning fires (mirror the stash_list deprecation test).
Specs for the new in_branch / merge-into-branch facade methods.
UPGRADING.md migration section with the per-method mapping above.
Summary
Deprecate the ActiveRecord-style branch objects and their facade entry points in favor of the
Git::BranchInfo-based API, following the same pattern used for remotes.Scope of deprecation:
Git::Branch(class)Git::Branches(collection class)Git::Repository#branch— returnsGit::BranchGit::Repository#branches— returnsGit::BranchesNot deprecated: the rest of
Git::Repository::Branching. That module is the replacement —branch_list,checkout,branch_new,branch_delete,branch_contains,update_ref,current_branch, etc. all stay. Only the two methods that hand back AR objects (#branch,#branches) are in scope.Proposed timeline: deprecate as early as 5.0.0, remove in 6.0.0.
Motivation
Git::BranchInfo(immutable, remote-aware) already exists and is returned byGit::Repository#branch_list.Git::Branch/Git::Branchesare the legacydef initialize(base, …)rich objects that both hold data and perform operations. Steering users tobranch_list+ facade operations aligns branches with the*InfoDAO direction (see umbrella #1636) and sidesteps the legacy string-constructor bug in #1631.Capability audit — no gap
Every
Git::Branchoperation is already a thin delegate to an existingGit::Repositoryfacade method that accepts a name/string:Git::BranchmethodcheckoutGit::Repository#checkout(see note on create-if-missing)createGit::Repository#branch_newdeleteGit::Repository#branch_deletecurrentGit::Repository#current_branchcontains?Git::Repository#branch_containsupdate_refGit::Repository#update_refmergeGit::Repository#merge(see note on themerge(branch)overload)archiveGit::Repository#archivegcommitGit::Repository#gcommitstashesGit::Repository#stashes_all(tracked separately in #1637)full/name/remoteGit::BranchInfo#refname/#short_name/#remote_nameGit::Branches(collection):each/[]/local/remote/size map ontoGit::Repository#branch_list(which returnsArray<Git::BranchInfo>) plus array operations.Preconditions (do before deprecating the composites)
Two
Git::Branchmethods are multi-step conveniences with no single facade equivalent. Provide replacements first so the deprecation notes can point somewhere real:in_branch(message) { … }— temp checkout → commit-or-reset → restore original branch. Re-home as aGit::Repository#in_branchfacade method (or document a recipe).merge(branch)overload — "merge X into branch Y without checking out Y first." The bare facade#mergemerges into the current branch, so add a facade path or document the recipe.Semantic wrinkles to document in the deprecation notes
checkoutauto-creates:Git::Branch#checkoutcallscheck_if_createbefore checking out;Git::Repository#checkout(name)does not. Call this out so migrators aren't surprised.#branchesreturns an enumerable ofGit::Branch;branch_listreturnsArray<Git::BranchInfo>. Access shifts frombranch.nametoinfo.short_name, etc.#stashesis a latent-bug method (ignores the branch, returns all repo stashes) — already split out to Deprecate Git::Branch#stashes in favor of Git::Repository#stashes_all #1637.Per-method deprecation messages (draft)
Each warning should name the exact replacement, e.g.:
git.branch('x')→ "Userepo.branch_list/repo.branch_contains/ name-based facade methods instead."git.branch('x').delete→repo.branch_delete('x')git.branch('x').checkout→repo.checkout('x')(note: no auto-create)git.branches→repo.branch_listgit.branches['x']→repo.branch_list.find { |b| b.short_name == 'x' }Use the existing
Git::Deprecation.warnpattern (as inGit::Repository#stash_list).Suggested sequencing
in_branchandmerge-into-branch facade replacements.#branch,#branches, and theGit::Branchoperation methods that already have exact facade equivalents).in_branch/merge(branch)until step 1 ships.#stashesusers throughGit::Stashes).Blast radius
Git::Branch,Git::Branches,#branch,#branchesare core, high-traffic,@api public. Expect significant deprecation-warning volume; phasing (above) keeps 5.0.0 warnings honest and each pointed at a real replacement.Testing
stash_listdeprecation test).in_branch/merge-into-branch facade methods.UPGRADING.mdmigration section with the per-method mapping above.Affected files (initial)
lib/git/branch.rb,lib/git/branches.rblib/git/repository/branching.rb(#branch,#branches; newin_branch/merge path)spec/unit/git/branch_spec.rb,spec/unit/git/branches_spec.rb,spec/unit/git/repository/branching_spec.rbUPGRADING.mdRelated
Git::Branchstring constructor (supports moving users to theBranchInfopath)Git::Branch#stashes(sub-case of this effort)*Info/DAO migrationredesign/branch_parse_refactor_plan.md