Browse Source

Formats remote branch name for better readability

main
Eric Amodio 1 year ago
parent
commit
d0f7ce2f56
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      src/git/models/reference.ts

+ 6
- 1
src/git/models/reference.ts View File

@ -1,6 +1,6 @@
import { configuration } from '../../configuration'; import { configuration } from '../../configuration';
import { GlyphChars } from '../../constants'; import { GlyphChars } from '../../constants';
import { getBranchNameWithoutRemote } from './branch';
import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from './branch';
const rangeRegex = /^(\S*?)(\.\.\.?)(\S*)\s*$/; const rangeRegex = /^(\S*?)(\.\.\.?)(\S*)\s*$/;
const shaLikeRegex = /(^[0-9a-f]{40}([\^@~:]\S*)?$)|(^[0]{40}(:|-)$)/; const shaLikeRegex = /(^[0-9a-f]{40}([\^@~:]\S*)?$)|(^[0]{40}(:|-)$)/;
@ -306,6 +306,11 @@ export namespace GitReference {
let refName = options?.quoted ? `'${ref.name}'` : ref.name; let refName = options?.quoted ? `'${ref.name}'` : ref.name;
switch (ref.refType) { switch (ref.refType) {
case 'branch': case 'branch':
if (ref.remote) {
refName = `${getRemoteNameFromBranchName(refName)}: ${getBranchNameWithoutRemote(refName)}`;
refName = options?.quoted ? `'${refName}'` : refName;
}
result = `${options.label ? `${ref.remote ? 'remote ' : ''}branch ` : ''}${ result = `${options.label ? `${ref.remote ? 'remote ' : ''}branch ` : ''}${
options.icon ? `$(git-branch)${GlyphChars.Space}${refName}` : refName options.icon ? `$(git-branch)${GlyphChars.Space}${refName}` : refName
}`; }`;

Loading…
Cancel
Save