<commit_before>'use string';

import * as fs from 'fs';
import * as vscode from 'vscode';
import StashGit, { Stash } from './Git/StashGit';
import { StashCommands } from './StashCommands';
import StashLabels from './StashLabels';
import StashNode from './StashNode/StashNode';
import NodeType from './StashNode/NodeType';
import StashNodeFactory from './StashNode/StashNodeFactory';
import { DiffDisplayer } from './DiffDisplayer';
import WorkspaceGit from './Git/WorkspaceGit';

interface QuickPickRepositoryNodeItem extends vscode.QuickPickItem {
    node: StashNode;
}
interface QuickPickStashNodeItem extends vscode.QuickPickItem {
    node: StashNode;
}

export class Commands {
    private stashGit: StashGit;
    private workspaceGit: WorkspaceGit;
    private stashLabels: StashLabels;
    private stashCommands: StashCommands;
    private stashNodeFactory: StashNodeFactory;
    private displayer: DiffDisplayer;

    constructor(workspaceGit: WorkspaceGit, stashCommands: StashCommands, diffDisplayer: DiffDisplayer, stashLabels: StashLabels) {
        this.workspaceGit = workspaceGit;
        this.stashCommands = stashCommands;
        this.stashLabels = stashLabels;
        this.displayer = diffDisplayer;
        this.stashGit = new StashGit();
        this.stashNodeFactory = new StashNodeFactory();
    }

    /**
     * Shows a stashed file diff document.
     *
     * @param fileNode the involved node
     */
    public show = (fileNode: StashNode) => {
        this.displayer.showDiff(fileNode);
    }

    /**
     * Shows a stashed file diff document compared with the HEAD version.
     *
     * @param fileNode the involved node
     */
    public diffCurrent = (fileNode: StashNode) => {
        this.displayer.showDiffCurrent(fileNode);
    }

    /**
     * Generate a stash on the active repository or selects a repository and continues.
     *
     * @param repositoryNode the involved node
     */
    public stash = (repositoryNode?: StashNode) => {
        this.runOnRepository(
            repositoryNode,
            (repositoryNode: StashNode) => { this.stashPerform(repositoryNode); },
        );
    }

    /**
     * Clears all the stashes active repository or selects a repository and continues.
     *
     * @param repositoryNode the involved node
     */
    public clear = (repositoryNode?: StashNode) => {
        this.runOnRepository(
            repositoryNode,
            (repositoryNode: StashNode) => { this.clearPerform(repositoryNode); },
        );
    }

