worktree 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a21f0e1e12ffd3382234f57fc3abeff4f2816aa7f36897923ebe77e045fbb99
4
- data.tar.gz: 79635e4cf96a885f5d0472887dc046e066db04427efaae495c65c97a38f00a00
3
+ metadata.gz: 0b20449f6464b20c3bd03ca27b1a261b68ab5fe4f8bf18d52e33a95e90e60f73
4
+ data.tar.gz: 496f6c0380665811b23d80acb6adb7ae2acf84058d7cdb9a97091137cf681f06
5
5
  SHA512:
6
- metadata.gz: 2c22b94b9bf4a33b14950574065963e5feec30ffeda94e376590dc2053f297c2fcee30cd087e227b0fcb4dc18903122a6bb92852e04b2ef5f60dd6d7df9f70fd
7
- data.tar.gz: 8b988eeeb6ad543317f5bc117a6c8461a936f6b9e9ac1f84c2c9998403fefa843e78162163dfa697ee3c4c90a5ea43f659d68c89d4908511c2a24565448811ef
6
+ metadata.gz: 27836a4299f8f6ffead0725a28cb7754b2a90159e65c0972ebd93b4c4d7f59b61e1a99be9e60226e5945e2be2f417f6dcf684e75cbe813fd0e97d88f073d07f4
7
+ data.tar.gz: 27d6e562eb633ba96d871f89abfeca68bcd0841d1b93ebcdb10c8569a0777b2837a78f3a0f95b6b7353d3412b0c699cb32cb727005ab1dd091c8b6f2898ae486
data/bin/worktree CHANGED
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ lib = File.expand_path('../lib', __dir__)
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
4
7
  require 'worktree/cli'
5
8
 
6
9
  Worktree::CLI.start(ARGV)
data/lib/worktree/cli.rb CHANGED
@@ -4,51 +4,71 @@ require 'worktree'
4
4
  require 'thor'
5
5
 
6
6
  module Worktree
7
- class CLI < Thor
7
+ class CLI < Thor # :nodoc:
8
8
  def self.exit_on_failure?
9
9
  true
10
10
  end
11
11
 
12
12
  desc 'new BRANCH', 'Create a new branch'
13
- option :from, default: Worktree::Command::Add::DEFAULT_BRANCH_REMOTE
13
+ option :from, default: 'upstream/master'
14
14
  option :project_dir
15
+ option :launcher_vars, type: :hash, default: {}
16
+ option :clone_db, type: :boolean, default: false
17
+ option :fetch_remote, type: :boolean, default: true
15
18
  def new(branch)
16
19
  Worktree::Command::Add.new(branch,
17
20
  from: options[:from],
18
- project_dir: options[:project_dir]).do!
21
+ project_dir: options[:project_dir],
22
+ clone_db: options[:clone_db],
23
+ fetch_remote: options[:fetch_remote],
24
+ launcher_vars: options[:launcher_vars]).do!
19
25
  end
20
26
 
21
27
  desc 'open BRANCH', 'Open existing worktree'
22
28
  option :project_dir
29
+ option :launcher_vars, type: :hash, default: {}
23
30
  def open(branch)
24
31
  Worktree::Command::Open.new(branch,
25
- project_dir: options[:project_dir]).do!
32
+ project_dir: options[:project_dir],
33
+ launcher_vars: options[:launcher_vars]).do!
26
34
  end
27
35
 
28
- desc 'remove BRANCH', 'Remove branches'
36
+ desc 'remove BRANCH', 'Remove branch'
29
37
  option :project_dir
30
- def remove(*branches)
31
- branches.each do |b|
32
- Worktree::Command::Remove.new(b,
33
- project_dir: options[:project_dir]).do!
34
- end
38
+ option :drop_db, type: :boolean, default: false
39
+ option :drop_remote_branch, type: :boolean, default: false
40
+ option :check_merged, type: :boolean, default: false
41
+ def remove(branch)
42
+ Worktree::Command::Remove.new(branch,
43
+ project_dir: options[:project_dir],
44
+ drop_db: options[:drop_db],
45
+ drop_remote_branch: options[:drop_remote_branch],
46
+ check_merged: options[:check_merged]).do!
47
+ end
48
+
49
+ desc 'check-stale', 'Check stale branches'
50
+ option :project_dir
51
+ def check_stale
52
+ Worktree::Command::CheckStale.new(project_dir: options[:project_dir]).do!
35
53
  end
36
54
 
37
55
  desc 'remove-stale', 'Remove all stale branches'
