Class: Gitlab::Triage::Action::Summarize

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/triage/action/summarize.rb

Direct Known Subclasses

Dry

Defined Under Namespace

Classes: Dry

Instance Attribute Summary

Attributes inherited from Base

#network, #policy

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Triage::Action::Base

Instance Method Details

#actObject



32
33
34
# File 'lib/gitlab/triage/action/summarize.rb', line 32

def act
  perform if issue.valid?
end

#destinationObject (private)



51
52
53
# File 'lib/gitlab/triage/action/summarize.rb', line 51

def destination
  issue.destination || network.options.source_id
end

#group_summary_without_destination?Boolean (private)

Returns:

  • (Boolean)


55
56
57
# File 'lib/gitlab/triage/action/summarize.rb', line 55

def group_summary_without_destination?
  network.options.source == :groups && !issue.destination
end

#issueObject (private)



47
48
49
# File 'lib/gitlab/triage/action/summarize.rb', line 47

def issue
  @issue ||= policy.build_summary
end

#performObject (private)



38
39
40
41
42
43
44
45
# File 'lib/gitlab/triage/action/summarize.rb', line 38

def perform
  if group_summary_without_destination?
    puts Gitlab::Triage::UI.warn("Issue was not created: No summary destination specified when source is 'groups'.")
    return
  end

  policy.summary = network.post_api(post_issue_url, post_issue_body)
end

#post_issue_bodyObject (private)



73
74
75
76
77
78
# File 'lib/gitlab/triage/action/summarize.rb', line 73

def post_issue_body
  {
    title: issue.title,
    description: issue.description
  }
end

#post_issue_urlObject (private)



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/gitlab/triage/action/summarize.rb', line 59

def post_issue_url
  # POST /projects/:id/issues
  # https://docs.gitlab.com/ee/api/issues.html#new-issue
  post_url = UrlBuilders::UrlBuilder.new(
    network_options: network.options,
    source_id: destination,
    resource_type: 'issues'
  ).build

  puts Gitlab::Triage::UI.debug "post_issue_url: #{post_url}" if network.options.debug

  post_url
end