fontana_client_support 0.8.0 → 0.8.1

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
  SHA1:
3
- metadata.gz: fbb4703a07cc90d6464574b2496b1d190d57ab2f
4
- data.tar.gz: 81c6792dd383c7b0f4ab7b0676b435ae40a9909c
3
+ metadata.gz: dd1df0580d18385443b09b58a9e84e912c86ae3b
4
+ data.tar.gz: a16226f93506b90fa281cd84d9f0c631d5bcc2c4
5
5
  SHA512:
6
- metadata.gz: 640166a805a597dc89d3a10d06a41e13ddc526fde925dd778e9959ccb28f7107623f0c52007e7e12edcef9d2e8c577aab30313c593741e831f4a5ff2e299213a
7
- data.tar.gz: 0ce01a1e42df1ea0a74e0cb2f9f7a47b20404ba0cae8c969e4316c3d00b03a0c5a7cd4221c82121747ca24604cd24f4af192859c734bcd1c7bc4bd00f077632d
6
+ metadata.gz: 6c20ca74ea7432989b4483dd21e568c512c3ba7a9d7c12c52d93e856da3969c38cdd2854fe732d543e44e055c19c2feabdecddfd26d036998b88bc266ec7c737
7
+ data.tar.gz: 5ed88c5ee9328d00aaa374a80b2567b4ae75cf97e3a8b53af5d9ef59747c228da94f515d2de1a8a2f34e80c6a7749dcadad30e46bb9b732758fcfcd3075dfe48
@@ -8,12 +8,13 @@ namespace :deploy do
8
8
  namespace_with_fontana :scm, :"app:scm" do
9
9
 
10
10
  set_url_and_branch = ->{
11
- ENV['URL'] ||= FontanaClientSupport.repo_url
12
- ENV['BRANCH'] ||= FontanaClientSupport.current_branch_name
13
11
  }
14
12
 
15
13
  desc "deploy:scm:setup + clone (+ checkout branch) + deploy:scm:update."
16
- fontana_task :reset, before: set_url_and_branch
14
+ fontana_task :reset, env: {
15
+ 'URL' => FontanaClientSupport.repo_url,
16
+ 'BRANCH' => FontanaClientSupport.current_branch_name
17
+ }
17
18
 
18
19
  desc "drop DB, initialize, clear runtime workspace."
19
20
  fontana_task :setup
@@ -22,8 +22,10 @@ namespace :vendor do
22
22
  end
23
23
 
24
24
  def vendor_fontana_branch
25
- # http://qiita.com/sugyan/items/83e060e895fa8ef2038c
26
- `git symbolic-ref --short HEAD`.strip
25
+ return nil unless Dir.exist?(FontanaClientSupport.vendor_fontana)
26
+ Dir.chdir(FontanaClientSupport.vendor_fontana) do
27
+ return FontanaClientSupport.git_current_branch_name
28
+ end
27
29
  end
28
30
 
29
31
  def raise_if_fontana_branch_empty
@@ -133,7 +135,7 @@ namespace :vendor do
133
135
 
134
136
  elsif vfb != Fontana.branch
135
137
  # vendor/fontanaのブランチが FONTANA_BRANCH と異なる場合
136
- puts "\e[33m but FONTANA_BRANCH is #{Fontana.branch}\e[0m"
138
+ # puts "\e[33m but FONTANA_BRANCH is #{Fontana.branch}\e[0m"
137
139
  Rake::Task["vendor:fontana:reset"].delegate
138
140
 
139
141
  elsif Fontana.version.nil? || Fontana.version.empty?
@@ -1,3 +1,3 @@
1
1
  module FontanaClientSupport
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -15,8 +15,17 @@ module FontanaClientSupport
15
15
  @vendor_fontana ||= File.join(vendor_dir, "fontana")
16
16
  end
17
17
 
18
- def current_branch_name
19
- @current_branch_name ||= `git symbolic-ref --short HEAD`.strip
18
+ def git_current_branch_name
19
+ # http://qiita.com/sugyan/items/83e060e895fa8ef2038c
20
+ result = `git symbolic-ref --short HEAD`.strip
21
+ return result unless result.nil? || result.empty?
22
+ result = `git status`.scan(/On branch\s*(.+)\s*$/).flatten.first
23
+ return result unless result.nil? || result.empty?
24
+ work = `git log --decorate -1`.scan(/^commit\s[0-9a-f]+\s\((.+)\)/).
25
+ flatten.first.split(/,/).map(&:strip).reject{|s| s =~ /HEAD\Z/}
26
+ r = work.select{|s| s =~ /origin\//}.first
27
+ r ||= work.first
28
+ result = r.sub(/\Aorigin\//, '')
20
29
  rescue => e
21
30
  puts "[#{e.class}] #{e.message}"
22
31
  puts "Dir.pwd: #{Dir.pwd}"
@@ -24,6 +33,18 @@ module FontanaClientSupport
24
33
  raise e
25
34
  end
26
35
 
36
+ def current_branch_name
37
+ raise "missing root_dir" if root_dir.nil?
38
+ raise "root_dir does not exist: #{root_dir.inspect}" unless Dir.exist?(root_dir)
39
+ unless @current_branch_name
40
+ Dir.chdir(root_dir) do
41
+ @current_branch_name = git_current_branch_name
42
+ end
43
+ end
44
+ puts "@current_branch_name: #{@current_branch_name.inspect}"
45
+ return @current_branch_name
46
+ end
47
+
27
48
  def repo_url
28
49
  @repo_url ||= `git remote -v`.scan(/origin\s+(.+?)\s/).flatten.uniq.first
29
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontana_client_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - akima