38
56
  option :project_dir
39
57
  def remove_stale
40
58
  Worktree::Command::RemoveStale.new(project_dir: options[:project_dir]).do!
41
- rescue TTY::Reader::InputInterrupt
42
- Worktree.logger.info { "You've interrupted removing of stale branches!" }
43
59
  end
44
60
 
45
61
  desc 'cherry_pick COMMIT', 'Create a new cherry pick'
46
62
  option :to, required: true
47
63
  option :project_dir, default: Dir.pwd
64
+ option :launcher_vars, type: :hash, default: {}
65
+ option :clone_db, type: :boolean, default: false
48
66
  def cherry_pick(commit)
49
67
  Worktree::Command::CherryPick.new(commit,
50
68
  to: options[:to],
51
- project_dir: options[:project_dir]).do!
69
+ project_dir: options[:project_dir],
70
+ clone_db: options[:clone_db],
71
+ launcher_vars: options[:launcher_vars]).do!
52
72
  end
53
73
 
54
74
  desc 'configure', 'Configure worktree'
@@ -57,10 +77,14 @@ module Worktree
57
77
  end
58
78
 
59
79
  desc 'init URI', 'Initialize new worktree'
60
- option :repo_path, required: true
80
+ option :path, default: Dir.pwd
81
+ option :remote, default: 'origin'
82
+ option :name
61
83
  def init(uri)
62
84
  Worktree::Command::Init.new(uri,
63
- repo_path: options[:repo_path]).do!
85
+ path: options[:path],
86
+ name: options[:name],
87
+ remote: options[:remote]).do!
64
88
  end
65
89
  end
66
90
  end
@@ -1,56 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tty-prompt'
4
-
5
3
  module Worktree
6
4
  module Command
7
- class Add
8
- DEFAULT_BRANCH_REMOTE = 'upstream/master'
9
-
10
- def initialize(branch, from:, project_dir:)
5
+ class Add # :nodoc:
6
+ def initialize(branch, from:, project_dir:, launcher_vars: {}, clone_db: false, fetch_remote: true)
11
7
  @branch = branch
12
- @branch_remote = from
8
+ @from = from
13
9
  @project_dir = File.expand_path project_dir || Project.resolve(branch).root
14
- @worktree = "#{@project_dir}/#{@branch}"
10
+ @launcher_vars = launcher_vars
11
+ @clone_db = clone_db
12
+ @fetch_remote = fetch_remote
15
13
  end
16
14
 
17
15
  def do!
18
- raise "Worktree #{@worktree} already exists!" if Dir.exist?(@worktree)
19
- raise 'No master repo found!' unless Dir.exist?("#{@project_dir}/master/.git")
16
+ # fetch git remote if allowed
17
+ git.fetch(remote, prune: true) if @fetch_remote
20
18
 
21
- # fetch all
22
- # TODO: silence log while fetching remotes
23
- git.remotes.each { |remote| git.fetch(remote, prune: true) }
19
+ # create new git worktree
20
+ Worktree.run_command "git worktree add -b #{@branch} ../#{@branch} #{@from}", chdir: git.dir
24
21
 
25
- # update master
26
- git.pull('upstream', 'master')
22
+ # copy files specified in configuration into new folder
23
+ Feature::CopyFiles.new(project_dir: @project_dir, branch: @branch).run!
27
24
 
28
- Worktree.run_command "git worktree add -b #{@branch} ../#{@branch} #{@branch_remote}", chdir: "#{@project_dir}/master"
25
+ # clone PG database
26
+ Feature::CloneDbs.new(project_dir: @project_dir, branch: @branch).run! if @clone_db
29
27
 
30
- copy_files
31
- clone_dbs
32
- Launcher.new(
33
- project_dir: @project_dir,
34
- branch: @branch
35
- ).launch!
28
+ # launch in editor
29
+ Launcher.new(project_dir: @project_dir, branch: @branch, extra_vars: @launcher_vars).launch!
36
30
  end
37
31
 
38
32
  private
39
33
 
40
- def copy_files
41
- Feature::CopyFiles.new(
42
- project_dir: @project_dir,
43
- branch: @branch
44
- ).run!
45
- end
46
-
47
- def clone_dbs
48
- if File.exist?("#{@project_dir}/#{@branch}/config/database.yml")
49
- Feature::CloneDbs.new(
50
- project_dir: @project_dir,
51
- branch: @branch
52
- ).run! unless TTY::Prompt.new.no?('Clone development database?')
53
- end
34
+ def remote
35
+ @from.split('/')[0]
54
36
  end
