Class: Pixab::FeatureCopy
- Inherits:
-
Object
- Object
- Pixab::FeatureCopy
- Defined in:
- lib/feature/FeatureCopy.rb
Instance Method Summary collapse
- #create_feature_branch(feature_name) ⇒ Object
-
#initialize(isNeedPush) ⇒ FeatureCopy
constructor
A new instance of FeatureCopy.
- #run(path, feature_name) ⇒ Object
Constructor Details
#initialize(isNeedPush) ⇒ FeatureCopy
Returns a new instance of FeatureCopy.
9 10 11 |
# File 'lib/feature/FeatureCopy.rb', line 9 def initialize(isNeedPush) @isNeedPush = isNeedPush end |
Instance Method Details
#create_feature_branch(feature_name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/feature/FeatureCopy.rb', line 26 def create_feature_branch(feature_name) if !GitUtils.is_git_repo puts "当前目录不是 Git 仓库!, path: #{Dir.pwd}".red return end target_branch = GitRepoInfo.get_target_branch(feature_name) if target_branch.nil? puts "无法获取目标分支,分支:#{feature_name}".red end remote_target_branch = GitUtils.get_remote_branch_name(target_branch) if remote_target_branch.nil? puts "远程仓库不存在 #{target_branch} 分支!".red return end GitUtils.fetch_origin(target_branch) `git checkout -b #{feature_name} #{remote_target_branch}` # 是否需要推送到远程仓库 if @isNeedPush `git push -u origin #{feature_name}` end end |
#run(path, feature_name) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/feature/FeatureCopy.rb', line 13 def run(path, feature_name) unless Dir.exist?(path) puts "当前目录不存在: #{path}".red return end puts "\n#{File.basename(path)} 开始创建分支: #{feature_name}\n".green Dir.chdir(path) do create_feature_branch(feature_name) end end |