Skip to content

Commit 6a59bc8

Browse files
committed
Remove the Git::Base::Factory module
1 parent 28224a1 commit 6a59bc8

File tree

2 files changed

+90
-102
lines changed

2 files changed

+90
-102
lines changed

lib/git/base.rb

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'git/base/factory'
21
require 'logger'
32
require 'open3'
43

@@ -10,8 +9,6 @@ module Git
109
# {Git.clone}, or {Git.bare}.
1110
#
1211
class Base
13-
include Git::Base::Factory
14-
1512
# (see Git.bare)
1613
def self.bare(git_dir, options = {})
1714
normalize_paths(options, default_repository: git_dir, bare: true)
@@ -632,6 +629,96 @@ def current_branch
632629
self.lib.branch_current
633630
end
634631

632+
# @return [Git::Branch] an object for branch_name
633+
def branch(branch_name = self.current_branch)
634+
Git::Branch.new(self, branch_name)
635+
end
636+
637+
# @return [Git::Branches] a collection of all the branches in the repository.
638+
# Each branch is represented as a {Git::Branch}.
639+
def branches
640+
Git::Branches.new(self)
641+
end
642+
643+
# returns a Git::Worktree object for dir, commitish
644+
def worktree(dir, commitish = nil)
645+
Git::Worktree.new(self, dir, commitish)
646+
end
647+
648+
# returns a Git::worktrees object of all the Git::Worktrees
649+
# objects for this repo
650+
def worktrees
651+
Git::Worktrees.new(self)
652+
end
653+
654+
# @return [Git::Object::Commit] a commit object
655+
def commit_tree(tree = nil, opts = {})
656+
Git::Object::Commit.new(self, self.lib.commit_tree(tree, opts))
657+
end
658+
659+
# @return [Git::Diff] a Git::Diff object
660+
def diff(objectish = 'HEAD', obj2 = nil)
661+
Git::Diff.new(self, objectish, obj2)
662+
end
663+
664+
# @return [Git::Object] a Git object
665+
def gblob(objectish)
666+
Git::Object.new(self, objectish, 'blob')
667+
end
668+
669+
# @return [Git::Object] a Git object
670+
def gcommit(objectish)
671+
Git::Object.new(self, objectish, 'commit')
672+
end
673+
674+
# @return [Git::Object] a Git object
675+
def gtree(objectish)
676+
Git::Object.new(self, objectish, 'tree')
677+
end
678+
679+
# @return [Git::Log] a log with the specified number of commits
680+
def log(count = 30)
681+
Git::Log.new(self, count)
682+
end
683+
684+
# returns a Git::Object of the appropriate type
685+
# you can also call @git.gtree('tree'), but that's
686+
# just for readability. If you call @git.gtree('HEAD') it will
687+
# still return a Git::Object::Commit object.
688+
#
689+
# object calls a method that will run a rev-parse
690+
# on the objectish and determine the type of the object and return
691+
# an appropriate object for that type
692+
#
693+
# @return [Git::Object] an instance of the appropriate type of Git::Object
694+
def object(objectish)
695+
Git::Object.new(self, objectish)
696+
end
697+
698+
# @return [Git::Remote] a remote of the specified name
699+
def remote(remote_name = 'origin')
700+
Git::Remote.new(self, remote_name)
701+
end
702+
703+
# @return [Git::Status] a status object
704+
def status
705+
Git::Status.new(self)
706+
end
707+
708+
# @return [Git::Object::Tag] a tag object
709+
def tag(tag_name)
710+
Git::Object.new(self, tag_name, 'tag', true)
711+
end
712+
713+
# Find as good common ancestors as possible for a merge
714+
# example: g.merge_base('master', 'some_branch', 'some_sha', octopus: true)
715+
#
716+
# @return [Array<Git::Object::Commit>] a collection of common ancestors
717+
def merge_base(*args)
718+
shas = self.lib.merge_base(*args)
719+
shas.map { |sha| gcommit(sha) }
720+
end
721+
635722
private
636723

637724
# Normalize options before they are sent to Git::Base.new

lib/git/base/factory.rb

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)