bigkeeper 0.8.3 → 0.8.4

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: b0865993502adc9ea5a674ce5201cc9d28cad25b
4
- data.tar.gz: 98224dd734ab65172620028b5a6138fa0a73d872
3
+ metadata.gz: a178ce998f09ae1fdb14f742aef17629f330d180
4
+ data.tar.gz: f827fe0abbef6453e5cced72fb2304b3b1f39382
5
5
  SHA512:
6
- metadata.gz: eb028888e708fd0156d0d1a4c03d6d107ac5f1c64b4138ecd8922e78a3048051d6f87dcf87a46b66ac0a5fb68f404463a9a13737ff9a6f4aed82a4109874d2ef
7
- data.tar.gz: fcecfc0731700f362578423571b472fa1b277421df0653e88f79ac457b06462f7618315e4597f373754c690c7b1765ca7f2a07d4d159a082a1d233a1ecfb0e9e
6
+ metadata.gz: a25c17c7db3fdb78d8500ec06e9500741414c22b9a16dc57069c3969b584c23c9b997acd048c2fdb8897394d7563deb914a82552f1ff16788960d12e6e3c35f3
7
+ data.tar.gz: d254ed1eb23b54495fe0098bbb92370618233b9598aa843bcca2ecdab9c795aefc5619c9ea5554f43a48b77517b0666b0c7e395a38ac5dbe39d1aab2d8700b58
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bigkeeper (0.8.2)
4
+ bigkeeper (0.8.3)
5
5
  big_stash (~> 0.1)
6
6
  cocoapods
7
7
  colorize
data/lib/big_keeper.rb CHANGED
@@ -12,6 +12,7 @@ require 'big_keeper/command/feature&hotfix'
12
12
  require 'big_keeper/command/release'
13
13
  require 'big_keeper/command/pod'
14
14
  require 'big_keeper/command/module'
15
+ require 'big_keeper/command/spec'
15
16
 
16
17
  require 'big_keeper/service/git_service'
17
18
 
@@ -47,6 +48,8 @@ module BigKeeper
47
48
 
48
49
  module_command
49
50
 
51
+ spec_command
52
+
50
53
  desc 'Show version of bigkeeper'
51
54
  command :version do |version|
52
55
  version.action do |global_options, options, args|
@@ -13,6 +13,6 @@ module BigKeeper
13
13
  module_list << dic
14
14
  end
15
15
  json = JSON.pretty_generate(module_list)
16
- Logger.default(json)
16
+ puts json
17
17
  end
18
18
  end