    /**
     * Pops the selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public pop = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to pop' },
            (stashNode: StashNode) => { this.popPerform(stashNode); },
        );
    }

    /**
     * Applies the selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public apply = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to apply' },
            (stashNode: StashNode) => { this.applyPerform(stashNode); },
        );
    }

    /**
     * Branches the selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public branch = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to branch' },
            (stashNode: StashNode) => { this.branchPerform(stashNode); },
        );
    }

    /**
     * Drops the currently selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public drop = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to drop' },
            (stashNode: StashNode) => { this.dropPerform(stashNode); },
        );
    }

    /**
     * Generates a stash for the given repository.
     *
     * @param repositoryNode the repository node
     */
    private stashPerform = (repositoryNode: StashNode) => {
        const repositoryLabel = this.stashLabels.getName(repositoryNode);

        vscode.window
            .showQuickPick([
                {
                    label: 'Stash only',
                    description: 'Crate a simple stash',
                    type: StashCommands.StashType.Simple,
                },
                {
                    label: 'Keep index',
                    description: 'Stash but keep all changes added to the index intact',
                    type: StashCommands.StashType.KeepIndex,
                },
                {
                    label: 'Include untracked',
                    description: 'Stash also untracked files',
                    type: StashCommands.StashType.IncludeUntracked,
                },
                {
                    label: 'Include untracked + keep index',
                    description: '',
                    type: StashCommands.StashType.IncludeUntrackedKeepIndex,
                },
                {
                    label: 'All',
                    description: 'Stash also untracked and ignored files',
                    type: StashCommands.StashType.All,
                },
                {
                    label: 'All + keep index',<commit_msg>fix typo<commit_after>'use string';

import * as fs from 'fs';
import * as vscode from 'vscode';
import StashGit, { Stash } from './Git/StashGit';
import { StashCommands } from './StashCommands';
import StashLabels from './StashLabels';
import StashNode from './StashNode/StashNode';
import NodeType from './StashNode/NodeType';
import StashNodeFactory from './StashNode/StashNodeFactory';
import { DiffDisplayer } from './DiffDisplayer';
import WorkspaceGit from './Git/WorkspaceGit';

interface QuickPickRepositoryNodeItem extends vscode.QuickPickItem {
    node: StashNode;
}
interface QuickPickStashNodeItem extends vscode.QuickPickItem {
    node: StashNode;
}

export class Commands {
    private stashGit: StashGit;
    private workspaceGit: WorkspaceGit;
    private stashLabels: StashLabels;
    private stashCommands: StashCommands;
    private stashNodeFactory: StashNodeFactory;
    private displayer: DiffDisplayer;

    constructor(workspaceGit: WorkspaceGit, stashCommands: StashCommands, diffDisplayer: DiffDisplayer, stashLabels: StashLabels) {
        this.workspaceGit = workspaceGit;
        this.stashCommands = stashCommands;
        this.stashLabels = stashLabels;
        this.displayer = diffDisplayer;
        this.stashGit = new StashGit();
        this.stashNodeFactory = new StashNodeFactory();
    }

    /**
     * Shows a stashed file diff document.
     *
     * @param fileNode the involved node
     */
    public show = (fileNode: StashNode) => {
        this.displayer.showDiff(fileNode);
    }

    /**
     * Shows a stashed file diff document compared with the HEAD version.
     *
     * @param fileNode the involved node
     */
    public diffCurrent = (fileNode: StashNode) => {
        this.displayer.showDiffCurrent(fileNode);
    }

    /**
     * Generate a stash on the active repository or selects a repository and continues.
     *
     * @param repositoryNode the involved node
     */
    public stash = (repositoryNode?: StashNode) => {
        this.runOnRepository(
            repositoryNode,
            (repositoryNode: StashNode) => { this.stashPerform(repositoryNode); },
        );
    }

    /**
     * Clears all the stashes active repository or selects a repository and continues.
     *
     * @param repositoryNode the involved node
     */
    public clear = (repositoryNode?: StashNode) => {
        this.runOnRepository(
            repositoryNode,
            (repositoryNode: StashNode) => { this.clearPerform(repositoryNode); },
        );
    }

    /**
     * Pops the selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public pop = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to pop' },
            (stashNode: StashNode) => { this.popPerform(stashNode); },
        );
    }

    /**
     * Applies the selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public apply = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to apply' },
            (stashNode: StashNode) => { this.applyPerform(stashNode); },
        );
    }

    /**
     * Branches the selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public branch = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to branch' },
            (stashNode: StashNode) => { this.branchPerform(stashNode); },
        );
    }

    /**
     * Drops the currently selected stash or selects one and continue.
     *
     * @param stashNode the involved node
     */
    public drop = (stashNode?: StashNode) => {
        this.runOnStash(
            stashNode,
            { placeHolder: 'Pick a stash to drop' },
            (stashNode: StashNode) => { this.dropPerform(stashNode); },
        );
    }

    /**
     * Generates a stash for the given repository.
     *
     * @param repositoryNode the repository node
     */
    private stashPerform = (repositoryNode: StashNode) => {
        const repositoryLabel = this.stashLabels.getName(repositoryNode);

        vscode.window
            .showQuickPick([
                {
                    label: 'Stash only',
                    description: 'Create a simple stash',
                    type: StashCommands.StashType.Simple,
                },
                {
                    label: 'Keep index',
                    description: 'Stash but keep all changes added to the index intact',
                    type: StashCommands.StashType.KeepIndex,
                },
                {
                    label: 'Include untracked',
                    description: 'Stash also untracked files',
                    type: StashCommands.StashType.IncludeUntracked,
                },
                {
                    label: 'Include untracked + keep index',
                    description: '',
                    type: StashCommands.StashType.IncludeUntrackedKeepIndex,
                },
                {
                    label: 'All',
                    description: 'Stash also untracked and ignored files',
                    type: StashCommands.StashType.All,
                },
                {
                    label: 'All + keep index',
{'fraction_non_alphanumeric': 0.09536985795978602, 'fraction_numerical': 0.0, 'mean_word_length': 1.9544959128065396, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '2706352', 'n_tokens_mistral': 3070, 'n_tokens_neox': 2955, 'n_words': 774}