/**
Copyright: 2024 Contrast Security, Inc
  Contact: support@contrastsecurity.com
  License: Commercial

  NOTICE: This Software and the patented inventions embodied within may only be
  used as part of Contrast Security’s commercial offerings. Even though it is
  made available through public repositories, use of this Software is subject to
  the applicable End User Licensing Agreement found at
  https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
  between Contrast Security and the End User. The Software may not be reverse
  engineered, modified, repackaged, sold, redistributed or otherwise used in a
  way not consistent with the End User License Agreement.
*/
'use strict';

module.exports = {
  jira: {
    baseUrl: `https://${process.env.JIRA_HOST}`,
    ticketIDPattern: /(NODE-?\s?[0-9]{4})/i,
    excludeIssueTypes: ['Sub-task', 'Release'],
    api: {
      host: process.env.JIRA_HOST,
      email: process.env.JIRA_EMAIL,
      token: process.env.JIRA_TOKEN
    }
  },
  hideEmptyBlocks: true,
  template: `## <%= process.env.VERSION -%>

<% blockTickets = tickets.all.filter((t) => !t.reverted); -%>
<% if (blockTickets.length > 0 || !options.hideEmptyBlocks) { -%>
### Jira Tickets
---------------------
<% blockTickets.forEach(ticket => { -%>
  * [<%= ticket.fields.issuetype.name %>] - <%- ticket.fields.summary %>
    [<%= ticket.key %>](<%= jira.baseUrl + '/browse/' + ticket.key %>)
<% }); -%>
<% if (!blockTickets.length) {%> ~ None ~ <% } %>
<% } -%>
<% blockNoTickets = commits.noTickets; -%>
<% if (blockNoTickets.length > 0 || !options.hideEmptyBlocks) { -%>

### Other Commits
---------------------
<% blockNoTickets.forEach(commit => { -%>
  * <%= commit.slackUser ? '@'+commit.slackUser.name : commit.authorName %> - <<%= commit.revision.substr(0, 7) %>> - <%= commit.summary %>
<% }); -%>
<% if (!blockNoTickets.length) {%> ~ None ~ <% } %>
<% } -%>
<% blockPendingByOwner = tickets.pendingByOwner; -%>
<% if (blockPendingByOwner.length > 0 || !options.hideEmptyBlocks) { -%>
<% } -%>
--------------------
`
};