55
37
 
56
38
  def git
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Worktree
4
+ module Command
5
+ class CheckStale
6
+ def initialize(project_dir:)
7
+ @project_dir = File.expand_path project_dir || Dir.pwd
8
+ end
9
+
10
+ def do!
11
+ # update refs
12
+ git.remotes.each { |remote| git.fetch(remote, prune: true) }
13
+ git.pull('upstream', 'master')
14
+
15
+ branches = Dir.entries(@project_dir).
16
+ select { |f| File.directory?("#{@project_dir}/#{f}}") }.
17
+ reject { |f| ['master', '.', '..'].include?(f) }
18
+
19
+ stale_branches = branches.select do |branch|
20
+ git.branch('master').contains?(branch)
21
+ end
22
+
23
+ Worktree.logger.info { "You have #{stale_branches.size} stale branches!" }
24
+ end
25
+
26
+ private
27
+
28
+ def git
29
+ @git ||= Worktree.git_for(@project_dir)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,27 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'git'
4
- require 'tty-prompt'
5
-
6
3
  module Worktree
7
4
  module Command
8
5
  class CherryPick
9
- def initialize(commit, to:, project_dir:)
6
+ def initialize(commit, to:, project_dir:, launcher_vars: {}, clone_db: false)
10
7
  @commit = commit[0..7] # short commit
11
- @branch_remote = to
12
- @branch = "cherry-pick-#{@commit}-to-#{@branch_remote.tr('/', '-')}"
8
+ @to = to
9
+ @branch = "cherry-pick-#{@commit}-to-#{@to.tr('/', '-')}"
13
10
  @project_dir = File.expand_path project_dir
11
+ @clone_db = clone_db
12
+ @launcher_vars = launcher_vars
14
13
  end
15
14
 
16
15
  def do!
17
- raise "Folder #{@branch} already exists!" if Dir.exist?("#{@project_dir}/#{@branch}")
18
- raise 'No master repo found!' unless Dir.exist?("#{@project_dir}/master/.git")
19
-
20
- # fetch all
21
- git.remotes.each(&:fetch)
16
+ # fetch all remotes
17
+ git.remotes.each { |remote| git.fetch(remote, prune: true) }
22
18
 
23
- Worktree.run_command "git worktree add -b #{@branch} ../#{@branch} #{@branch_remote}", chdir: "#{@project_dir}/master"
19
+ # create new git worktree
20
+ Worktree.run_command "git worktree add -b #{@branch} ../#{@branch} #{@to}", chdir: git.dir
24
21
 
22
+ # cherry-pick specified commit into specified branch
25
23
  begin
26
24
  Worktree.run_command "git cherry-pick #{@commit} -m 1", chdir: "#{@project_dir}/#{@branch}"
27
25
  rescue Worktree::Error => e
@@ -29,31 +27,17 @@ module Worktree
29
27
  Worktree.logger.warn { e.message }
30
28
  end
31
29
 
32
- copy_files
33
- clone_dbs
34
- Launcher.new(
35
- project_dir: @project_dir,
36
- branch: @branch
37
- ).launch!
38
- end
30
+ # copy files specified in configuration into new folder
31
+ Feature::CopyFiles.new(project_dir: @project_dir, branch: @branch).run!
39
32
 
40
- private
33
+ # clone PG database
34
+ Feature::CloneDbs.new(project_dir: @project_dir, branch: @branch).run! if @clone_db
41
35
 
42
- def copy_files
43
- Feature::CopyFiles.new(
44
- project_dir: @project_dir,
45
- branch: @branch
46
- ).run!
36
+ # launch in editor
37
+ Launcher.new(project_dir: @project_dir, branch: @branch, extra_vars: @launcher_vars).launch!
47
38
  end
48
39
 
49
- def clone_dbs
50
- if File.exist?("#{@project_dir}/#{@branch}/config/database.yml")
51
- Feature::CloneDbs.new(
52
- project_dir: @project_dir,
53
- branch: @branch
54
- ).run! unless TTY::Prompt.new.no?('Clone development database?')
55
- end
56
- end
40
+ private
57
41
 
58
42
  def git
59
43
  @git ||= Worktree.git_for(@project_dir)
@@ -1,50 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tty-prompt'
4
-
5
3
  module Worktree
6
4
  module Command
