Sha256: c5cd0d5c13409ab311f95356d94074d45a5ed3355a07f004a639ef0f68a27cba

Contents?: true

Size: 1.17 KB

Versions: 8

Compression:

Stored size: 1.17 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: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

8 entries across 8 versions & 1 rubygems

Version Path
nixenvironment-0.0.121 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.120 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.119 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.118 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.117 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.116 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.115 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.114 lib/nixenvironment/jenkins/Modules/git_helper.rb