<commit_before>import { flags } from '@oclif/command';
import { Observable } from 'rxjs';
import { map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { yes } from 'src/cli/flags';
import { FotingoCommand } from 'src/cli/FotingoCommand';
import { Emoji } from 'src/io/messenger';
import { getReleaseNotes } from 'src/templates/getReleaseNotes';
import { CreateRelease, JointRelease, LocalChanges, ReleaseData } from 'src/types';

export class Release extends FotingoCommand<JointRelease, ReleaseData> {
  static description = 'Create a release with your changes';

  static args = [
    {
      description: 'Name of the release to be created',
      name: 'release-name',
      required: true,
    },
  ];

  static flags = {
    issue: flags.string({
      char: 'i',
      description: 'Specify more issues to include in the release',
      multiple: true,
      required: false,
    }),
    simple: flags.boolean({
      char: 's',
      description: 'Do not use any issue tracker',
      name: 'simple',
    }),
    yes,
  };

  /**
   * Given the local changes and a release data, build the object needed
   * to create a release in the issue tracker
   */
  private static buildReleaseData([data, { tracker, ...releaseData }]: [
    LocalChanges,
    ReleaseData,
  ]): CreateRelease {
    return {
      ...releaseData,
      ...data,
      submitRelease: tracker.enabled,
    };
  }

  protected getCommandData(): ReleaseData {
    const { args, flags } = this.parse(Release);
    return {
      issues: (flags.issue || []) as string[],
      name: args.releaseName as string,
      tracker: {
        enabled: !flags.simple,
      },
      useDefaults: flags.yes as boolean,
    };
  }

  protected runCmd(commandData$: Observable<ReleaseData>): Observable<JointRelease> {
    const releaseInformation$ = commandData$.pipe(
      switchMap(this.git.getBranchInfo),
      withLatestFrom(commandData$),
      switchMap(this.getLocalChangesInformation),
      withLatestFrom(commandData$),
      map(Release.buildReleaseData),
    );

    return releaseInformation$.pipe(
      tap((data) => this.messenger.emit(`Creating release ${data.name}`, Emoji.SHIP)),
      switchMap(this.tracker.createRelease),
      switchMap(this.tracker.setIssuesFixVersion),
      withLatestFrom(commandData$),
      switchMap(([release, { useDefaults }]) =>
        getReleaseNotes(this.fotingo.release, this.messenger, release, useDefaults).pipe(
          map((notes) => ({
            notes,
            release,
          })),
        ),
      ),
      switchMap(({ notes, release }) => this.github.createRelease(release, notes)),
      tap((data: JointRelease) =>
        this.messenger.emit(
          `Release created: ${data.release.url} | ${data.remoteRelease.url}`,
          Emoji.LINK,
        ),
      ),
    );
  }
}
<commit_msg>chore(release): use correct names for flags and args<commit_after>import { flags } from '@oclif/command';
import { Observable } from 'rxjs';
import { map, switchMap, tap, withLatestFrom } from 'rxjs/operators';
import { yes } from 'src/cli/flags';
import { FotingoCommand } from 'src/cli/FotingoCommand';
import { Emoji } from 'src/io/messenger';
import { getReleaseNotes } from 'src/templates/getReleaseNotes';
import { CreateRelease, JointRelease, LocalChanges, ReleaseData } from 'src/types';

export class Release extends FotingoCommand<JointRelease, ReleaseData> {
  static description = 'Create a release with your changes';

  static args = [
    {
      description: 'Name of the release to be created',
      name: 'release',
      required: true,
    },
  ];

  static flags = {
    issues: flags.string({
      char: 'i',
      description: 'Specify more issues to include in the release',
      multiple: true,
      required: false,
    }),
    simple: flags.boolean({
      char: 's',
      description: 'Do not use any issue tracker',
      name: 'simple',
    }),
    yes,
  };

  /**
   * Given the local changes and a release data, build the object needed
   * to create a release in the issue tracker
   */
  private static buildReleaseData([data, { tracker, ...releaseData }]: [
    LocalChanges,
    ReleaseData,
  ]): CreateRelease {
    return {
      ...releaseData,
      ...data,
      submitRelease: tracker.enabled,
    };
  }

  protected getCommandData(): ReleaseData {
    const { args, flags } = this.parse(Release);
    return {
      issues: (flags.issues || []) as string[],
      name: args.release as string,
      tracker: {
        enabled: !flags.simple,
      },
      useDefaults: flags.yes as boolean,
    };
  }

  protected runCmd(commandData$: Observable<ReleaseData>): Observable<JointRelease> {
    const releaseInformation$ = commandData$.pipe(
      switchMap(this.git.getBranchInfo),
      withLatestFrom(commandData$),
      switchMap(this.getLocalChangesInformation),
      withLatestFrom(commandData$),
      map(Release.buildReleaseData),
    );

    return releaseInformation$.pipe(
      tap((data) => this.messenger.emit(`Creating release ${data.name}`, Emoji.SHIP)),
      switchMap(this.tracker.createRelease),
      switchMap(this.tracker.setIssuesFixVersion),
      withLatestFrom(commandData$),
      switchMap(([release, { useDefaults }]) =>
        getReleaseNotes(this.fotingo.release, this.messenger, release, useDefaults).pipe(
          map((notes) => ({
            notes,
            release,
          })),
        ),
      ),
      switchMap(({ notes, release }) => this.github.createRelease(release, notes)),
      tap((data: JointRelease) =>
        this.messenger.emit(
          `Release created: ${data.release.url} | ${data.remoteRelease.url}`,
          Emoji.LINK,
        ),
      ),
    );
  }
}

{'fraction_non_alphanumeric': 0.13028292001397135, 'fraction_numerical': 0.0, 'mean_word_length': 2.8565656565656568, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, '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': '6683546', 'n_tokens_mistral': 1683, 'n_tokens_neox': 1640, 'n_words': 405}