Class: DangerPackwerk::Private::OwnershipInformation

Inherits:
T::Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/danger-packwerk/private/ownership_information.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for_package(package, org_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/danger-packwerk/private/ownership_information.rb', line 17

def self.for_package(package, org_name)
  pack = Packs.find(package.name)
  team = pack.nil? ? nil : CodeOwnership.for_package(pack)

  if team.nil?
    OwnershipInformation.new
  else
    OwnershipInformation.new(
      owning_team: team,
      github_team: team.raw_hash.fetch('github', {}).fetch('team', nil),
      slack_channel: team.raw_hash.fetch('slack', {}).fetch('room_for_humans', nil),
      org_name: org_name
    )
  end
end

Instance Method Details



57
58
59
# File 'lib/danger-packwerk/private/ownership_information.rb', line 57

def markdown_link_to_github_members_no_tag
  "[<ins>#{github_team}</ins>](https://github.com/orgs/#{org_name}/teams/#{T.must(github_team).gsub("@#{org_name}/", '')}/members)"
end


47
48
49
# File 'lib/danger-packwerk/private/ownership_information.rb', line 47

def markdown_link_to_slack_room
  "[<ins>#{slack_channel}</ins>](https://slack.com/app_redirect?channel=#{T.must(slack_channel).delete('#')})"
end

#ownership_copyObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/danger-packwerk/private/ownership_information.rb', line 34

def ownership_copy
  github_team_flow_sensitive = github_team
  slack_channel_flow_sensitive = slack_channel

  if owning_team && github_team_flow_sensitive && slack_channel_flow_sensitive
    team_slack_link = markdown_link_to_slack_room
    "- Owned by #{markdown_link_to_github_members_no_tag} (Slack: #{team_slack_link})"
  else
    '- This pack is unowned.'
  end
end