diff --git a/src/git/formatters/status.ts b/src/git/formatters/status.ts new file mode 100644 index 0000000..590d60d --- /dev/null +++ b/src/git/formatters/status.ts @@ -0,0 +1,32 @@ +'use strict'; +import { Strings } from '../../system'; +import { Formatter, IFormatOptions } from './formatter'; +import { GitStatusFile, IGitStatusFile } from '../models/status'; +import * as path from 'path'; + +export interface IStatusFormatOptions extends IFormatOptions { + tokenOptions?: { + file?: Strings.ITokenOptions; + path?: Strings.ITokenOptions; + }; +} + +export class StatusFileFormatter extends Formatter { + + get file() { + const file = path.basename(this._item.fileName); + return this._padOrTruncate(file, this._options.tokenOptions!.file); + } + + get path() { + const directory = GitStatusFile.getFormattedDirectory(this._item, false); + return this._padOrTruncate(directory, this._options.tokenOptions!.file); + } + + static fromTemplate(template: string, status: IGitStatusFile, dateFormat: string | null): string; + static fromTemplate(template: string, status: IGitStatusFile, options?: IStatusFormatOptions): string; + static fromTemplate(template: string, status: IGitStatusFile, dateFormatOrOptions?: string | null | IStatusFormatOptions): string; + static fromTemplate(template: string, status: IGitStatusFile, dateFormatOrOptions?: string | null | IStatusFormatOptions): string { + return super.fromTemplateCore(this, template, status, dateFormatOrOptions); + } +} \ No newline at end of file diff --git a/src/gitService.ts b/src/gitService.ts index bc50570..eebc566 100644 --- a/src/gitService.ts +++ b/src/gitService.ts @@ -15,6 +15,7 @@ import * as path from 'path'; export { GitUri, IGitCommitInfo }; export * from './git/models/models'; export * from './git/formatters/commit'; +export * from './git/formatters/status'; export { getNameFromRemoteResource, RemoteResource, RemoteProvider } from './git/remotes/provider'; export * from './git/gitContextTracker';