<commit_before>import * as React from 'react'
import { ChangesList } from './changes-list'
import { Diff  } from '../diff'
import { DiffSelection, DiffSelectionType } from '../../models/diff'
import { IChangesState, PopupType } from '../../lib/app-state'
import { Repository } from '../../models/repository'
import { Dispatcher, IGitHubUser, IssuesStore } from '../../lib/dispatcher'
import { PersistingResizable } from '../resizable'
import { CommitIdentity } from '../../models/commit-identity'
import { Commit } from '../../lib/local-git-operations'
import { UndoCommit } from './undo-commit'
import { IAutocompletionProvider, EmojiAutocompletionProvider, IssuesAutocompletionProvider } from '../autocompletion'

interface IChangesProps {
  readonly repository: Repository
  readonly changes: IChangesState
  readonly dispatcher: Dispatcher
  readonly commitAuthor: CommitIdentity | null
  readonly branch: string | null
  readonly gitHubUsers: Map<string, IGitHubUser>
  readonly emoji: Map<string, string>
  readonly mostRecentLocalCommit: Commit | null
  readonly issuesStore: IssuesStore
}

/** TODO: handle "repository not found" scenario */

export class Changes extends React.Component<IChangesProps, void> {
  private autocompletionProviders: ReadonlyArray<IAutocompletionProvider<any>> | null

  public constructor(props: IChangesProps) {
    super(props)

    this.receiveProps(props)
  }

  public componentWillReceiveProps(nextProps: IChangesProps) {
    this.receiveProps(nextProps)
  }

  private receiveProps(props: IChangesProps) {
    if (props.repository.id !== this.props.repository.id || !this.autocompletionProviders) {
      const autocompletionProviders: IAutocompletionProvider<any>[] = [
        new EmojiAutocompletionProvider(this.props.emoji),
      ]

      const gitHubRepository = props.repository.gitHubRepository
      if (gitHubRepository) {
        autocompletionProviders.push(new IssuesAutocompletionProvider(props.issuesStore, gitHubRepository, props.dispatcher))
      }

      this.autocompletionProviders = autocompletionProviders
    }

    if (props.changes.contextualCommitMessage) {
      // Once we receive the contextual commit message we can clear it. We don't
      // want to keep receiving it.
      props.dispatcher.clearContextualCommitMessage(props.repository)
    }
  }

  private onCreateCommit(summary: string, description: string) {
    this.props.dispatcher.commitIncludedChanges(this.props.repository, summary, description)
  }
<commit_msg>Note that we can only provide issue autocompletions for GitHub repos<commit_after>import * as React from 'react'
import { ChangesList } from './changes-list'
import { Diff  } from '../diff'
import { DiffSelection, DiffSelectionType } from '../../models/diff'
import { IChangesState, PopupType } from '../../lib/app-state'
import { Repository } from '../../models/repository'
import { Dispatcher, IGitHubUser, IssuesStore } from '../../lib/dispatcher'
import { PersistingResizable } from '../resizable'
import { CommitIdentity } from '../../models/commit-identity'
import { Commit } from '../../lib/local-git-operations'
import { UndoCommit } from './undo-commit'
import { IAutocompletionProvider, EmojiAutocompletionProvider, IssuesAutocompletionProvider } from '../autocompletion'

interface IChangesProps {
  readonly repository: Repository
  readonly changes: IChangesState
  readonly dispatcher: Dispatcher
  readonly commitAuthor: CommitIdentity | null
  readonly branch: string | null
  readonly gitHubUsers: Map<string, IGitHubUser>
  readonly emoji: Map<string, string>
  readonly mostRecentLocalCommit: Commit | null
  readonly issuesStore: IssuesStore
}

/** TODO: handle "repository not found" scenario */

export class Changes extends React.Component<IChangesProps, void> {
  private autocompletionProviders: ReadonlyArray<IAutocompletionProvider<any>> | null

  public constructor(props: IChangesProps) {
    super(props)

    this.receiveProps(props)
  }

  public componentWillReceiveProps(nextProps: IChangesProps) {
    this.receiveProps(nextProps)
  }

  private receiveProps(props: IChangesProps) {
    if (props.repository.id !== this.props.repository.id || !this.autocompletionProviders) {
      const autocompletionProviders: IAutocompletionProvider<any>[] = [
        new EmojiAutocompletionProvider(this.props.emoji),
      ]

      // Issues autocompletion is only available for GitHub repositories.
      const gitHubRepository = props.repository.gitHubRepository
      if (gitHubRepository) {
        autocompletionProviders.push(new IssuesAutocompletionProvider(props.issuesStore, gitHubRepository, props.dispatcher))
      }

      this.autocompletionProviders = autocompletionProviders
    }

    if (props.changes.contextualCommitMessage) {
      // Once we receive the contextual commit message we can clear it. We don't
      // want to keep receiving it.
      props.dispatcher.clearContextualCommitMessage(props.repository)
    }
  }

  private onCreateCommit(summary: string, description: string) {
    this.props.dispatcher.commitIncludedChanges(this.props.repository, summary, description)
  }

{'fraction_non_alphanumeric': 0.10185004868549172, 'fraction_numerical': 0.0, 'mean_word_length': 4.333333333333333, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4011381', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1377, 'n_words': 350}