mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
Merge from vscode 5e80bf449c995aa32a59254c0ff845d37da11b70 (#9317)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user