Class: Pixab::Feature
- Inherits:
-
Object
- Object
- Pixab::Feature
- Defined in:
- lib/feature/Feature.rb
Instance Method Summary collapse
- #ensure_feature_prefix(feature_name) ⇒ Object
- #featureCopy(commands, index, isNeedPush) ⇒ Object
- #featureStart(commands, index, isNeedPush) ⇒ Object
- #run(commands = nil) ⇒ Object
Instance Method Details
#ensure_feature_prefix(feature_name) ⇒ Object
70 71 72 |
# File 'lib/feature/Feature.rb', line 70 def ensure_feature_prefix(feature_name) feature_name.start_with?('feature') ? feature_name : "feature/#{feature_name}" end |
#featureCopy(commands, index, isNeedPush) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/feature/Feature.rb', line 51 def featureCopy(commands, index, isNeedPush) git_repos = UserInfo.new.git_sub_repos if git_repos.empty? puts "No Git repositories found.".red return end feature_name = GitRepoInfo.new.branch if feature_name.nil? puts "无法获取当前分支名称".red return end feature_copy = FeatureCopy.new(isNeedPush) git_repos.each do |repo| feature_copy.run(repo, feature_name) end end |
#featureStart(commands, index, isNeedPush) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/feature/Feature.rb', line 31 def featureStart(commands, index, isNeedPush) git_repos = UserInfo.new.git_repos if git_repos.empty? puts "No Git repositories found.".red return end feature_name = commands[index + 1] if feature_name.nil? puts "请输入要创建的分支名称".red return end feature_name = ensure_feature_prefix(feature_name) feature_start = FeatureStart.new(isNeedPush) git_repos.each do |repo| feature_start.run(repo, feature_name) end end |
#run(commands = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/feature/Feature.rb', line 9 def run(commands = nil) isNeedPush = true commands.each_index do |index| command = commands[index] case command when '--no-push' isNeedPush = false end end commands.each_index do |index| command = commands[index] case command when 'start' featureStart(commands, index, isNeedPush) when 'copy' featureCopy(commands, index, isNeedPush) end end end |