<commit_before>'use strict';

let cli  = require('heroku-cli-util');
let co   = require('co');
let _    = require('lodash');
let time = require('../../lib/time');

let width = () => process.stdout.columns > 80 ? process.stdout.columns : 80;
let trunc = s => _.truncate(s, {length: width()-60, omission: '…'});

function* run (context, heroku) {
  let url = `/apps/${context.app}/releases`;
  if (context.flags.extended) url = url + '?extended=true';
  let releases = yield heroku.request({
    path: url,
    partial: true,
    headers: { 'Range': `version ..; max=${context.flags.num || 15}, order=desc` },
  });
  if (context.flags.json) {
    cli.log(JSON.stringify(releases, null, 2));
  } else if (context.flags.extended) {
    cli.styledHeader(`${context.app} Releases`);
    cli.table(releases, {
      printHeader: false,
      columns: [
        {key: 'version',     format: v => cli.color.green('v'+v)},
        {key: 'description', format: trunc},
        {key: 'user',        format: u => cli.color.magenta(u.email.replace(/@addons\.heroku\.com$/,''))},
        {key: 'created_at',  format: t => time.ago(new Date(t))},
        {key: 'extended.slug_id'},
        {key: 'extended.slug_uuid'},
      ]
    });
  } else if (releases.length === 0) {
    cli.log(`${context.app} has no releases.`);
  } else {
    cli.styledHeader(`${context.app} Releases`);
    cli.table(releases, {
      printHeader: false,
      columns: [
        {key: 'version',     format: v => cli.color.green('v'+v)},<commit_msg>shorten releases header<commit_after>'use strict';

let cli  = require('heroku-cli-util');
let co   = require('co');
let _    = require('lodash');
let time = require('../../lib/time');

let width = () => process.stdout.columns > 80 ? process.stdout.columns : 80;
let trunc = s => _.truncate(s, {length: width()-60, omission: '…'});

function* run (context, heroku) {
  let url = `/apps/${context.app}/releases`;
  if (context.flags.extended) url = url + '?extended=true';
  let releases = yield heroku.request({
    path: url,
    partial: true,
    headers: { 'Range': `version ..; max=${context.flags.num || 15}, order=desc` },
  });
  if (context.flags.json) {
    cli.log(JSON.stringify(releases, null, 2));
  } else if (context.flags.extended) {
    cli.styledHeader(`${context.app} Releases`);
    cli.table(releases, {
      printHeader: false,
      columns: [
        {key: 'version',     format: v => cli.color.green('v'+v)},
        {key: 'description', format: trunc},
        {key: 'user',        format: u => cli.color.magenta(u.email.replace(/@addons\.heroku\.com$/,''))},
        {key: 'created_at',  format: t => time.ago(new Date(t))},
        {key: 'extended.slug_id'},
        {key: 'extended.slug_uuid'},
      ]
    });
  } else if (releases.length === 0) {
    cli.log(`${context.app} has no releases.`);
  } else {
    cli.styledHeader(`${context.app} Releases`);
    cli.table(releases, {
      printHeader: false,
      columns: [
        {key: 'version',     label: '', format: v => cli.color.green('v'+v)},
{'fraction_non_alphanumeric': 0.2061043649491303, 'fraction_numerical': 0.006563833278634723, 'mean_word_length': 3.015810276679842, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4008011', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1038, 'n_words': 224}