@@ -0,0 +1,39 @@
1
+ require 'big_keeper/command/spec/analyze'
2
+ require 'big_keeper/command/spec/add'
3
+ require 'big_keeper/command/spec/delete'
4
+ require 'big_keeper/command/spec/search'
5
+
6
+ module BigKeeper
7
+
8
+ def self.spec_command
9
+ desc 'spec command'
10
+
11
+ command :spec do |spec|
12
+ spec.switch [:a,:all]
13
+ spec.command :analyze do |analyze|
14
+ analyze.action do |global_options, options, args|
15
+ path = File.expand_path(global_options[:path])
16
+ is_all = options[:all]
17
+ module_names = args
18
+ spec_analyze(path, is_all, module_names)
19
+ end
20
+ end
21
+ spec.command :add do |add|
22
+ add.action do
23
+ spec_add()
24
+ end
25
+ end
26
+ spec.command :delete do |delete|
27
+ delete.action do
28
+ spec_delete()
29
+ end
30
+ end
31
+ spec.command :search do |search|
32
+ search.action do
33
+ spec_search()
34
+ end
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ require 'big_keeper/util/bigkeeper_parser'
2
+ require 'big_keeper/dependency/dep_type'
3
+ require 'big_keeper/util/logger'
4
+
5
+ module BigKeeper
6
+ def self.spec_add
7
+ puts "Hello spec_add"
8
+ end
9
+ end
@@ -0,0 +1,88 @@
1
+ require 'big_keeper/util/bigkeeper_parser'
2
+ require 'big_keeper/dependency/dep_type'
3
+ require 'big_keeper/util/logger'
4
+ require 'big_keeper/model/library_model'
5
+
6
+ module BigKeeper
7
+ def self.spec_analyze(path,is_all,find_module_names)
8
+ is_default = !is_all&&find_module_names.size==0
9
+ if is_all && find_module_names.size>0
10
+ Logger.error("parameter conflict: [--all] | [module_names]")
11
+ return
12
+ end
13
+ puts "start spec analyze..."
14
+ puts Time.now.to_s
15
+
16
+ # Parse Bigkeeper file
17
+ # BigkeeperParser.parse("#{path}/Bigkeeper")
18
+ # module_names = BigkeeperParser.module_names
19
+
20
+ # find modules
21
+ puts "get all modules..."
22
+ module_names = []
23
+ pod_path = path+"/Pods/"
24
+ dir = Dir.open(pod_path)
25
+ dir.each do |dir_name|
26
+ if !dir_name.include?(".") && dir_name != "Headers" && dir_name != "Local Podspecs" && dir_name != "Target Support Files"
27
+ module_names[module_names.size]=dir_name
28
+ end
29
+ end
30
+
31
+ is_legal = true
32
+ for input_moudle_name in find_module_names do
33
+ if !module_names.include?(input_moudle_name)
34
+ is_legal = false
35
+ Logger.error("["+input_moudle_name+"] not exist.")
36
+ end
37
+ end
38
+ if !is_legal
39
+ return
40
+ end
41
+
42
+ # setup modules
43
+ module_list = []
44
+ module_keyword_map = Hash.new
45
+ file_count = 0
46
+ for module_name in module_names do
47
+ library = LibraryModel.new(module_name)
48
+ library.get_all_public_file(path)
49
+ module_list[module_list.size]=library
50
+ module_keyword_map[module_name]=library.keyword_list
51
+ if is_all || find_module_names.include?(library.name)
52
+ file_count = file_count + library.file_list.size
53
+ end
54
+ end
55
+ # analyze modules spec
56
+
57
+ puts "analyze modules "+Time.now.to_s
58
+ file_index = 0
59
+ for library in module_list do
60
+ if is_all || find_module_names.include?(library.name)
61
+ puts "analyzing "+library.name
62
+ file_index = file_index + library.file_list.size
63
+ library.spec_dependece_library(module_keyword_map.clone)#(Hash.new(module_keyword_map)).to_hash)
64
+ progress = (file_index*100.0)/file_count
65
+ progress = format("%.02f", progress).to_f
66
+ puts "progress >>>> "+String(progress)+"% ["+library.name+" done] "
67
+ end
68
+ end
69
+ puts "analyze complete "+Time.now.to_s
70
+
71
+ # log spec info
72
+ for library in module_list do
73
+ if is_all || find_module_names.include?(library.name)
74
+ Logger.highlight("\n-"+library.name+":")
75
+ for spec_library in library.spec_library do
76
+ puts " -"+spec_library
77
+ end
78
+ end
79
+ end
80
+
81
+ # save cache to file
82
+ if is_all
83
+
84
+ end
85
+
86
+ end
87
+
88
+ end
@@ -0,0 +1,9 @@
1
+ require 'big_keeper/util/bigkeeper_parser'
2
+ require 'big_keeper/dependency/dep_type'
3
+ require 'big_keeper/util/logger'
4
+
5
+ module BigKeeper
6
+ def self.spec_delete
7
+ puts "Hello spec_delete"
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'big_keeper/util/bigkeeper_parser'
2
+ require 'big_keeper/dependency/dep_type'
3
+ require 'big_keeper/util/logger'
4
+
5
+ module BigKeeper
6
+ def self.spec_search
7
+ puts "Hello spec_search"
8
+ end
9
+ end
@@ -0,0 +1,116 @@
1
+ require 'big_keeper/util/file_operator'
2
+ require 'big_keeper/util/code_operator'
3
+
4
+
5
+ module BigKeeper
6
+ class LibraryModel
7
+ attr_accessor :name, :file_list, :header_file_list, :keyword_list, :spec_library
8
+ def initialize(name)
9
+ @name = name
10
+ @file_list = []
11
+ @header_file_list = []
12
+ @spec_library = []
13
+ @keyword_list = []
14
+ end
15
+
16
+ def get_all_public_file(path)
17
+ all_header = FileOperator.find_all_header_file("#{path}/Pods/#{@name}")
18
+ for file_path in all_header do
19
+ @header_file_list[@header_file_list.size] = file_path
20
+ file_name = File.basename(file_path)
21
+ @keyword_list[@keyword_list.size] = file_name
22
+ in_note = false
23
+ File.foreach(file_path) { |line|
24
+ hash = Hash.new
25
+ hash["in_note"]=in_note
26
+ hash["line"]=line
27
+ OCCodeOperator.in_note_code(hash)
28
+ in_note = hash["in_note"]
29
+ line = hash["line"]
30
+ if line.empty?
31
+ next
32
+ end
33
+ if line.include?("@interface ")
34
+ line[0,line.index("@interface ")+11]=""
35
+ column = line.split(/:/)
36
+ if column.size > 1
37
+ class_name = column[0]
38
+ if class_name.include?("<")
39
+ class_name = class_name[0, class_name.index("<")]
40
+ end
41
+ class_name = class_name.strip
42
+ if (@keyword_list.include?(class_name+".h"))
43
+ @keyword_list.delete(class_name+".h")
44
+ end
45
+ @keyword_list[@keyword_list.size] = class_name
46
+ end
47
+ end
48
+ }
49
+ end
50
+ # if @name == ""
51
+ # puts @keyword_list
52
+ # end
53
+ @file_list = FileOperator.find_all_code_file("#{path}/Pods/#{@name}")
54
+ end
55
+
56
+ def spec_dependece_library(library_keywords_hash)
57
+ if library_keywords_hash.include?(@name)
58
+ library_keywords_hash.delete(@name)
59
+ end
60
+
61
+ for file_path in @file_list do
62
+ # note for coding
63
+ in_note = false
64
+ File.foreach(file_path) { |line|
65
+ hash = Hash.new
66
+ hash["in_note"]=in_note
67
+ hash["line"]=line
68
+ OCCodeOperator.in_note_code(hash)
69
+ in_note = hash["in_note"]
70
+ line = hash["line"]
71
+ if line.empty?
72
+ next
73
+ end
74
+ library_keywords_hash.each {|library_name, keyword_list|
75
+ is_dependence = false
76
+ tip = ""
77
+ for keyword in keyword_list do
78
+ if line.include?(keyword)
79
+ last_char = '.'
80
+ last_index = line.index(keyword)-1
81
+ if last_index >= 0
82
+ last_char = line[last_index]
83
+ end
84
+ next_char = '.'
85
+ next_index = line.index(keyword)+keyword.size
86
+ if next_index < line.size
87
+ next_char = line[next_index]
88
+ end
89
+ if !(((next_char<='z'&&next_char>='a')||(next_char<='Z'&&next_char>='A')||(next_char<='9'&&next_char>='0')||next_char=='_')||((last_char<='z'&&last_char>='a')||(last_char<='Z'&&last_char>='A')||(last_char<='9'&&last_char>='0')||last_char=='_'))
90
+ if keyword.include?(".h") && line.include?("import") && line.include?("/"+keyword+">")
91
+ dependence_library_name = line[line.index("<")+1...line.index("/"+keyword+">")]
92
+ if dependence_library_name == library_name
93
+ tip = " [file]:"+File.basename(file_path)+" [line]: "+line.strip+" [keyword]: "+keyword
94
+ is_dependence = true
95
+ break
96
+ end
97
+ else
98
+ tip = " [file]:"+File.basename(file_path)+" [line]: "+line.strip+" [keyword]: "+keyword
99
+ is_dependence = true
100
+ break
101
+ end
102
+ end
103
+ end
104
+ end
105
+ if is_dependence
106
+ @spec_library[@spec_library.size] = library_name+tip
107
+ library_keywords_hash.delete(library_name)
108
+ end
109
+ }
110
+
111
+ }
112
+ end
113
+ end
114
+
115
+ end
116
+ end
@@ -0,0 +1,37 @@
1
+ module BigKeeper
2
+
3
+ class OCCodeOperator
4
+ end
5
+
6
+ class << OCCodeOperator
7
+
8
+ def in_note_code(line_hash)
9
+ line = line_hash["line"]
10
+ in_note = line_hash["in_note"]
11
+ line = line.strip
12
+ if in_note
13
+ line_hash["line"]=""
14
+ if (line.include?("*/"))
15
+ line_hash["in_note"] = false
16
+ end
17
+ return
18
+ end
19
+ if line[0,2] == "//" || line[0,7] == "#pragma"
20
+ line_hash["line"]=""
21
+ return
22
+ end
23
+ if line.include?("/*")
24
+ line_hash["in_note"] = true
25
+ before_line = line[line.index("/*")+1...line.size]
26
+ if before_line.include?("*/")
27
+ line_hash["in_note"] = false
28
+ end
29
+ line_hash["line"] = line[0,line.index("/*")]
30
+ return
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -16,6 +16,18 @@ module BigKeeper
16
16
  current_name = `whoami`
