Module: Init

Included in:
IssueDB
Defined in:
lib/issue_db/utils/init.rb

Instance Method Summary collapse

Instance Method Details

#init!Object

A helper method for initializing the IssueDB library when .new is called Everything in this method should be idempotent and safe to call multiple times



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/issue_db/utils/init.rb', line 6

def init!
  begin
    @client.add_label(
      @repo.full_name,
      @label,
      "000000",
      { description: "This issue is managed by the issue-db Ruby library. Please do not remove this label." }
    )
  rescue StandardError => e
    if e.message.include?("code: already_exists")
      @log.debug("label #{@label} already exists")
    else
      @log.error("error creating label: #{e.message}") unless ENV.fetch("ENV", nil) == "acceptance"
    end
  end
end