Skip to content

Commit

Permalink
feat: [UH-1258] better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielCastro committed Jan 29, 2019
1 parent c44e1aa commit 85a74e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export { verifyConditions } from './verifyConditions';
export { success } from './success';

export const dryRun = true;
14 changes: 8 additions & 6 deletions lib/success.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function getTickets(config: PluginConfig, context: GenerateNotesContext): string
const matches = pattern.exec(commit.message);
if (matches) {
tickets.add(matches[0]);
context.logger.info(`Found ticket ${matches[0]}`);
context.logger.info(`Found ticket ${matches[0]} in commit: ${commit.commit.short}`);
}
}
}
Expand All @@ -25,16 +25,18 @@ function getTickets(config: PluginConfig, context: GenerateNotesContext): string

async function findOrCreateVersion(config: PluginConfig, context: GenerateNotesContext, jira: JiraClient, projectIdOrKey: string, name: string): Promise<Version> {
const remoteVersions = await jira.project.getVersions({ projectIdOrKey });
context.logger.info(`Looking for version with name '${name}'`);
const existing = _.find(remoteVersions, { name });
if (existing) {
context.logger.info(`Found existing release ${existing.id}`);
context.logger.info(`Found existing release '${existing.id}'`);
return existing;
}

context.logger.info(`Making new release`);
context.logger.info(`No existing release found, creating new`);

let newVersion: Version;
if (config.dryRun) {
context.logger.info(`dry-run: making a fake release`);
newVersion = {
name,
id: 'dry_run_id',
Expand All @@ -48,19 +50,19 @@ async function findOrCreateVersion(config: PluginConfig, context: GenerateNotesC
});
}

context.logger.info(`Made new release ${newVersion.id}`);
context.logger.info(`Made new release '${newVersion.id}'`);
return newVersion;
}

export async function success(config: PluginConfig, context: GenerateNotesContext): Promise<void> {
const tickets = getTickets(config, context);

context.logger.info(`Found issues ${tickets.join(', ')}`);
context.logger.info(`Found ticket ${tickets.join(', ')}`);

const template = _.template(config.releaseNameTemplate || 'v${version}');
const newVersionName = template({ version: context.nextRelease.version });

context.logger.info(`Using jira release ${newVersionName}`);
context.logger.info(`Using jira release '${newVersionName}'`);

const jira = makeClient(config, context);

Expand Down

0 comments on commit 85a74e9

Please sign in to comment.