Skip to content

Commit e304c38

Browse files
Copilotletmaik
andauthored
Sort refs by committer date by default (#124)
Co-authored-by: letmaik <530988+letmaik@users.noreply.github.com>
1 parent e10e9df commit e304c38

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ By default, the tree view is located in its own container accessible from the ac
5555
`gitTreeCompare.collapsed` When enabled, shows folders collapsed instead of expanded. NOTE: Changing this option requires restarting VS Code.
5656

5757
`gitTreeCompare.compactFolders` When enabled, compacts (flattens) single-child folders into a single tree element. Useful for Java package structures, for example. May have a performance impact for large diff trees.
58+
59+
`gitTreeCompare.refSortOrder` Determines how refs (branches, tags) are sorted when changing the comparison base. Default is `committerdate` which sorts by most recently committed first, making it easy to find recently-used branches. Can be set to `alphabetically` for alphabetical sorting.

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,15 @@
415415
"type": "boolean",
416416
"description": "Whether to show checkboxes such that files or folders can be ticked off, for example when reviewing.",
417417
"default": false
418+
},
419+
"gitTreeCompare.refSortOrder": {
420+
"type": "string",
421+
"enum": [
422+
"alphabetically",
423+
"committerdate"
424+
],
425+
"description": "How to sort refs (branches, tags) when changing the comparison base. 'committerdate' sorts by most recently committed first.",
426+
"default": "committerdate"
418427
}
419428
}
420429
}

src/treeProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,8 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
10071007
return;
10081008
}
10091009
const commit = new ChangeBaseCommitItem();
1010-
const refs = (await this.repository.getRefs()).filter(ref => ref.name);
1010+
const sortOrder = workspace.getConfiguration(NAMESPACE).get<'alphabetically' | 'committerdate'>('refSortOrder', 'committerdate');
1011+
const refs = (await this.repository.getRefs({ sort: sortOrder })).filter(ref => ref.name);
10111012
const heads = refs.filter(ref => ref.type === RefType.Head).map(ref => new ChangeBaseRefItem(ref));
10121013
const tags = refs.filter(ref => ref.type === RefType.Tag).map(ref => new ChangeBaseTagItem(ref));
10131014
const remoteHeads = refs.filter(ref => ref.type === RefType.RemoteHead).map(ref => new ChangeBaseRemoteHeadItem(ref));

0 commit comments

Comments
 (0)