Skip to content

Commit c80442d

Browse files
nomikenomikelszomoru
authored
Enhance GithHub publishing logic to handle renamed repositories (microsoft#245024)
* Enhance GithHub publishing logic to handle renamed repositories. * Make "result" const as it is never reassigned. * Pull request feedback --------- Co-authored-by: nomike <[email protected]> Co-authored-by: Ladislau Szomoru <[email protected]>
1 parent 1a99a26 commit c80442d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

extensions/github/src/publish.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
9999
if (repo) {
100100
try {
101101
quickpick.busy = true;
102-
await octokit.repos.get({ owner, repo: repo });
103-
quickpick.items = [{ label: `$(error) GitHub repository already exists`, description: `$(github) ${owner}/${repo}`, alwaysShow: true }];
102+
const fullName = `${owner}/${repo}`;
103+
const result = await octokit.repos.get({ owner, repo: repo });
104+
if (result.data.full_name.toLowerCase() !== fullName.toLowerCase()) {
105+
// Repository has moved permanently due to it being renamed
106+
break;
107+
}
108+
quickpick.items = [{ label: `$(error) GitHub repository already exists`, description: `$(github) ${fullName}`, alwaysShow: true }];
104109
} catch {
105110
break;
106111
} finally {

0 commit comments

Comments
 (0)