Sha256: 863cebb68898c273d636fc0cdfa5b116920db079bf72c49181ccceaee6775164

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

require_relative 'paths'

module GitHelper
    include Paths
    
    private
    def repos_changed
        `git fetch origin 1>/dev/null`
        `git diff origin/master` != ''
    end

    public
    def clone_environment
        FileUtils.mkdir_p(path_to_environment)
        
        Dir.chdir(path_to_environment) { `git clone git@nix.githost.io.write:NIX_iPhone_Internal/IJE.git .` }
    end
    
    def clone_provisioning_updater
        FileUtils.mkdir_p(path_to_provisioning_updater)
        
        Dir.chdir(path_to_provisioning_updater) { `git clone git@nix.githost.io:NIX_iPhone_Internal/NPU.git .` }
    end
    
    def set_git_hook(&hook_block)
        Thread.new do
            Dir.chdir(path_to_environment) do
                while true
                    if repos_changed
                        `git pull`
                        hook_block.call()
                    end
                    
                    sleep(15)
                end
            end  
        end
    end
    
    def remove_local_environment
        FileUtils.rm_rf(path_to_environment)
    end
    
    def remove_local_provisioning_updater
        FileUtils.rm_rf(path_to_provisioning_updater)
    end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
nixenvironment-0.0.133 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.132 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.131 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.130 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.129 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.127 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.125 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.124 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.122 lib/nixenvironment/jenkins/Modules/git_helper.rb