7
- class Init
8
- def initialize(uri, repo_path:)
5
+ class Init # :nodoc:
6
+ def initialize(uri, name:, path:, remote: 'origin')
9
7
  @uri = uri
10
- @repo_path = File.expand_path repo_path
8
+ @path = File.expand_path path
9
+ @remote = remote
10
+ @name = name || build_name
11
11
  end
12
12
 
13
13
  def do!
14
- # clone git repo
15
- @git = Git.clone(@uri, tmp_repo_name, path: @repo_path)
16
-
17
- # rearrange repo folders
18
- FileUtils.mkdir_p "#{@repo_path}/#{repo_name}"
19
- git_master_path = "#{@repo_path}/#{repo_name}/master"
20
- FileUtils.mv "#{@repo_path}/#{tmp_repo_name}", git_master_path
21
-
22
- # reinit git from new path
23
- @git = Worktree.git_for(git_master_path)
24
-
25
- remote_name = TTY::Prompt.new.ask?('What is remote name?', default: 'origin')
14
+ FileUtils.mkdir_p "#{@path}/#{@name}"
26
15
 
27
- unless remote_name == 'origin'
28
- # add remote
29
- @git.add_remote remote_name, @uri
30
-
31
- # TODO: remove origin remote?
16
+ Dir.chdir "#{@path}/#{@name}" do
17
+ @git = Git.clone(@uri, 'master', remote: @remote, log: Worktree.logger)
32
18
  end
33
19
  end
34
20
 
35
21
  private
36
22
 
37
- # example '123' * 2 = '123123'
38
- def tmp_repo_name
39
- repo_name * 2
40
- end
41
-
42
- def repo_name
43
- @repo_name ||= begin
44
- u = URI(@uri)
45
- n = u.path.split('/')
46
- n.last[0..-5] # remove .git
47
- end
23
+ def build_name
24
+ URI(@uri).path.split('/').last[0..-5] # remove .git
48
25
  end
49
26
  end
50
27
  end
@@ -1,24 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'tty-prompt'
4
-
5
3
  module Worktree
6
4
  module Command
7
- class Open
8
- def initialize(branch, project_dir:)
5
+ class Open # :nodoc:
6
+ def initialize(branch, project_dir:, launcher_vars: {})
9
7
  @branch = branch
10
8
  @project_dir = File.expand_path project_dir || Project.resolve(branch).root
11
- @worktree = "#{@project_dir}/#{@branch}"
9
+ @launcher_vars = launcher_vars
12
10
  end
13
11
 
14
12
  def do!
15
- raise "Worktree #{@worktree} not found exists!" unless Dir.exist?(@worktree)
16
- raise 'No master repo found!' unless Dir.exist?("#{@project_dir}/master/.git")
17
-
18
- Launcher.new(
19
- project_dir: @project_dir,
20
- branch: @branch
21
- ).launch!
13
+ Launcher.new(project_dir: @project_dir, branch: @branch, extra_vars: @launcher_vars).launch!
22
14
  end
23
15
  end
24
16
  end
@@ -3,41 +3,35 @@
3
3
  module Worktree
4
4
  module Command
5
5
  class Remove
6
- def initialize(branch, project_dir:, update_refs: true)
6
+ NotMergedError = Class.new(StandardError)
7
+
8
+ def initialize(branch, project_dir: nil, drop_db: false, drop_remote_branch: false, check_merged: false)
7
9
  @branch = branch
8
10
  @project_dir = File.expand_path project_dir || Project.resolve(branch).root
9
- @worktree = "#{@project_dir}/#{@branch}"
10
- @update_refs = update_refs
11
+ @drop_db = drop_db
12
+ @check_merged = check_merged
11
13
  end
12
14
 
13
15
  def do!
14
- return unless Dir.exist?(@worktree)
15
- return unless TTY::Prompt.new.yes?("Do you want to remove #{@worktree}?")
16
-
17
- # update refs
18
- git.remotes.each { |remote| git.fetch(remote, prune: true) } if @update_refs
19
-
20
- unless git.branch('master').contains?(@branch)
21
- unless TTY::Prompt.new.yes?("The branch #{@branch} was not merged to master. Would you like to remove it anyway?")
22
- Worktree.logger.warn { "You've skipped removing the worktree #{@worktree}" }
23
- return
24
- end
16
+ if @check_merged && !git.branch('master').contains?(@branch)
17
+ raise NotMergedError.new("#{@branch} is not merged into master")
25
18
  end
26
19
 
27
- drop_db! if File.exist?("#{@worktree}/config/database.yml")
20
+ drop_db! if @drop_db
28
21
 
