Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git - Fix ref sorting regression #171058

Merged
merged 1 commit into from Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 9 additions & 10 deletions extensions/git/src/repository.ts
Expand Up @@ -1382,9 +1382,14 @@ export class Repository implements Disposable {
}

async getRefs(query: RefQuery = {}, cancellationToken?: CancellationToken): Promise<Ref[]> {
return await this.run(Operation.GetRefs, () => {
return this.repository.getRefs(query, cancellationToken);
});
const config = workspace.getConfiguration('git');
let defaultSort = config.get<'alphabetically' | 'committerdate'>('branchSortOrder');
if (defaultSort !== 'alphabetically' && defaultSort !== 'committerdate') {
defaultSort = 'alphabetically';
}

query = { ...query, sort: query?.sort ?? defaultSort };
return await this.run(Operation.GetRefs, () => this.repository.getRefs(query, cancellationToken));
}

async getRemoteRefs(remote: string, opts?: { heads?: boolean; tags?: boolean }): Promise<Ref[]> {
Expand Down Expand Up @@ -1997,16 +2002,10 @@ export class Repository implements Disposable {
this._sourceControl.commitTemplate = commitTemplate;

// Execute cancellable long-running operations
const config = workspace.getConfiguration('git');
let sort = config.get<'alphabetically' | 'committerdate'>('branchSortOrder') || 'alphabetically';
if (sort !== 'alphabetically' && sort !== 'committerdate') {
sort = 'alphabetically';
}

const [resourceGroups, refs] =
await Promise.all([
this.getStatus(cancellationToken),
this.repository.getRefs({ sort }, cancellationToken)]);
this.getRefs({}, cancellationToken)]);

this._refs = refs!;
this._updateResourceGroupsState(resourceGroups);
Expand Down