Class: YJCocoa::GitPull
- Defined in:
- lib/yjcocoa/git/git_pull.rb
Constant Summary
Constants inherited from Command
Instance Attribute Summary collapse
-
#all ⇒ Object
property.
-
#gits ⇒ Object
git array.
Class Method Summary collapse
Instance Method Summary collapse
- #buildGitPaths ⇒ Object
- #gitPull(path = ".") ⇒ Object
-
#initialize(argv) ⇒ GitPull
constructor
初始化.
-
#run ⇒ Object
businrss.
Methods inherited from Git
Methods inherited from Command
Constructor Details
#initialize(argv) ⇒ GitPull
初始化
29 30 31 32 |
# File 'lib/yjcocoa/git/git_pull.rb', line 29 def initialize(argv) super self.all = argv.flag?('all', false) end |
Instance Attribute Details
#all ⇒ Object
property
25 26 27 |
# File 'lib/yjcocoa/git/git_pull.rb', line 25 def all @all end |
#gits ⇒ Object
git array
26 27 28 |
# File 'lib/yjcocoa/git/git_pull.rb', line 26 def gits @gits end |
Class Method Details
.options ⇒ Object
20 21 22 |
# File 'lib/yjcocoa/git/git_pull.rb', line 20 def self. [['--all', 'pull all branch'],] end |
Instance Method Details
#buildGitPaths ⇒ Object
48 49 50 51 52 53 |
# File 'lib/yjcocoa/git/git_pull.rb', line 48 def buildGitPaths self.gits = Dir["**/.git"] self.gits.map! { |path| File.dirname(path) } end |
#gitPull(path = ".") ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/yjcocoa/git/git_pull.rb', line 55 def gitPull(path=".") thread = Thread.new { Dir.chdir(path) { puts "YJCocoa git pull #{path}/.git".green localChanges = !(`git stash` =~ /No local changes to save/) system("git pull -p") if self.all list = (`git branch`).split("\n") if list.size >= 2 headBranch = "master" list.each { |item| if item =~ /\* / headBranch = item.gsub(/\* /, "") else `git checkout #{item}` system("git pull") end } `git checkout #{headBranch}` end end `git stash pop` if localChanges puts } } thread.join end |
#run ⇒ Object
businrss
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/yjcocoa/git/git_pull.rb', line 35 def run self.buildGitPaths if self.gits.empty? if self.gitExist? self.gitPull end else self.gits.each { |path| self.gitPull(path) } end end |