29
22
  # remove stale worktree
30
- Worktree.run_command "git worktree remove #{@worktree} --force", chdir: "#{@project_dir}/master"
23
+ Worktree.run_command "git worktree remove #{@project_dir}/#{@branch} --force", chdir: git.dir
31
24
 
32
25
  # if remote branch exists then remove it also
33
- if Git.ls_remote(git.dir)['remotes'].keys.include?("origin/#{@branch}")
34
- if TTY::Prompt.new.yes?("Do you want to remove remote branch origin/#{@branch}?")
35
- git.push('origin', @branch, delete: true)
36
- end
26
+ if @drop_remote_branch && Git.ls_remote(git.dir)['remotes'].keys.include?("origin/#{@branch}")
27
+ git.push('origin', @branch, delete: true)
28
+ Worktree.logger.info { "Remote branch #{@branch} was deleted successfully." }
37
29
  end
38
30
 
39
31
  # remove local branch
40
32
  git.branch(@branch).delete
33
+ rescue NotMergedError => e
34
+ Worktree.logger.error { e }
41
35
  end
42
36
 
43
37
  private
@@ -47,9 +41,8 @@ module Worktree
47
41
  db_manager = db_manager_for(@branch)
48
42
  return if db_manager.template == db_manager_master.template
49
43
 
50
- if TTY::Prompt.new.yes?("Do you want to drop database #{db_manager.template}?")
51
- db_manager.dropdb!
52
- end
44
+ db_manager.dropdb!
45
+ Worktree.logger.info { "Database #{db_manager.template} was dropped successfully." }
53
46
  end
54
47
 
55
48
  def db_manager_for(branch)
@@ -13,8 +13,9 @@ module Worktree
13
13
  git.pull('upstream', 'master')
14
14
 
15
15
  branches = Dir.entries(@project_dir).
16
- reject { |d| d == '.' || d == '..' || d == 'master' }.
17
- select { |f| File.directory?(f) }
16
+ select { |f| File.directory?("#{@project_dir}/#{f}}") }.
17
+ reject { |f| ['master', '.', '..'].include?(f) }
18
+
18
19
 
19
20
  stale_branches = branches.select do |branch|
20
21
  git.branch('master').contains?(branch)
@@ -24,7 +25,11 @@ module Worktree
24
25
 
25
26
  stale_branches.each_with_index do |stale_branch, index|
26
27
  Worktree.logger.info { "#{index + 1} of #{stale_branches.size}" }
27
- Remove.new(stale_branch, project_dir: @project_dir, update_refs: false).do!
28
+ Remove.new(stale_branch,
29
+ project_dir: @project_dir,
30
+ drop_db: true,
31
+ drop_remote_branch: true,
32
+ check_merged: true).do!
28
33
  end
29
34
  end
30
35
 
@@ -6,8 +6,8 @@ module Worktree
6
6
  class DbManager
7
7
  attr_reader :spec
8
8
 
9
- def initialize(config_file, environment = 'development')
10
- @spec = YAML.load_file(config_file)
9
+ def initialize(spec_file, environment = 'development')
10
+ @spec = YAML.load_file(spec_file)
11
11
  @environment = environment
12
12
  end
13
13
 
@@ -27,6 +27,14 @@ module Worktree
27
27
  end
28
28
  end
29
29
 
30
+ def db_host
31
+ if multi?
32
+ environment_spec.dig('primary', 'host')
33
+ else
34
+ environment_spec['host']
35
+ end
36
+ end
37
+
30
38
  def template
31
39
  if multi?
32
40
  environment_spec.dig('primary', 'database')
@@ -37,18 +45,18 @@ module Worktree
37
45
 
38
46
  def createdb!(db_name)
39
47
  cmd = if db_port
40
- "createdb -h localhost -p #{db_port} -T #{template} #{db_name}"
48
+ "createdb -h #{db_host} -p #{db_port} -T #{template} #{db_name}"
41
49
  else
42
- "createdb -h localhost -T #{template} #{db_name}"
50
+ "createdb -h #{db_host} -T #{template} #{db_name}"
43
51
  end
44
52
  Worktree.run_command cmd
45
53
  end
46
54
 
47
55
  def dropdb!
48
56
  cmd = if db_port
49
- "dropdb -h localhost -p #{db_port} #{template}"
57
+ "dropdb -h #{db_host} -p #{db_port} #{template}"
50
58
  else
