big_keeper 0.2.0 → 0.3.0

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: 614030e993375adb543b94c896f0a9c140e1aeb7
4
- data.tar.gz: ee9dae88f9b0f8057907240b11a0bc4d74cd1a43
3
+ metadata.gz: 52955ae921730c15a2fdb6f0f82153d78bea2739
4
+ data.tar.gz: 52760849a27d986991b9ea512b31a36bbd7ad9ca
5
5
  SHA512:
6
- metadata.gz: 1e407a4b7fcdc8c12247476dca57d04df0bf159d66d360235d06f45870e877b6c525c8730327e57f64063335c8904e29b59b2ff8f72e3d7f8c7f39db8f3e50b4
7
- data.tar.gz: 567f52bb566f129a5bd6e232d3c1269a3b18df5afeb7c3f7f0ff994950ec22ab06b618a848c2a4a0168cee0e28793a720bf23c40f353133781ea9829b6fb12f6
6
+ metadata.gz: 2099cceb030a28c55f9b6f6e776e238fbdb26cae48a8f4082c0c6ac00115da47c878fc89e2b63cf2690758de23bec4ef10a8bcbde1177ae68ea750674ffeb4bc
7
+ data.tar.gz: fc6c444d0abb77deea22741ab4ea2dcd2279d11e2bb62d195c7eeadff72f4c2585e444c800859d7ec64de95dceba67e8623bd779c8d0b61637dede46113b27aa
data/Gemfile.lock CHANGED
@@ -2,6 +2,10 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  big_keeper (0.2.0)
5
+ big_stash (~> 0.1)
6
+ cocoapods
7
+ gli (~> 2.16)
8
+ plist
5
9
 
6
10
  GEM
7
11
  remote: https://ruby.taobao.org/
data/big_keeper.gemspec CHANGED
@@ -30,6 +30,11 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
+ spec.add_runtime_dependency "gli", "~> 2.16"
34
+ spec.add_runtime_dependency "big_stash", "~> 0.1"
35
+ spec.add_runtime_dependency "cocoapods"
36
+ spec.add_runtime_dependency "plist"
37
+
33
38
  spec.add_development_dependency "bundler", "~> 1.15"
34
39
  spec.add_development_dependency "rake", "~> 10.0"
35
40
  spec.add_development_dependency "gli", "~> 2.16"
@@ -38,12 +38,7 @@ module BigKeeper
38
38
  end
39
39
 
40
40
  # Start home feature
41
- GitOperator.new.git_checkout(path, 'master') if GitOperator.new.has_remote_branch(path, 'master')
42
- GitOperator.new.git_checkout(path, 'develop') if GitOperator.new.has_remote_branch(path, 'develop')
43
-
44
- GitOperator.new.pull(path, 'develop') if GitOperator.new.has_remote_branch(path, 'develop')
45
-
46
- GitflowOperator.new.start(path, feature_name, GitflowType::FEATURE)
41
+ GitService.new.start(path, feature_name, GitflowType::FEATURE)
47
42
 
48
43
  # Modify podfile as path and Start modules feature
49
44
  modules.each do |module_name|
@@ -5,6 +5,48 @@ require 'big_keeper/model/operate_type'
5
5
  module BigKeeper
6
6
  # Operator for got
7
7
  class GitService
8
+ def start(path, name, type)
9
+ if GitOperator.new.has_remote_branch(path, 'master')
10
+ if GitOperator.new.has_local_branch(path, 'master')
11
+ if GitOperator.new.has_commits(path, 'master')
12
+ raise %Q('master' has unpushed commits, you should fix it)
13
+ else
14
+ GitOperator.new.git_checkout(path, 'master')
15
+ GitOperator.new.pull(path, 'master')
16
+ end
17
+ else
18
+ GitOperator.new.git_checkout(path, 'master')
19
+ end
20
+ end
21
+
22
+ if GitOperator.new.has_remote_branch(path, 'develop')
23
+ if GitOperator.new.has_local_branch(path, 'develop')
24
+ if GitOperator.new.has_commits(path, 'develop')
25
+ raise %Q('develop' has unpushed commits, you should fix it)
26
+ else
27
+ GitOperator.new.git_checkout(path, 'develop')
28
+ GitOperator.new.pull(path, 'develop')
29
+ end
30
+ else
31
+ GitOperator.new.git_checkout(path, 'develop')
32
+ end
33
+ end
34
+
35
+ if !GitflowOperator.new.verify_git_flow(path)
36
+ GitOperator.new.push(path, 'develop') if !GitOperator.new.has_remote_branch(path, 'develop')
37
+ GitOperator.new.push(path, 'master') if !GitOperator.new.has_remote_branch(path, 'master')
38
+ end
39
+
40
+ branch_name = "#{GitflowType.name(type)}/#{name}"
41
+ if GitOperator.new.has_branch(path, branch_name)
42
+ GitOperator.new.git_checkout(path, branch_name)
43
+ GitOperator.new.pull(path, branch_name)
44
+ else
45
+ GitflowOperator.new.start(path, name, type)
46
+ GitOperator.new.push(path, branch_name)
47
+ end
48
+ end
49
+
8
50
  def verify_branch(path, branch_name, type)
