Skip to content

Commit 12b08be

Browse files
authored
Only use the commit in share link when upstream (microsoft#156658)
Fixes microsoft#156627
1 parent 84dc769 commit 12b08be

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

extensions/github/src/links.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ export function getPermalink(gitAPI: GitAPI, useSelection: boolean, hostPrefix?:
125125
return;
126126
}
127127

128-
const commitHash = gitRepo.state.HEAD?.commit;
128+
const commitHash = (gitRepo.state.HEAD?.ahead === 0) ? `/blob/${gitRepo.state.HEAD?.commit}` : '';
129129
const fileSegments = fileAndPosition.type === LinkType.File
130130
? (useSelection ? `${uri.path.substring(gitRepo.rootUri.path.length)}${rangeString(fileAndPosition.range)}` : '')
131131
: (useSelection ? `${uri.path.substring(gitRepo.rootUri.path.length)}${notebookCellRangeString(fileAndPosition.cellIndex, fileAndPosition.range)}` : '');
132132

133-
return `${hostPrefix}/${repo.owner}/${repo.repo}/blob/${commitHash
133+
return `${hostPrefix}/${repo.owner}/${repo.repo}${commitHash
134134
}${fileSegments}`;
135135
}

0 commit comments

Comments
 (0)