<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import {autobind} from 'core-decorators';
import cx from 'classnames';
import {CompositeDisposable} from 'atom';

import StagingView from './staging-view';
import GitLogo from './git-logo';
import CommitViewController from '../controllers/commit-view-controller';
import EtchWrapper from './etch-wrapper';
import {isValidWorkdir} from '../helpers';

export default class GitTabView extends React.Component {
  static focus = {
    ...StagingView.focus,
    ...CommitViewController.focus,
  };

  static propTypes = {
    repository: PropTypes.object.isRequired,
    isLoading: PropTypes.bool.isRequired,

    lastCommit: PropTypes.object.isRequired,
    isMerging: PropTypes.bool,
    isRebasing: PropTypes.bool,
    isAmending: PropTypes.bool,
    hasUndoHistory: PropTypes.bool,
    currentBranch: PropTypes.object,
    unstagedChanges: PropTypes.arrayOf(PropTypes.object),
    stagedChanges: PropTypes.arrayOf(PropTypes.object),
    mergeConflicts: PropTypes.arrayOf(PropTypes.object),
    workingDirectoryPath: PropTypes.string,
    mergeMessage: PropTypes.string,
    fetchInProgress: PropTypes.bool,

    workspace: PropTypes.object.isRequired,
    commandRegistry: PropTypes.object.isRequired,
    grammars: PropTypes.object.isRequired,
    resolutionProgress: PropTypes.object.isRequired,
    notificationManager: PropTypes.object.isRequired,
    config: PropTypes.object.isRequired,
    project: PropTypes.object.isRequired,
    tooltips: PropTypes.object.isRequired,

    initializeRepo: PropTypes.func.isRequired,
    abortMerge: PropTypes.func.isRequired,
    commit: PropTypes.func.isRequired,
    prepareToCommit: PropTypes.func.isRequired,
    resolveAsOurs: PropTypes.func.isRequired,
    resolveAsTheirs: PropTypes.func.isRequired,
    undoLastDiscard: PropTypes.func.isRequired,
    attemptStageAllOperation: PropTypes.func.isRequired,
    attemptFileStageOperation: PropTypes.func.isRequired,
    discardWorkDirChangesForPaths: PropTypes.func.isRequired,
    openFiles: PropTypes.func.isRequired,
  };

  constructor(props, context) {
    super(props, context);

    this.subscriptions = new CompositeDisposable();

    this.refRoot = null;
    this.refStagingView = null;
    this.refCommitViewComponent = null;
  }

  componentDidMount() {
    this.subscriptions.add(
      this.props.commandRegistry.add(this.refRoot, {
        'tool-panel:unfocus': this.blur,
        'core:focus-next': this.advanceFocus,
        'core:focus-previous': this.retreatFocus,
      }),
    );
  }

