Sha256: 192c6ca0a79ea7f4f03cb0b0c3c2ea36441e3c35cc7336b49bb89e59f8c980a7

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 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) do
            unless system('git clone git@nix.githost.io.write:NIX_iPhone_Internal/IJE.git .')
              if system('git clone https://nix.githost.io/NIX_iPhone_Internal/IJE.git .')
                `git remote set-url origin git@nix.githost.io.write:NIX_iPhone_Internal/IJE.git`
              end
            end
        end
    end
    
    def clone_provisioning_updater
        FileUtils.mkdir_p(path_to_provisioning_updater)

        Dir.chdir(path_to_provisioning_updater) do
          unless system('git clone git@nix.githost.io:NIX_iPhone_Internal/NPU.git .')
            if system('git clone https://nix.githost.io/NIX_iPhone_Internal/NPU.git .')
              `git remote set-url origin git@nix.githost.io:NIX_iPhone_Internal/NPU.git`
            end
          end
        end
    end
    
    def set_git_hook
        Thread.new do
            Dir.chdir(path_to_environment) do
                loop do
                    if repos_changed
                        `git pull`
                        yield
                    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

15 entries across 15 versions & 1 rubygems

Version Path
nixenvironment-0.0.141 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.147 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.146 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.145 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.144 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.143 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.142 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.138.1 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.138 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.140 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.139 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.137 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.136 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.135 lib/nixenvironment/jenkins/Modules/git_helper.rb
nixenvironment-0.0.134 lib/nixenvironment/jenkins/Modules/git_helper.rb