class Dependency
Public Class Methods
new(author, git='git')
click to toggle source
# File lib/needy-git/dependency.rb, line 5 def initialize(author, git='git') @git = git @author = author end
Public Instance Methods
update(folder)
click to toggle source
# File lib/needy-git/dependency.rb, line 10 def update(folder) sh "#{@git} pull" sh "#{@git} add #{folder}" commit_and_push(folder) unless nothing_to_commit(folder) end
update_submodule(folder)
click to toggle source
# File lib/needy-git/dependency.rb, line 17 def update_submodule(folder) sh "#{@git} submodule update --init" sh "#{@git} submodule update" root_dir = Dir.pwd Dir.chdir(folder) sh "#{@git} pull origin master" Dir.chdir(root_dir) sh "#{@git} pull" commit_and_push(folder) unless nothing_to_commit(folder) end
Private Instance Methods
build_number()
click to toggle source
# File lib/needy-git/dependency.rb, line 43 def build_number return ENV["BUILD_NUMBER"].nil? ? 'N/A' : ENV["BUILD_NUMBER"] end
commit_and_push(folder)
click to toggle source
# File lib/needy-git/dependency.rb, line 38 def commit_and_push(folder) sh "#{@git} commit #{folder} --author=\"#{@author}\" -m \"Dependency Auto Commit. Build number #{build_number}.\"" sh "#{@git} push" end
nothing_to_commit(folder)
click to toggle source
# File lib/needy-git/dependency.rb, line 32 def nothing_to_commit(folder) message = `#{@git} status #{folder}` puts message return message.include?('nothing to commit') end