Merge from vscode 5e80bf449c995aa32a59254c0ff845d37da11b70 (#9317)

This commit is contained in:
Anthony Dresser
2020-02-24 21:15:52 -08:00
committed by GitHub
parent 628fd8d74d
commit 4a9c47d3d6
93 changed files with 3109 additions and 813 deletions

View File

@@ -50,8 +50,13 @@ interface MutableRemote extends Remote {
* Log file options.
*/
export interface LogFileOptions {
/** Max number of log entries to retrieve. If not specified, the default is 32. */
readonly maxEntries?: number;
/** Optional. The maximum number of log entries to retrieve. */
readonly maxEntries?: number | string;
/** Optional. The Git sha (hash) to start retrieving log entries from. */
readonly hash?: string;
/** Optional. Specifies whether to start retrieving log entries in reverse order. */
readonly reverse?: boolean;
readonly sortByAuthorDate?: boolean;
}
function parseVersion(raw: string): string {
@@ -817,8 +822,26 @@ export class Repository {
}
async logFile(uri: Uri, options?: LogFileOptions): Promise<Commit[]> {
const maxEntries = options?.maxEntries ?? 32;
const args = ['log', `-n${maxEntries}`, `--format=${COMMIT_FORMAT}`, '-z', '--', uri.fsPath];
const args = ['log', `--format=${COMMIT_FORMAT}`, '-z'];
if (options?.maxEntries && !options?.reverse) {
args.push(`-n${options.maxEntries}`);
}
if (options?.hash) {
// If we are reversing, we must add a range (with HEAD) because we are using --ancestry-path for better reverse walking
if (options?.reverse) {
args.push('--reverse', '--ancestry-path', `${options.hash}..HEAD`);
} else {
args.push(options.hash);
}
}
if (options?.sortByAuthorDate) {
args.push('--author-date-order');
}
args.push('--', uri.fsPath);
const result = await this.run(args);
if (result.exitCode) {