Class: YJCocoa::GitBranch
- Defined in:
- lib/yjcocoa/git/git_branch.rb
Constant Summary
Constants inherited from Command
Instance Attribute Summary collapse
-
#addBranch ⇒ Object
property.
-
#deleteBranchs ⇒ Object
Returns the value of attribute deleteBranchs.
Class Method Summary collapse
Instance Method Summary collapse
- #gitBranchAdd ⇒ Object
- #gitBranchDelete ⇒ Object
-
#initialize(argv) ⇒ GitBranch
constructor
初始化.
- #run ⇒ Object
-
#validate! ⇒ Object
businrss.
Methods inherited from Git
Methods inherited from Command
Constructor Details
#initialize(argv) ⇒ GitBranch
初始化
36 37 38 39 40 41 |
# File 'lib/yjcocoa/git/git_branch.rb', line 36 def initialize(argv) super self.addBranch = argv.option('add') self.deleteBranchs = argv.option('delete') self.deleteBranchs = self.deleteBranchs.split(",").reject {|i| i.empty? } if self.deleteBranchs end |
Instance Attribute Details
#addBranch ⇒ Object
property
32 33 34 |
# File 'lib/yjcocoa/git/git_branch.rb', line 32 def addBranch @addBranch end |
#deleteBranchs ⇒ Object
Returns the value of attribute deleteBranchs.
33 34 35 |
# File 'lib/yjcocoa/git/git_branch.rb', line 33 def deleteBranchs @deleteBranchs end |
Class Method Details
.options ⇒ Object
26 27 28 29 |
# File 'lib/yjcocoa/git/git_branch.rb', line 26 def self. [['--add', '增加branch并推送到服务器'], ['--delete', '删除多个branch并推送到服务器'],] end |
Instance Method Details
#gitBranchAdd ⇒ Object
57 58 59 60 |
# File 'lib/yjcocoa/git/git_branch.rb', line 57 def gitBranchAdd puts "YJCocoa git add branch #{self.addBranch}".green system("git push --set-upstream origin #{self.addBranch}") if system("git checkout -b #{self.addBranch}") end |
#gitBranchDelete ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/yjcocoa/git/git_branch.rb', line 62 def gitBranchDelete puts "YJCocoa git delete branchs #{self.deleteBranchs}".green self.deleteBranchs.each { |branch| system("git branch -d #{branch}") system("git push origin --delete #{branch}") } end |
#run ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/yjcocoa/git/git_branch.rb', line 49 def run if self.addBranch self.gitBranchAdd puts end self.gitBranchDelete if self.deleteBranchs && !self.deleteBranchs.empty? end |
#validate! ⇒ Object
businrss
44 45 46 47 |
# File 'lib/yjcocoa/git/git_branch.rb', line 44 def validate! exit 0 unless self.gitExist? self. unless self.addBranch || self.deleteBranchs end |