bonchi 0.1.0 → 0.2.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f1b9e3fb0df2276375aff9ca6d5f416fc2396602570c41d0a2f925f3528cdc1
4
- data.tar.gz: 23b137fbe286b1c8a2845348ae8bb30d1c9200851ed7eee0c99face39e3fb7b8
3
+ metadata.gz: c8bcf10affa988d4bff6b9d78fd53ea1be600a9c03e93bf95f083fadd210e3e6
4
+ data.tar.gz: 40a744831b24891e328d4dbc400a4da030a98680279e06cd55ab77b0306d5375
5
5
  SHA512:
6
- metadata.gz: 8f132bd0f26283c4bab9f506553882eee5685e77def350e76c537a180beb44f399fa8540d542ab5be06f85fc8579b1378dde351c887c8291f4cbdeeb9a08f7df
7
- data.tar.gz: 71b5b5c3fda5a36dfdce6bb3b16a12401b838663bf57f22e8fdf25193372db458e4598f98c2d09ddbc91882d4567b1fdba6d029cfceae96054ea0b179502cfee
6
+ metadata.gz: 511dfe169d347f644e9f5c24db3a03ba3faba965ceda23848d06295b58bca16c7de3020164febd7cc2611f26878d421663a709d599edede7a71dc164e8ae891a
7
+ data.tar.gz: 26f08d5c1e6725088ba9d2268a7ef0fe0daa604351c63afd4a44dd45208f21c68fce9270b8dbbabd104313b950f776de700e8b1a07eececa14d0007676260704
data/lib/bonchi/cli.rb CHANGED
@@ -22,18 +22,18 @@ module Bonchi
22
22
  existing = Git.worktree_path_for(branch)
23
23
  if existing
24
24
  puts "Worktree already exists: #{existing}"
25
- puts "BONCHI_CD:#{existing}"
25
+ signal_cd(existing)
26
26
  return
27
27
  end
28
28
 
29
29
  Git.worktree_add_new_branch(path, branch, base)
30
30
  puts "Worktree created at: #{path}"
31
31
 
32
+ signal_cd(path)
33
+
32
34
  if options[:setup] && Config.from_main_worktree
33
35
  puts ""
34
36
  Setup.new(worktree: path).run
35
- else
36
- puts "BONCHI_CD:#{path}"
37
37
  end
38
38
  end
39
39
 
@@ -42,7 +42,7 @@ module Bonchi
42
42
  existing = Git.worktree_path_for(branch)
43
43
  if existing
44
44
  puts "Worktree already exists: #{existing}"
45
- puts "BONCHI_CD:#{existing}"
45
+ signal_cd(existing)
46
46
  return
47
47
  end
48
48
 
@@ -54,7 +54,7 @@ module Bonchi
54
54
  Git.worktree_add(path, branch)
55
55
  puts "Worktree created at: #{path}"
56
56
 
57
- puts "BONCHI_CD:#{path}"
57
+ signal_cd(path)
58
58
  end
59
59
 
60
60
  desc "pr NUMBER_OR_URL", "Checkout GitHub PR in worktree"
@@ -66,7 +66,7 @@ module Bonchi
66
66
  existing = Git.worktree_path_for(branch)
67
67
  if existing
68
68
  puts "Worktree already exists: #{existing}"
69
- puts "BONCHI_CD:#{existing}"
69
+ signal_cd(existing)
70
70
  return
71
71
  end
72
72
 
@@ -74,12 +74,12 @@ module Bonchi
74
74
  Git.worktree_add(path, branch)
75
75
  puts "PR ##{pr_number} checked out at: #{path}"
76
76
 
77
- puts "BONCHI_CD:#{path}"
77
+ signal_cd(path)
78
78
  end
79
79
 
80
- desc "setup", "Run setup in current worktree (ports, copy, pre_setup, setup cmd)"
81
- def setup
82
- Setup.new.run
80
+ desc "setup [-- ARGS...]", "Run setup in current worktree (ports, copy, pre_setup, setup cmd)"
81
+ def setup(*args)
82
+ Setup.new.run(args)
83
83
  end
84
84
 
85
85
  desc "list", "List all worktrees"
@@ -113,6 +113,15 @@ module Bonchi
113
113
 
114
114
  private
115
115
 
116
+ def signal_cd(path)
117
+ cd_file = ENV["BONCHI_CD_FILE"]
118
+ if cd_file
119
+ File.write(cd_file, path)
120
+ else
121
+ puts "cd #{path}"
122
+ end
123
+ end
124
+
116
125
  def extract_pr_number(input)
117
126
  case input
118
127
  when %r{^https://github.com/.*/pull/(\d+)}
@@ -126,13 +135,12 @@ module Bonchi
126
135
 
127
136
  SHELL_ENV = <<~'SHELL'
128
137
  bonchi() {
129
- local output
130
- output=$(command bonchi "$@")
138
+ local bonchi_cd_file="${TMPDIR:-/tmp}/bonchi_cd.$$"
139
+ BONCHI_CD_FILE="$bonchi_cd_file" command bonchi "$@"
131
140
  local exit_code=$?
132
- echo "$output"
133
- if [ $exit_code -eq 0 ]; then
134
- local cd_path=$(echo "$output" | grep "^BONCHI_CD:" | cut -d: -f2-)
135
- [ -n "$cd_path" ] && cd "$cd_path"
141
+ if [ $exit_code -eq 0 ] && [ -f "$bonchi_cd_file" ]; then
142
+ cd "$(cat "$bonchi_cd_file")"
143
+ rm -f "$bonchi_cd_file"
136
144
  fi
137
145
  return $exit_code
138
146
  }
@@ -1,3 +1,3 @@
1
1
  module Bonchi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0.rc1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bonchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gert Goet
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '3.3'
54
+ version: '3.1'
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="