Git - add git.commitShortHashLength setting (#237343)

This commit is contained in:
Ladislau Szomoru
2025-01-06 17:05:37 +01:00
committed by GitHub
parent 4e2ba23aed
commit 3548eae0e1
7 changed files with 53 additions and 30 deletions

View File

@@ -23,7 +23,7 @@ import { IPushErrorHandlerRegistry } from './pushError';
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
import { StatusBarCommands } from './statusbar';
import { toGitUri } from './uri';
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, IDisposable, isDescendant, onceEvent, pathEquals, relativePath } from './util';
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, getCommitShortHash, IDisposable, isDescendant, onceEvent, pathEquals, relativePath } from './util';
import { IFileWatcher, watch } from './watch';
import { detectEncoding } from './encoding';
@@ -1657,7 +1657,7 @@ export class Repository implements Disposable {
}
async checkout(treeish: string, opts?: { detached?: boolean; pullBeforeCheckout?: boolean }): Promise<void> {
const refLabel = opts?.detached ? treeish.substring(0, 8) : treeish;
const refLabel = opts?.detached ? getCommitShortHash(Uri.file(this.root), treeish) : treeish;
await this.run(Operation.Checkout(refLabel),
async () => {
@@ -1675,7 +1675,7 @@ export class Repository implements Disposable {
}
async checkoutTracking(treeish: string, opts: { detached?: boolean } = {}): Promise<void> {
const refLabel = opts.detached ? treeish.substring(0, 8) : treeish;
const refLabel = opts.detached ? getCommitShortHash(Uri.file(this.root), treeish) : treeish;
await this.run(Operation.CheckoutTracking(refLabel), () => this.repository.checkout(treeish, [], { ...opts, track: true }));
}