Git - Update getRefs pattern when querying for branches and tags (#171605)

This commit is contained in:
Ladislau Szomoru
2023-01-18 12:41:32 +01:00
committed by GitHub
parent e7d34457a5
commit 9a9d7bfdde
2 changed files with 4 additions and 5 deletions

View File

@@ -2263,11 +2263,10 @@ export class CommandCenter {
run = force => repository.deleteBranch(name, force);
} else {
const getBranchPicks = async () => {
const refs = await repository.getRefs({ pattern: 'refs/heads/*' });
const refs = await repository.getRefs({ pattern: 'refs/heads' });
const currentHead = repository.HEAD && repository.HEAD.name;
return refs.filter(ref => ref.type === RefType.Head && ref.name !== currentHead)
.map(ref => new BranchDeleteItem(ref));
return refs.filter(ref => ref.name !== currentHead).map(ref => new BranchDeleteItem(ref));
};
const placeHolder = l10n.t('Select a branch to delete');
@@ -2425,7 +2424,7 @@ export class CommandCenter {
@command('git.deleteTag', { repository: true })
async deleteTag(repository: Repository): Promise<void> {
const tagPicks = async (): Promise<TagItem[] | QuickPickItem[]> => {
const remoteTags = await repository.getRefs({ pattern: 'refs/tags/*' });
const remoteTags = await repository.getRefs({ pattern: 'refs/tags' });
return remoteTags.length === 0 ? [{ label: l10n.t('$(info) This repository has no tags.') }] : remoteTags.map(ref => new TagItem(ref));
};

View File

@@ -2092,7 +2092,7 @@ export class Repository {
HEAD = await this.getBranch(HEAD.name);
} else if (HEAD.commit) {
// Tag || Commit
const tags = await this.getRefs({ pattern: 'refs/tags/*' });
const tags = await this.getRefs({ pattern: 'refs/tags' });
const tag = tags.find(tag => tag.commit === HEAD!.commit);
if (tag) {