worktree 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/bin/worktree +6 -0
- data/bin/worktree_tab_completion +9 -0
- data/lib/worktree.rb +37 -0
- data/lib/worktree/cli.rb +59 -0
- data/lib/worktree/command.rb +8 -0
- data/lib/worktree/command/add.rb +66 -0
- data/lib/worktree/command/cherry_pick.rb +68 -0
- data/lib/worktree/command/configure.rb +17 -0
- data/lib/worktree/command/open.rb +37 -0
- data/lib/worktree/command/remove.rb +64 -0
- data/lib/worktree/command/remove_stale.rb +38 -0
- data/lib/worktree/config.rb +23 -0
- data/lib/worktree/db_manager.rb +56 -0
- data/lib/worktree/error.rb +6 -0
- data/lib/worktree/feature/clone_dbs.rb +46 -0
- data/lib/worktree/feature/copy_files.rb +32 -0
- data/lib/worktree/feature/jira.rb +74 -0
- data/lib/worktree/feature/tmux.rb +67 -0
- data/lib/worktree/project.rb +29 -0
- data/lib/worktree/tab_completion.rb +8 -0
- data/lib/worktree/tab_completion/branch_completion.rb +54 -0
- data/lib/worktree/tab_completion/cli.rb +140 -0
- data/lib/worktree/tab_completion/project_dir_completion.rb +50 -0
- data/lib/worktree/tab_completion/remote_branch_completion.rb +24 -0
- data/lib/worktree/tab_completion/worktree_completion.rb +19 -0
- data/lib/worktree/version.rb +5 -0
- metadata +241 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Worktree
|
4
|
+
module TabCompletion
|
5
|
+
class ProjectDirCompletion
|
6
|
+
def initialize(base_compl)
|
7
|
+
@base_compl = base_compl.to_s.strip
|
8
|
+
if @base_compl.starts_with?('~')
|
9
|
+
@replace_home = true
|
10
|
+
@base_compl = "#{ENV['HOME']}/#{@base_compl[1..-1]}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def list
|
15
|
+
if File.directory?(@base_compl)
|
16
|
+
base_dir = @base_compl
|
17
|
+
else
|
18
|
+
# remove tail
|
19
|
+
if @base_compl.starts_with?('/')
|
20
|
+
if @base_compl.split('/').size == 2
|
21
|
+
base_dir = '/'
|
22
|
+
else
|
23
|
+
base_dir = @base_compl.split('/')[0..-2].join('/')
|
24
|
+
end
|
25
|
+
else
|
26
|
+
base_dir = @base_compl.split('/')[0..-2].join('/')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
base_dir = base_dir.presence || '.'
|
31
|
+
|
32
|
+
# select only folders
|
33
|
+
Dir.entries(base_dir.presence).
|
34
|
+
select { |f| File.directory? "#{base_dir.chomp('/')}/#{f}" }.
|
35
|
+
reject { |d| d == '.' || d == '..' }.
|
36
|
+
map do |d|
|
37
|
+
if @replace_home
|
38
|
+
b = "~#{base_dir[ENV['HOME'].size+1..-1]}"
|
39
|
+
"#{b.chomp('/')}/#{d}"
|
40
|
+
elsif base_dir == '.'
|
41
|
+
d
|
42
|
+
else
|
43
|
+
b = base_dir
|
44
|
+
"#{b.chomp('/')}/#{d}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'git'
|
4
|
+
|
5
|
+
module Worktree
|
6
|
+
module TabCompletion
|
7
|
+
class RemoteBranchCompletion
|
8
|
+
def initialize(base_compl, project_dir: nil)
|
9
|
+
@base_compl = base_compl.to_s.strip
|
10
|
+
@project_dir = project_dir || Dir.pwd
|
11
|
+
end
|
12
|
+
|
13
|
+
def list
|
14
|
+
Git.ls_remote(git.dir)['remotes'].keys
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def git
|
20
|
+
@git ||= Worktree.git_for(@project_dir)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Worktree
|
4
|
+
module TabCompletion
|
5
|
+
class WorktreeCompletion
|
6
|
+
def initialize(base_compl)
|
7
|
+
@base_compl = base_compl.to_s.strip
|
8
|
+
@project_dir = Project.resolve(@base_compl).root
|
9
|
+
end
|
10
|
+
|
11
|
+
def list
|
12
|
+
# select only folders
|
13
|
+
Dir.entries(@project_dir).
|
14
|
+
select { |f| File.directory? "#{@project_dir.chomp('/')}/#{f}" }.
|
15
|
+
reject { |d| d == '.' || d == '..' }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: worktree
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Gonchar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: git
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jira-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: tty-command
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: tty-prompt
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: zeitwerk
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: byebug
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 12.3.3
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 12.3.3
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description:
|
182
|
+
email:
|
183
|
+
- igor.gonchar@gmail.com
|
184
|
+
executables:
|
185
|
+
- worktree
|
186
|
+
- worktree_tab_completion
|
187
|
+
extensions: []
|
188
|
+
extra_rdoc_files: []
|
189
|
+
files:
|
190
|
+
- bin/console
|
191
|
+
- bin/setup
|
192
|
+
- bin/worktree
|
193
|
+
- bin/worktree_tab_completion
|
194
|
+
- lib/worktree.rb
|
195
|
+
- lib/worktree/cli.rb
|
196
|
+
- lib/worktree/command.rb
|
197
|
+
- lib/worktree/command/add.rb
|
198
|
+
- lib/worktree/command/cherry_pick.rb
|
199
|
+
- lib/worktree/command/configure.rb
|
200
|
+
- lib/worktree/command/open.rb
|
201
|
+
- lib/worktree/command/remove.rb
|
202
|
+
- lib/worktree/command/remove_stale.rb
|
203
|
+
- lib/worktree/config.rb
|
204
|
+
- lib/worktree/db_manager.rb
|
205
|
+
- lib/worktree/error.rb
|
206
|
+
- lib/worktree/feature/clone_dbs.rb
|
207
|
+
- lib/worktree/feature/copy_files.rb
|
208
|
+
- lib/worktree/feature/jira.rb
|
209
|
+
- lib/worktree/feature/tmux.rb
|
210
|
+
- lib/worktree/project.rb
|
211
|
+
- lib/worktree/tab_completion.rb
|
212
|
+
- lib/worktree/tab_completion/branch_completion.rb
|
213
|
+
- lib/worktree/tab_completion/cli.rb
|
214
|
+
- lib/worktree/tab_completion/project_dir_completion.rb
|
215
|
+
- lib/worktree/tab_completion/remote_branch_completion.rb
|
216
|
+
- lib/worktree/tab_completion/worktree_completion.rb
|
217
|
+
- lib/worktree/version.rb
|
218
|
+
homepage: https://github.com/gigorok/worktree
|
219
|
+
licenses:
|
220
|
+
- MIT
|
221
|
+
metadata: {}
|
222
|
+
post_install_message:
|
223
|
+
rdoc_options: []
|
224
|
+
require_paths:
|
225
|
+
- lib
|
226
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - ">="
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: '0'
|
236
|
+
requirements: []
|
237
|
+
rubygems_version: 3.0.3
|
238
|
+
signing_key:
|
239
|
+
specification_version: 4
|
240
|
+
summary: Manage your projects by git working tree feature
|
241
|
+
test_files: []
|