51
- "dropdb -h localhost #{template}"
59
+ "dropdb -h #{db_host} #{template}"
52
60
  end
53
61
  Worktree.run_command cmd
54
62
  end
@@ -4,8 +4,7 @@ require 'yaml'
4
4
 
5
5
  module Worktree
6
6
  module Feature
7
- class CloneDbs
8
-
7
+ class CloneDbs # :nodoc:
9
8
  def initialize(project_dir:, branch:)
10
9
  @project_dir = project_dir
11
10
  @branch = branch
@@ -2,10 +2,11 @@
2
2
 
3
3
  module Worktree
4
4
  class Launcher # :nodoc:
5
- def initialize(project_dir:, branch:)
5
+ def initialize(project_dir:, branch:, extra_vars: {})
6
6
  @project_dir = project_dir
7
7
  @branch = branch
8
8
  @working_directory = "#{@project_dir}/#{@branch}".chomp('/')
9
+ @extra_vars = extra_vars.symbolize_keys
9
10
  end
10
11
 
11
12
  def launch!
@@ -16,20 +17,11 @@ module Worktree
16
17
 
17
18
  def command
18
19
  cmd = ENV.fetch('WORKTREE_LAUNCHER') { ENV.fetch('EDITOR', 'vim') }
19
- format(cmd, replace_vars)
20
+ format(cmd, default_vars.merge(@extra_vars))
20
21
  end
21
22
 
22
- def replace_vars
23
- {
24
- worktree_dir: @working_directory,
25
- worktree_branch: @branch,
26
- tmux_session_name: tmux_session_name
27
- }
28
- end
29
-
30
- # tmux session name cannot contains . or :
31
- def tmux_session_name
32
- @branch.gsub(/\.|:/, '-')
23
+ def default_vars
24
+ { path: @working_directory, branch: @branch }
33
25
  end
34
26
  end
35
27
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worktree
4
- class Project
4
+ class Project # :nodoc:
5
5
  def self.resolve(branch, project_dir: nil)
6
6
  project_key = project_key_by_branch(branch)
7
7
  # try to find project key by dir (cherry-pick or open case)
@@ -29,8 +29,6 @@ module Worktree
29
29
  end
30
30
  end
31
31
 
32
- private
33
-
34
32
  def self.project_key_by_branch(branch)
35
33
  project_keys = Worktree::Config.config['projects'].keys
36
34
  return nil if project_keys.empty?
@@ -52,5 +50,7 @@ module Worktree
52
50
  end
53
51
  project_key
54
52
  end
53
+
54
+ private_class_method :project_key_by_branch, :project_key_by_dir
55
55
  end
56
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Worktree
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/worktree.rb CHANGED
@@ -9,7 +9,7 @@ require 'zeitwerk'
9
9
  loader = Zeitwerk::Loader.for_gem
10
10
  loader.setup
11
11
 
12
- module Worktree
12
+ module Worktree # :nodoc:
13
13
  def logger
14
14
  return @logger if defined?(@logger)
15
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worktree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Gonchar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-21 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
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
83
  - !ruby/object:Gem::Dependency
98
84
  name: zeitwerk
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +164,7 @@ dependencies:
178
164
  - - ">="
179
165
  - !ruby/object:Gem::Version
180
166
  version: '0'
181
- description:
167
+ description:
182
168
  email:
183
169
  - igor.gonchar@gmail.com
184
170
  executables:
@@ -195,6 +181,7 @@ files:
195
181
  - lib/worktree/cli.rb
196
182
  - lib/worktree/command.rb
197
183
  - lib/worktree/command/add.rb
184
+ - lib/worktree/command/check_stale.rb
198
185
  - lib/worktree/command/cherry_pick.rb
199
186
  - lib/worktree/command/configure.rb
200
187
  - lib/worktree/command/init.rb
@@ -219,7 +206,7 @@ homepage: https://github.com/gigorok/worktree
219
206
  licenses:
220
207
  - MIT
221
208
  metadata: {}
222
- post_install_message:
209
+ post_install_message:
223
210
  rdoc_options: []
224
211
  require_paths:
225
212
  - lib
@@ -234,9 +221,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
221
  - !ruby/object:Gem::Version
235
222
  version: '0'
236
223
  requirements: []
237
- rubyforge_project:
224
+ rubyforge_project:
238
225
  rubygems_version: 2.7.6.2
239
- signing_key:
226
+ signing_key:
240
227
  specification_version: 4
241
228
  summary: Manage your projects by git working tree feature
242
229
  test_files: []