17
17
  current_name.chomp
18
18
  end
19
-
19
+
20
+ end
21
+
22
+ class << FileOperator
23
+ def find_all_header_file(path)
24
+ return Dir.glob("#{path}/**/*.h")
25
+ end
26
+ def find_all_code_file(path)
27
+ header_file_list = Dir.glob("#{path}/**/*.[h]")
28
+ m_file_list = Dir.glob("#{path}/**/*.[m]")
29
+ return header_file_list+m_file_list
30
+ end
20
31
  end
32
+
21
33
  end
@@ -9,6 +9,7 @@ module BigKeeper
9
9
  json_data = File.read(file_path)
10
10
  module_branches_dic = JSON.parse(json_data)
11
11
  to_tree(module_branches_dic, home_branches, version)
12
+ File.delete(file_path)
12
13
  end
13
14
 
14
15
  #generate json print throught console
@@ -18,6 +19,7 @@ module BigKeeper
18
19
  module_branches_dic = JSON.parse(json_data)
19
20
  json = to_json(home_branches, module_branches_dic, version)
20
21
  puts JSON.pretty_generate(json)
22
+ File.delete(file_path)
21
23
  end
22
24
 
23
25
  def self.to_json(home_branches, module_info_list, version)
@@ -31,7 +33,7 @@ module BigKeeper
31
33
  next unless module_info_dic["branches"] != nil
