aircon 0.2.1 → 0.2.2

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: b5b3b124b494117995209a018929128c6f19659813c182d8cf204a29b695bc97
4
- data.tar.gz: ffd8e8323e460a77a007abe18f43cee07080b78156da9759fd3f22773310860c
3
+ metadata.gz: d76315d35b51587153fc8df9ef838132d3c3e86a0c3e4c2cd8a0316efae9c69a
4
+ data.tar.gz: c563bde8c95b8fe48de22520b014a3b98a6b0cd81974b6ced35b1aa600e4c4b2
5
5
  SHA512:
6
- metadata.gz: 749d093f93485cbbc99b3280be49d8921049b5ad107ccc17170f6522d47eefe358bde6ba17afa74c270d289133feb47673486a4dc28e39f8f42fa614e9f9f5b4
7
- data.tar.gz: '091c7ce2565eea7113f4c3d8263a0c31a72349e5c05ff681f373bd0c9e40b82feda3f031f507a5ec74304e40161891d98034f1a6b8167616f2dc031a03b41676'
6
+ metadata.gz: d951bf39261652772719424735e55cbab79ed819e2fb36347b6e93d61c4c6c534660c64eaa578f68480e46b689e0c37737ff6841dca58e5375dd2af8d492c55f
7
+ data.tar.gz: 8d331471642fc173bd1f770559e0c8a55a773517089082378918b8144fc1220f2b43cc779f9305da896ebaf3dc5e2abdb76492e15a0e20512616a95d051ff8e7
@@ -170,26 +170,34 @@ module Aircon
170
170
  system("docker", "exec", container, "git", "config", "--global",
171
171
  "url.#{authed}.insteadOf", "git@github.com:")
172
172
  end
173
- # Skip checkout if already on the target branch (host was on this branch)
174
- current_branch, = Open3.capture2("docker", "exec", container, "git", "rev-parse", "--abbrev-ref", "HEAD")
175
- if current_branch.strip != branch
176
- # Check if branch exists on remote; if so, check it out, otherwise create new
177
- _, status = Open3.capture2("docker", "exec", container, "git", "ls-remote", "--heads", "origin", branch)
178
- if status.success? && !_.strip.empty?
179
- system("docker", "exec", container, "git", "fetch", "origin", branch)
180
- system("docker", "exec", container, "git", "checkout", "-f", "-b", branch, "origin/#{branch}")
181
- system("docker", "exec", container, "git", "clean", "-fd")
182
- else
183
- system("docker", "exec", container, "git", "fetch", "origin", "main")
184
- system("docker", "exec", container, "git", "checkout", "-f", "--no-track", "-b", branch, "origin/main")
185
- system("docker", "exec", container, "git", "clean", "-fd")
186
- end
187
- end
173
+ checkout_branch(container, branch)
188
174
 
189
175
  # If you have the official anthropic marketplace plugin installed, it will always make a call to the anthropic github repo on claude startup. It uses SSH, but it should be https for universal compatibility since its a public repository.
190
176
  system("docker", "exec", container, "git", "config", "--global", "url.\"https://github.com/anthropics/\".insteadOf", "ssh://git@github.com/anthropics/")
191
177
  end
192
178
 
179
+ def checkout_branch(container, branch)
180
+ current_branch, = Open3.capture2("docker", "exec", container, "git", "rev-parse", "--abbrev-ref", "HEAD")
181
+ return if current_branch.strip == branch
182
+
183
+ _, local_status = Open3.capture2("docker", "exec", container, "git", "rev-parse", "--verify", branch)
184
+ if local_status.success?
185
+ system("docker", "exec", container, "git", "checkout", "-f", branch)
186
+ elsif branch_exists_on_remote?(container, branch)
187
+ system("docker", "exec", container, "git", "fetch", "origin", branch)
188
+ system("docker", "exec", container, "git", "checkout", "-f", "-b", branch, "origin/#{branch}")
189
+ else
190
+ system("docker", "exec", container, "git", "fetch", "origin", "main")
191
+ system("docker", "exec", container, "git", "checkout", "-f", "--no-track", "-b", branch, "origin/main")
192
+ end
193
+ system("docker", "exec", container, "git", "clean", "-fd")
194
+ end
195
+
196
+ def branch_exists_on_remote?(container, branch)
197
+ output, status = Open3.capture2("docker", "exec", container, "git", "ls-remote", "--heads", "origin", branch)
198
+ status.success? && !output.strip.empty?
199
+ end
200
+
193
201
  def run_init_script(container)
194
202
  return unless @config.init_script && !@config.init_script.to_s.empty?
195
203
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aircon
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aircon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Nguyen