9
51
  GitOperator.new.git_fetch(path)
10
52
 
@@ -63,13 +63,7 @@ module BigKeeper
63
63
  GitOperator.new.clone(File.expand_path("#{module_full_path}/../"), module_git)
64
64
  end
65
65
 
66
- GitOperator.new.git_checkout(module_full_path, 'master') if GitOperator.new.has_remote_branch(module_full_path, 'master')
67
- GitOperator.new.git_checkout(module_full_path, 'develop') if GitOperator.new.has_remote_branch(module_full_path, 'develop')
68
-
69
- GitOperator.new.pull(module_full_path, 'develop') if GitOperator.new.has_remote_branch(module_full_path, 'develop')
70
-
71
- GitflowOperator.new.start(module_full_path, name, type)
72
- GitOperator.new.push(module_full_path, branch_name)
66
+ GitService.new.start(module_full_path, name, type)
73
67
 
74
68
  BigStash::StashOperator.new(module_full_path).apply_stash(branch_name)
75
69
 
@@ -9,9 +9,19 @@ module BigKeeper
9
9
 
10
10
  def has_remote_branch(path, branch_name)
11
11
  has_branch = false
12
- IO.popen("cd #{path}; git branch -a") do |io|
12
+ IO.popen("cd #{path}; git branch -r") do |io|
13
13
  io.each do |line|
14
- has_branch = true if line =~ /remotes\/origin\/#{branch_name}/
14
+ has_branch = true if line.include? branch_name
15
+ end
16
+ end
17
+ has_branch
18
+ end
19
+
20
+ def has_local_branch(path, branch_name)
21
+ has_branch = false
22
+ IO.popen("cd #{path}; git branch") do |io|
23
+ io.each do |line|
24
+ has_branch = true if line.include? branch_name
15
25
  end
16
26
  end
17
27
  has_branch
@@ -70,6 +80,16 @@ module BigKeeper
70
80
  end
71
81
  end
72
82
 
83
+ def has_commits(path, branch_name)
84
+ has_commits = false
85
+ IO.popen("cd #{path}; git log --branches --not --remotes") do |io|
86
+ io.each do |line|
87
+ has_commits = true if line.include? branch_name
88
+ end
89
+ end
90
+ has_commits
91
+ end
92
+
73
93
  def has_changes(path)
74
94
  has_changes = true
75
95
  clear_flag = 'nothing to commit, working tree clean'
@@ -4,26 +4,26 @@ module BigKeeper
4
4
  # Operator for gitflow
5
5
  class GitflowOperator
6
6
  def start(path, name, type)
7
- init_git_flow(path)
8
7
  Dir.chdir(path) do
9
8
  gitflow_type_name = GitflowType.name(type)
10
9
  p `git flow #{gitflow_type_name} start #{name}`
11
10
  end
12
11
  end
13
12
 
14
- def init_git_flow(path)
13
+ def verify_git_flow(path)
14
+ has_git_flow = false
15
15
  Dir.chdir(path) do
16
16
  clear_flag = 'Already initialized for gitflow'
17
17
  IO.popen('git flow init -d') do |io|
18
18
  io.each do |line|
19
- if !line.include? clear_flag
20
- GitOperator.new.push(module_full_path, 'master') if !GitOperator.new.has_remote_branch(module_full_path, 'master')
21
- GitOperator.new.push(module_full_path, 'develop') if !GitOperator.new.has_remote_branch(module_full_path, 'develop')
19
+ if line.include? clear_flag
20
+ has_git_flow = true
22
21
  break
23
22
  end
24
23
  end
25
24
  end
26
25
  end
26
+ has_git_flow
27
27
  end
28
28
 
29
29
  def finish_release(path, release_name)
@@ -1,3 +1,3 @@
1
1
  module BigKeeper
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/big_keeper.rb CHANGED
@@ -28,27 +28,26 @@ module BigKeeper
28
28
 
