GitHub - add "Open on GitHub" to blame hover (#237514)

* WIP - saving my work

* Refactor hover rendering code
This commit is contained in:
Ladislau Szomoru
2025-01-08 20:34:54 +01:00
committed by GitHub
parent 1329d03879
commit dca80ea667
11 changed files with 147 additions and 57 deletions

View File

@@ -1592,13 +1592,13 @@ export class Repository implements Disposable {
}
private async getDefaultBranch(): Promise<Branch | undefined> {
try {
if (this.remotes.length === 0) {
return undefined;
}
const defaultRemote = this.getDefaultRemote();
if (!defaultRemote) {
return undefined;
}
const remote = this.remotes.find(r => r.name === 'origin') ?? this.remotes[0];
const defaultBranch = await this.repository.getDefaultBranch(remote.name);
try {
const defaultBranch = await this.repository.getDefaultBranch(defaultRemote.name);
return defaultBranch;
}
catch (err) {
@@ -1713,6 +1713,14 @@ export class Repository implements Disposable {
await this.run(Operation.DeleteRef, () => this.repository.deleteRef(ref));
}
getDefaultRemote(): Remote | undefined {
if (this.remotes.length === 0) {
return undefined;
}
return this.remotes.find(r => r.name === 'origin') ?? this.remotes[0];
}
async addRemote(name: string, url: string): Promise<void> {
await this.run(Operation.Remote, () => this.repository.addRemote(name, url));
}