Sha256: 7b25bc88cf41d2adefd9943746f9e99281977d6075759b0c0527e70e160f2f0e

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

module Nucleus
  module Adapters
    module GitRepoAnalyzer
      # Is the repository having any branch?
      # @param [String] repo_host repository host where the repository can be retrieved
      # @param [String] repo_name name of the directory for the repository that shall be created in the tmp dir
      # @param [String] username user to authenticate with
      # @return [TrueClass, FalseClass] true if the repository has any non-empty branch, e.g. 'master'
      def self.any_branch?(repo_host, repo_name, username)
        detected_branch = false
        options = { forward_agent: true, auth_methods: ['publickey'],
                    keys: [nucleus_config.ssh.handler.key_file], keys_only: true }
        Net::SSH.start(repo_host, username, options) do |ssh|
          ssh.exec! "git-upload-pack '/#{repo_name}.git'" do |ch, stream, data|
            detected_branch = (detected_branch || data != '0000') unless stream == :stderr
            ch.close
          end
        end
        detected_branch
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nucleus-0.3.1 lib/nucleus/core/file_handling/git_repo_analyzer.rb
nucleus-0.2.0 lib/nucleus/core/file_handling/git_repo_analyzer.rb
nucleus-0.1.0 lib/nucleus/core/file_handling/git_repo_analyzer.rb