29
29
  flag %i[p path], default_value: './'
30
30
  flag %i[v ver], default_value: 'Version in Bigkeeper file'
31
+ flag %i[u user], default_value: GitOperator.new.user
31
32
 
32
33
  path = ''
33
34
  version = ''
35
+ user = GitOperator.new.user
34
36
 
35
37
  pre do |global_options, _command, options, args|
36
38
  path = File.expand_path(global_options[:path])
37
39
  version = global_options[:ver]
40
+ user = global_options[:user]
38
41
  end
39
42
 
40
43
  desc 'Feature operations'
41
44
  command :feature do |c|
42
45
 
43
- c.flag %i[u user], default_value: GitOperator.new.user
44
- user = GitOperator.new.user
45
- c.pre do |global_options, _command, options, args|
46
- user = global_options[:user]
47
- end
48
-
49
46
  c.desc 'Start a new feature with name for given modules and main project'
50
47
  c.command :start do |start|
51
48
  start.action do |global_options, options, args|
49
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
50
+ help_now!('user name is required') if user and user.empty?
52
51
  help_now!('feature name is required') if args.length < 1
53
52
  name = args[0]
54
53
  modules = args[(1...args.length)] if args.length > 1
@@ -59,6 +58,8 @@ module BigKeeper
59
58
  c.desc 'Update moduels for the feature with name'
60
59
  c.command :update do |update|
61
60
  update.action do |global_options, options, args|
61
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
62
+ help_now!('user name is required') if user and user.empty?
62
63
  modules = args[(0...args.length)] if args.length > 0
63
64
  feature_update(path, user, modules)
64
65
  end
@@ -67,6 +68,8 @@ module BigKeeper
67
68
  c.desc 'Switch to the feature with name'
68
69
  c.command :switch do |switch|
69
70
  switch.action do |global_options, options, args|
71
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
72
+ help_now!('user name is required') if user and user.empty?
70
73
  help_now!('feature name is required') if args.length < 1
71
74
  name = args[0]
72
75
  feature_switch(path, version, user, name)
@@ -76,6 +79,8 @@ module BigKeeper
76
79
  c.desc 'Pull remote changes for current feature'
77
80
  c.command :pull do |pull|
78
81
  pull.action do |global_options, options, args|
82
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
83
+ help_now!('user name is required') if user and user.empty?
79
84
  feature_pull(path, user)
80
85
  end
81
86
  end
@@ -83,6 +88,8 @@ module BigKeeper
83
88
  c.desc 'Push local changes to remote for current feature'
84
89
  c.command :push do |push|
85
90
  push.action do |global_options, options, args|
91
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
92
+ help_now!('user name is required') if user and user.empty?
86
93
  help_now!('comment message is required') if args.length < 1
87
94
  comment = args[0]
88
95
  feature_push(path, user, comment)
@@ -92,6 +99,8 @@ module BigKeeper
92
99
  c.desc 'Finish current feature'
93
100
  c.command :finish do |finish|
94
101
  finish.action do |global_options, options, args|
102
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
103
+ help_now!('user name is required') if user and user.empty?
95
104
  feature_finish(path, user)
96
105
  end
97
106
  end
@@ -110,12 +119,6 @@ module BigKeeper
110
119
  desc 'Release operations'
111
120
  command :release do |c|
112
121
 
113
- c.flag %i[u user], default_value: GitOperator.new.user
114
- user = GitOperator.new.user
115
- c.pre do |global_options, _command, options, args|
116
- user = global_options[:user]
117
- end
118
-
119
122
  c.desc 'Release home project operations'
120
123
  c.command :home do |home|
121
124
  home.desc 'Start release home project'
@@ -125,6 +128,8 @@ module BigKeeper
125
128
  # version(optional): if null, will read verson in Bigkeeper file
126
129
  # e.g: ruby big_keeper.rb -p /Users/SFM/Downloads/BigKeeperMain-master
127
130
  # /Bigkeeper -v 3.0.0 release home start
131
+ user = user.gsub(/[^0-9A-Za-z]/, '').downcase
132
+ help_now!('user name is required') if user and user.empty?
128
133
  release_home_start(path, version, user)
129
134
  end
130
135
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: big_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmoaay
@@ -10,6 +10,62 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.16'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: big_stash
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: plist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
13
69
  - !ruby/object:Gem::Dependency
14
70
  name: bundler
15
71
  requirement: !ruby/object:Gem::Requirement