@@ -6,18 +6,18 @@ module RubyGit
66 # The working tree is a directory tree consisting of the checked out files that
77 # you are currently working on.
88 #
9- # Create a new WorkingTree using {.init}, {.clone}, or {.open}.
9+ # Create a new Worktree using {.init}, {.clone}, or {.open}.
1010 #
11- class WorkingTree
11+ class Worktree
1212 # The root path of the working tree
1313 #
1414 # @example
15- # working_tree_path = '/Users/James/myproject'
16- # working_tree = WorkingTree .open(working_tree_path )
17- # working_tree .path
15+ # worktree_path = '/Users/James/myproject'
16+ # worktree = Worktree .open(worktree_path )
17+ # worktree .path
1818 # => '/Users/James/myproject'
1919 #
20- # @return [Pathname] the root path of the working_tree
20+ # @return [Pathname] the root path of the worktree
2121 #
2222 attr_reader :path
2323
@@ -28,40 +28,40 @@ class WorkingTree
2828 # @see https://git-scm.com/docs/git-init git-init
2929 #
3030 # @example
31- # working_tree = WorkingTree .init(working_tree_path )
31+ # worktree = Worktree .init(worktree_path )
3232 #
33- # @param [String] working_tree_path the root path of a Git working tree
33+ # @param [String] worktree_path the root path of a Git working tree
3434 #
35- # @raise [RubyGit::Error] if working_tree_path is not a directory
35+ # @raise [RubyGit::Error] if worktree_path is not a directory
3636 #
37- # @return [RubyGit::WorkingTree ] the working tree whose root is at `path`
37+ # @return [RubyGit::Worktree ] the working tree whose root is at `path`
3838 #
39- def self . init ( working_tree_path )
40- raise RubyGit ::Error , "Path '#{ working_tree_path } ' not valid." unless File . directory? ( working_tree_path )
39+ def self . init ( worktree_path )
40+ raise RubyGit ::Error , "Path '#{ worktree_path } ' not valid." unless File . directory? ( worktree_path )
4141
4242 command = [ 'init' ]
43- options = { chdir : working_tree_path , out : StringIO . new , err : StringIO . new }
43+ options = { chdir : worktree_path , out : StringIO . new , err : StringIO . new }
4444 RubyGit ::CommandLine . run ( *command , **options )
4545
46- new ( working_tree_path )
46+ new ( worktree_path )
4747 end
4848
49- # Open an existing Git working tree that contains working_tree_path
49+ # Open an existing Git working tree that contains worktree_path
5050 #
5151 # @see https://git-scm.com/docs/git-open git-open
5252 #
5353 # @example
54- # working_tree = WorkingTree .open(working_tree_path )
54+ # worktree = Worktree .open(worktree_path )
5555 #
56- # @param [String] working_tree_path the root path of a Git working tree
56+ # @param [String] worktree_path the root path of a Git working tree
5757 #
58- # @raise [RubyGit::Error] if `working_tree_path ` does not exist, is not a directory, or is not within
58+ # @raise [RubyGit::Error] if `worktree_path ` does not exist, is not a directory, or is not within
5959 # a Git working tree.
6060 #
61- # @return [RubyGit::WorkingTree ] the Git working tree that contains `working_tree_path `
61+ # @return [RubyGit::Worktree ] the Git working tree that contains `worktree_path `
6262 #
63- def self . open ( working_tree_path )
64- new ( working_tree_path )
63+ def self . open ( worktree_path )
64+ new ( worktree_path )
6565 end
6666
6767 # Copy the remote repository and checkout the default branch
@@ -72,19 +72,19 @@ def self.open(working_tree_path)
7272 #
7373 # @see https://git-scm.com/docs/git-clone git-clone
7474 #
75- # @example Using default for WorkingTree path
75+ # @example Using default for Worktree path
7676 # FileUtils.pwd
7777 # => "/Users/jsmith"
78- # working_tree = WorkingTree .clone('https://github.com/main-branch/ruby_git.git')
79- # working_tree .path
78+ # worktree = Worktree .clone('https://github.com/main-branch/ruby_git.git')
79+ # worktree .path
8080 # => "/Users/jsmith/ruby_git"
8181 #
82- # @example Using a specified working_tree_path
82+ # @example Using a specified worktree_path
8383 # FileUtils.pwd
8484 # => "/Users/jsmith"
85- # working_tree_path = '/tmp/project'
86- # working_tree = WorkingTree .clone('https://github.com/main-branch/ruby_git.git', to_path: working_tree_path )
87- # working_tree .path
85+ # worktree_path = '/tmp/project'
86+ # worktree = Worktree .clone('https://github.com/main-branch/ruby_git.git', to_path: worktree_path )
87+ # worktree .path
8888 # => "/tmp/project"
8989 #
9090 # @param [String] repository_url a reference to a Git repository
@@ -97,7 +97,7 @@ def self.open(working_tree_path)
9797 # @raise [RubyGit::FailedError] if (1) `repository_url` is not valid or does not point to a valid repository OR
9898 # (2) `to_path` is not an empty directory.
9999 #
100- # @return [RubyGit::WorkingTree ] the Git working tree checked out from the cloned repository
100+ # @return [RubyGit::Worktree ] the Git working tree checked out from the cloned repository
101101 #
102102 def self . clone ( repository_url , to_path : '' )
103103 command = [ 'clone' , '--' , repository_url , to_path ]
@@ -108,13 +108,13 @@ def self.clone(repository_url, to_path: '')
108108
109109 private
110110
111- # Create a WorkingTree object
111+ # Create a Worktree object
112112 # @api private
113113 #
114- def initialize ( working_tree_path )
115- raise RubyGit ::Error , "Path '#{ working_tree_path } ' not valid." unless File . directory? ( working_tree_path )
114+ def initialize ( worktree_path )
115+ raise RubyGit ::Error , "Path '#{ worktree_path } ' not valid." unless File . directory? ( worktree_path )
116116
117- @path = root_path ( working_tree_path )
117+ @path = root_path ( worktree_path )
118118 RubyGit . logger . debug ( "Created #{ inspect } " )
119119 end
120120
@@ -126,14 +126,14 @@ def initialize(working_tree_path)
126126 #
127127 # @api private
128128 #
129- def root_path ( working_tree_path )
129+ def root_path ( worktree_path )
130130 command = %w[ rev-parse --show-toplevel ]
131- options = { chdir : working_tree_path , chomp : true , out : StringIO . new , err : StringIO . new }
131+ options = { chdir : worktree_path , chomp : true , out : StringIO . new , err : StringIO . new }
132132 RubyGit ::CommandLine . run ( *command , **options ) . stdout
133133 end
134134
135135 # def run(*command, **options)
136- # RubyGit::CommandLine.run(*command, working_tree_path : path, **options)
136+ # RubyGit::CommandLine.run(*command, worktree_path : path, **options)
137137 # end
138138 end
139139end
0 commit comments