Sha256: 110c49fe95d4ef077b20d35eab13f4192845399f6be3319303bba68dad8a3e70

Contents?: true

Size: 1.56 KB

Versions: 6

Compression:

Stored size: 1.56 KB

Contents

module Git
  module Whistles
    class Jira
      attr_reader :username, :password, :site

      def initialize
        get_config
      end

      def get_client(opts = {})
        options = {
          username: @username,
          password: @password,
          site: @site,
          context_path: '',
          auth_type: :basic,
          read_timeout: 120
        }

        options.merge!(opts)

        JIRA::Client.new(options)
      end

      def get_config
        @username = `git config jira.username`.strip
        if username.empty?
          puts Term::ANSIColor.yellow %Q{
            Your branch appears to have a issue ID,
            but I don't know your JIRA username!
            Please set it with:
            $ git config [--global] jira.username <username>
          }
          die "Aborting."
        end

        @password = `git config jira.password`.strip
        if password.empty?
          puts Term::ANSIColor.yellow %Q{
            Your branch appears to have a issue ID,
            but I don't know your JIRA password!
            Please set it with:
            $ git config [--global] jira.password <password>
          }
          die "Aborting."
        end

        @site = `git config jira.site`.strip
        if site.empty?
          puts Term::ANSIColor.yellow %Q{
            Your branch appears to have a issue ID,
            but I don't know your JIRA site!
            Please set it with:
            $ git config [--global] jira.site <https://mydomain.atlassian.net>
          }
          die "Aborting."
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git-whistles-1.2.1 lib/git-whistles/jira.rb
git-whistles-1.2.0 lib/git-whistles/jira.rb
git-whistles-1.1.3 lib/git-whistles/jira.rb
git-whistles-1.1.2 lib/git-whistles/jira.rb
git-whistles-1.1.1 lib/git-whistles/jira.rb
git-whistles-1.1.0 lib/git-whistles/jira.rb