32
34
  module_name = module_info_dic["module_name"]
33
35
  module_info_dic["branches"].each do | module_branch |
34
- if module_branch.strip.delete("*") == home_branch_name
36
+ if module_branch.strip.delete("*") == home_branch_name.strip.delete("*")
35
37
  module_current_info = {}
36
38
  module_current_info["module_name"] = module_name
37
39
  module_current_info["current_branch"] = module_info_dic["current_branch"]
@@ -41,6 +43,8 @@ module BigKeeper
41
43
  end
42
44
 
43
45
  branch_dic["is_remote"] = false
46
+ branch_dic["is_current"] = false
47
+
44
48
  if home_branch_name =~ /^remotes\//
45
49
  home_branch_name = $~.post_match
46
50
  branch_dic["is_remote"] = true
@@ -50,6 +54,11 @@ module BigKeeper
50
54
  home_branch_name = $~.post_match
51
55
  end
52
56
 
57
+ if home_branch_name.include?("*")
58
+ home_branch_name = home_branch_name.delete("*")
59
+ branch_dic["is_current"] = true
60
+ end
61
+
53
62
  if home_branch_name =~ /^feature\//
54
63
  home_branch_name = $~.post_match
55
64
  end
@@ -1,3 +1,3 @@
1
1
  module BigKeeper
2
- VERSION = "0.8.3"
2
+ VERSION = "0.8.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmoaay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-22 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -242,12 +242,18 @@ files:
242
242
  - lib/big_keeper/command/release.rb
243
243
  - lib/big_keeper/command/release/home.rb
244
244
  - lib/big_keeper/command/release/module.rb
245
+ - lib/big_keeper/command/spec.rb
246
+ - lib/big_keeper/command/spec/add.rb
247
+ - lib/big_keeper/command/spec/analyze.rb
248
+ - lib/big_keeper/command/spec/delete.rb
249
+ - lib/big_keeper/command/spec/search.rb
245
250
  - lib/big_keeper/dependency/dep_gradle_operator.rb
246
251
  - lib/big_keeper/dependency/dep_operator.rb
247
252
  - lib/big_keeper/dependency/dep_pod_operator.rb
248
253
  - lib/big_keeper/dependency/dep_service.rb
249
254
  - lib/big_keeper/dependency/dep_type.rb
250
255
  - lib/big_keeper/model/gitflow_type.rb
256
+ - lib/big_keeper/model/library_model.rb
251
257
  - lib/big_keeper/model/operate_type.rb
252
258
  - lib/big_keeper/model/podfile_model.rb
253
259
  - lib/big_keeper/service/git_service.rb
@@ -255,6 +261,7 @@ files:
255
261
  - lib/big_keeper/service/stash_service.rb
256
262
  - lib/big_keeper/util/bigkeeper_parser.rb
257
263
  - lib/big_keeper/util/cache_operator.rb
264
+ - lib/big_keeper/util/code_operator.rb
258
265
  - lib/big_keeper/util/file_operator.rb
259
266
  - lib/big_keeper/util/git_operator.rb
260
267
  - lib/big_keeper/util/gitflow_operator.rb