Skip to content

Commit

Permalink
fix: fixing ticketRegex matching
Browse files Browse the repository at this point in the history
  • Loading branch information
willy.ovalle@klarna.com committed Aug 15, 2019
1 parent b69a060 commit 7a3957d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { makeClient } from './jira';
import { GenerateNotesContext, PluginConfig } from './types';
import { escapeRegExp } from './util';

function getTickets(config: PluginConfig, context: GenerateNotesContext): string[] {
export function getTickets(config: PluginConfig, context: GenerateNotesContext): string[] {
let patterns: RegExp[] = [];

if (config.ticketRegex) {
patterns = [new RegExp(escapeRegExp(config.ticketRegex), 'giu')];
if (config.ticketRegex !== undefined) {
patterns = [new RegExp(config.ticketRegex, 'giu')];
} else {
patterns = config.ticketPrefixes!
.map(prefix => new RegExp(`\\b${escapeRegExp(prefix)}-(\\d+)\\b`, 'giu'));
Expand All @@ -18,7 +18,7 @@ function getTickets(config: PluginConfig, context: GenerateNotesContext): string
const tickets = new Set<string>();
for (const commit of context.commits) {
for (const pattern of patterns) {
const matches = pattern.exec(commit.message);
const matches = commit.message.match(pattern);
if (matches) {
tickets.add(matches[0]);
context.logger.info(`Found ticket ${matches[0]} in commit: ${commit.commit.short}`);
Expand Down

0 comments on commit 7a3957d

Please sign in to comment.