mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds status formatter
This commit is contained in:
32
src/git/formatters/status.ts
Normal file
32
src/git/formatters/status.ts
Normal file
@@ -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<IGitStatusFile, IStatusFormatOptions> {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import * as path from 'path';
|
|||||||
export { GitUri, IGitCommitInfo };
|
export { GitUri, IGitCommitInfo };
|
||||||
export * from './git/models/models';
|
export * from './git/models/models';
|
||||||
export * from './git/formatters/commit';
|
export * from './git/formatters/commit';
|
||||||
|
export * from './git/formatters/status';
|
||||||
export { getNameFromRemoteResource, RemoteResource, RemoteProvider } from './git/remotes/provider';
|
export { getNameFromRemoteResource, RemoteResource, RemoteProvider } from './git/remotes/provider';
|
||||||
export * from './git/gitContextTracker';
|
export * from './git/gitContextTracker';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user