xccache 0.0.1a3 → 0.0.1a4

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: 2f65f29ba5115620a4f02708c9bffea0dc76d03665970232a580c22f6659df51
4
- data.tar.gz: 7e98a3268e17d0198762c31d631b6e27516e3d4e2e851c5aeeaf33de28e2b5fa
3
+ metadata.gz: 8f25ddb49ae65e34b141a696ca54f50bd3dcb3e65d7883609263b6e6904c8f78
4
+ data.tar.gz: 8f73671a9e7dbdfc17026a3c38176d01fa2db96d7a85436d1da52dcd63656a6f
5
5
  SHA512:
6
- metadata.gz: 80d8a6b25273bcbb2ebbb6a7985d1a092caae35beaa60ba49b1b8e6a3c626196dd9c9d5397dde9391d228c8e5e9fa26e13bf5135542425efa18ffafb8cbc7746
7
- data.tar.gz: 821e59573bf41ca862db69118e60d5f9a16a4d338a900760063fd97e885fdf4bf88ae3d7792db11c10ac3a38d7546929c6117527ee4f6d72c70cfde506452d6c
6
+ metadata.gz: 2c939fbafc217ac9784278e37e2946ba4c289aee5ca67f239f0ec358d869551674720f1077cfdd4daba2da70c895f8b3918b4b2453a86c6c4233a398cd3e533d
7
+ data.tar.gz: a49f327f9e5551e2b095581ae650b5904bc09003c5b1399774ffacc635b16ac43856cc49ca02275692eda4c1f4d01430f8e3202f0dcd796ce4e69e1b934483ed
@@ -18,7 +18,11 @@ module XCCache
18
18
  status("--porcelain", capture: true, log_cmd: false)[0].empty?
19
19
  end
20
20
 
21
- %i[checkout fetch pull push clean add commit branch remote switch status].each do |name|
21
+ def init?
22
+ !root.glob(".git").empty?
23
+ end
24
+
25
+ %i[init checkout fetch pull push clean add commit branch remote switch status].each do |name|
22
26
  define_method(name) do |*args, **kwargs|
23
27
  run(name, *args, **kwargs)
24
28
  end
@@ -7,7 +7,8 @@ module XCCache
7
7
  def initialize(options = {})
8
8
  super
9
9
  if (@remote = options[:remote])
10
- @remote = File.expand_path(@remote) unless ["http", "https", "git"].include?(URI.parse(@remote).scheme)
10
+ schemes = ["http://", "https://", "git@"]
11
+ @remote = File.expand_path(@remote) unless schemes.any? { |x| @remote.start_with?(x) }
11
12
  ensure_remote
12
13
  end
13
14
  @branch = options[:branch]
@@ -27,7 +28,7 @@ module XCCache
27
28
 
28
29
  git.add(".")
29
30
  git.commit("-m \"Update cache at #{Time.new}\"")
30
- git.push("origin #{branch}")
31
+ git.push("-u origin #{branch}")
31
32
  end
32
33
 
33
34
  private
@@ -37,6 +38,7 @@ module XCCache
37
38
  end
38
39
 
39
40
  def ensure_remote
41
+ git.init unless git.init?
40
42
  existing = git.remote("get-url origin || true", capture: true, log_cmd: false)[0].strip
41
43
  return if @remote == existing
42
44
  return git.remote("add origin #{@remote}") if existing.empty?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xccache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1a3
4
+ version: 0.0.1a4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thuyen Trinh