  render() {
    if (this.props.repository.isTooLarge()) {
      return (
        <div className="github-Panel is-empty" tabIndex="-1" ref={c => { this.refRoot = c; }}>
          <div ref="noRepoMessage" className="github-Panel no-repository">
            <div className="large-icon">
              <GitLogo />
            </div>
            <h3>Too many changes</h3>
            <div className="initialize-repo-description">
              The repository at <strong>{this.props.workingDirectoryPath}</strong> has too many changed files
              to display in Atom. Ensure that you have set up an appropriate <code>.gitignore</code> file.
            </div>
          </div>
        </div>
      );
    } else if (this.props.repository.hasDirectory() &&
               !isValidWorkdir(this.props.repository.getWorkingDirectoryPath())) {
      return (
        <div className="github-Panel is-empty" tabIndex="-1" ref={c => { this.refRoot = c; }}>
          <div ref="noRepoMessage" className="github-Panel no-repository">
            <div className="large-icon">
              <GitLogo />
            </div>
            <h3>Unsupported directory</h3>
            <div className="initialize-repo-description">
              Atom does not support managing Git repositories in your home or root directories.
            </div>
          </div>
        </div>
      );
    } else if (this.props.repository.showGitTabInit()) {
      const inProgress = this.props.repository.showGitTabInitInProgress();
      const message = this.props.repository.hasDirectory() ?
        (
          <span>Initialize <strong>{this.props.workingDirectoryPath}</strong> with a
          Git repository</span>
        ) :
          <span>Initialize a new project directory with a Git repository</span>;

      return (
        <div className="github-Panel is-empty" tabIndex="-1" ref={c => { this.refRoot = c; }}>
          <div ref="noRepoMessage" className="github-Panel no-repository">
            <div className="large-icon">
              <GitLogo />
            </div>
            <div className="initialize-repo-description">{message}</div>
            <button onClick={this.initializeRepo} disabled={inProgress} className="btn btn-primary">
              {inProgress ? 'Creating repository...' : 'Create repository'}
            </button>
          </div>
        </div>
      );
    } else {
      const isLoading = this.props.fetchInProgress || this.props.repository.showGitTabLoading();

      return (
        <div
          className={cx('github-Panel', {'is-loading': isLoading})}
          tabIndex="-1"
          ref={c => { this.refRoot = c; }}>
          <EtchWrapper className="github-PanelEtchWrapper" ref={c => { this.refStagingView = c; }}>
            <StagingView
              commandRegistry={this.props.commandRegistry}
              notificationManager={this.props.notificationManager}
              workspace={this.props.workspace}
              stagedChanges={this.props.stagedChanges}
              unstagedChanges={this.props.unstagedChanges}
              mergeConflicts={this.props.mergeConflicts}
              workingDirectoryPath={this.props.workingDirectoryPath}
              resolutionProgress={this.props.resolutionProgress}
              openFiles={this.props.openFiles}
              discardWorkDirChangesForPaths={this.props.discardWorkDirChangesForPaths}
              attemptFileStageOperation={this.props.attemptFileStageOperation}
              attemptStageAllOperation={this.props.attemptStageAllOperation}
              undoLastDiscard={this.props.undoLastDiscard}
              abortMerge={this.props.abortMerge}
              resolveAsOurs={this.props.resolveAsOurs}
              resolveAsTheirs={this.props.resolveAsTheirs}
              lastCommit={this.props.lastCommit}
              isLoading={this.props.isLoading}
              isAmending={this.props.isAmending}
              hasUndoHistory={this.props.hasUndoHistory}
              isMerging={this.props.isMerging}
            />
          </EtchWrapper>
          <CommitViewController
            ref={c => { this.refCommitViewController = c; }}
            tooltips={this.props.tooltips}
            config={this.props.config}
            stagedChangesExist={this.props.stagedChanges.length > 0}
            mergeConflictsExist={this.props.mergeConflicts.length > 0}
            prepareToCommit={this.props.prepareToCommit}
            commit={this.props.commit}
            abortMerge={this.props.abortMerge}
            branchName={''}
            workspace={this.props.workspace}
            commandRegistry={this.props.commandRegistry}
            notificationManager={this.props.notificationManager}<commit_msg>Pass currentBranch through GitTabView<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import {autobind} from 'core-decorators';
import cx from 'classnames';
import {CompositeDisposable} from 'atom';

import StagingView from './staging-view';
import GitLogo from './git-logo';
import CommitViewController from '../controllers/commit-view-controller';
import EtchWrapper from './etch-wrapper';
import {isValidWorkdir} from '../helpers';

export default class GitTabView extends React.Component {
  static focus = {
    ...StagingView.focus,
    ...CommitViewController.focus,
  };

  static propTypes = {
    repository: PropTypes.object.isRequired,
    isLoading: PropTypes.bool.isRequired,

    lastCommit: PropTypes.object.isRequired,
    currentBranch: PropTypes.object,
    isMerging: PropTypes.bool,
    isRebasing: PropTypes.bool,
    isAmending: PropTypes.bool,
    hasUndoHistory: PropTypes.bool,
    unstagedChanges: PropTypes.arrayOf(PropTypes.object),
    stagedChanges: PropTypes.arrayOf(PropTypes.object),
    mergeConflicts: PropTypes.arrayOf(PropTypes.object),
    workingDirectoryPath: PropTypes.string,
    mergeMessage: PropTypes.string,
    fetchInProgress: PropTypes.bool,

    workspace: PropTypes.object.isRequired,
    commandRegistry: PropTypes.object.isRequired,
    grammars: PropTypes.object.isRequired,
    resolutionProgress: PropTypes.object.isRequired,
    notificationManager: PropTypes.object.isRequired,
    config: PropTypes.object.isRequired,
    project: PropTypes.object.isRequired,
    tooltips: PropTypes.object.isRequired,

    initializeRepo: PropTypes.func.isRequired,
    abortMerge: PropTypes.func.isRequired,
    commit: PropTypes.func.isRequired,
    prepareToCommit: PropTypes.func.isRequired,
    resolveAsOurs: PropTypes.func.isRequired,
    resolveAsTheirs: PropTypes.func.isRequired,
    undoLastDiscard: PropTypes.func.isRequired,
    attemptStageAllOperation: PropTypes.func.isRequired,
    attemptFileStageOperation: PropTypes.func.isRequired,
    discardWorkDirChangesForPaths: PropTypes.func.isRequired,
    openFiles: PropTypes.func.isRequired,
  };

  constructor(props, context) {
    super(props, context);

    this.subscriptions = new CompositeDisposable();

    this.refRoot = null;
    this.refStagingView = null;
    this.refCommitViewComponent = null;
  }

  componentDidMount() {
    this.subscriptions.add(
      this.props.commandRegistry.add(this.refRoot, {
        'tool-panel:unfocus': this.blur,
        'core:focus-next': this.advanceFocus,
        'core:focus-previous': this.retreatFocus,
      }),
    );
  }

  render() {
    if (this.props.repository.isTooLarge()) {
      return (
        <div className="github-Panel is-empty" tabIndex="-1" ref={c => { this.refRoot = c; }}>
          <div ref="noRepoMessage" className="github-Panel no-repository">
            <div className="large-icon">
              <GitLogo />
            </div>
            <h3>Too many changes</h3>
            <div className="initialize-repo-description">
              The repository at <strong>{this.props.workingDirectoryPath}</strong> has too many changed files
              to display in Atom. Ensure that you have set up an appropriate <code>.gitignore</code> file.
            </div>
          </div>
        </div>
      );
    } else if (this.props.repository.hasDirectory() &&
               !isValidWorkdir(this.props.repository.getWorkingDirectoryPath())) {
      return (
        <div className="github-Panel is-empty" tabIndex="-1" ref={c => { this.refRoot = c; }}>
          <div ref="noRepoMessage" className="github-Panel no-repository">
            <div className="large-icon">
              <GitLogo />
            </div>
            <h3>Unsupported directory</h3>
            <div className="initialize-repo-description">
              Atom does not support managing Git repositories in your home or root directories.
            </div>
          </div>
        </div>
      );
    } else if (this.props.repository.showGitTabInit()) {
      const inProgress = this.props.repository.showGitTabInitInProgress();
      const message = this.props.repository.hasDirectory() ?
        (
          <span>Initialize <strong>{this.props.workingDirectoryPath}</strong> with a
          Git repository</span>
        ) :
          <span>Initialize a new project directory with a Git repository</span>;

      return (
        <div className="github-Panel is-empty" tabIndex="-1" ref={c => { this.refRoot = c; }}>
          <div ref="noRepoMessage" className="github-Panel no-repository">
            <div className="large-icon">
              <GitLogo />
            </div>
            <div className="initialize-repo-description">{message}</div>
            <button onClick={this.initializeRepo} disabled={inProgress} className="btn btn-primary">
              {inProgress ? 'Creating repository...' : 'Create repository'}
            </button>
          </div>
        </div>
      );
    } else {
      const isLoading = this.props.fetchInProgress || this.props.repository.showGitTabLoading();

      return (
        <div
          className={cx('github-Panel', {'is-loading': isLoading})}
          tabIndex="-1"
          ref={c => { this.refRoot = c; }}>
          <EtchWrapper className="github-PanelEtchWrapper" ref={c => { this.refStagingView = c; }}>
            <StagingView
              commandRegistry={this.props.commandRegistry}
              notificationManager={this.props.notificationManager}
              workspace={this.props.workspace}
              stagedChanges={this.props.stagedChanges}
              unstagedChanges={this.props.unstagedChanges}
              mergeConflicts={this.props.mergeConflicts}
              workingDirectoryPath={this.props.workingDirectoryPath}
              resolutionProgress={this.props.resolutionProgress}
              openFiles={this.props.openFiles}
              discardWorkDirChangesForPaths={this.props.discardWorkDirChangesForPaths}
              attemptFileStageOperation={this.props.attemptFileStageOperation}
              attemptStageAllOperation={this.props.attemptStageAllOperation}
              undoLastDiscard={this.props.undoLastDiscard}
              abortMerge={this.props.abortMerge}
              resolveAsOurs={this.props.resolveAsOurs}
              resolveAsTheirs={this.props.resolveAsTheirs}
              lastCommit={this.props.lastCommit}
              isLoading={this.props.isLoading}
              isAmending={this.props.isAmending}
              hasUndoHistory={this.props.hasUndoHistory}
              isMerging={this.props.isMerging}
            />
          </EtchWrapper>
          <CommitViewController
            ref={c => { this.refCommitViewController = c; }}
            tooltips={this.props.tooltips}
            config={this.props.config}
            stagedChangesExist={this.props.stagedChanges.length > 0}
            mergeConflictsExist={this.props.mergeConflicts.length > 0}
            prepareToCommit={this.props.prepareToCommit}
            commit={this.props.commit}
            abortMerge={this.props.abortMerge}
            currentBranch={this.props.currentBranch}
            workspace={this.props.workspace}
            commandRegistry={this.props.commandRegistry}
            notificationManager={this.props.notificationManager}
{'fraction_non_alphanumeric': 0.11389895398919805, 'fraction_numerical': 0.001367334381623026, 'mean_word_length': 2.7126903553299493, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 113, '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': '484295', 'n_tokens_mistral': 3948, 'n_tokens_neox': 3995, 'n_words': 690}