MCPcopy Create free account
hub / github.com/desktop/desktop / createRepository

Method createRepository

app/src/lib/api.ts:1104–1136  ·  view source on GitHub ↗

Create a new GitHub repository with the given properties.

(
    org: IAPIOrganization | null,
    name: string,
    description: string,
    private_: boolean
  )

Source from the content-addressed store, hash-verified

1102
1103 /** Create a new GitHub repository with the given properties. */
1104 public async createRepository(
1105 org: IAPIOrganization | null,
1106 name: string,
1107 description: string,
1108 private_: boolean
1109 ): Promise<IAPIFullRepository> {
1110 try {
1111 const apiPath = org ? `orgs/${org.login}/repos` : 'user/repos'
1112 const response = await this.ghRequest('POST', apiPath, {
1113 body: {
1114 name,
1115 description,
1116 private: private_,
1117 },
1118 })
1119
1120 return await parsedResponse<IAPIFullRepository>(response)
1121 } catch (e) {
1122 if (e instanceof APIError) {
1123 if (org !== null) {
1124 throw new Error(
1125 `Unable to create repository for organization '${org.login}'. Verify that the repository does not already exist and that you have permission to create a repository there.`
1126 )
1127 }
1128 throw e
1129 }
1130
1131 log.error(`createRepository: failed with endpoint ${this.endpoint}`, e)
1132 throw new Error(
1133 `Unable to publish repository. Please check if you have an internet connection and try again.`
1134 )
1135 }
1136 }
1137
1138 /** Create a new GitHub fork of this repository (owner and name) */
1139 public async forkRepository(

Callers 2

createAPIRepositoryFunction · 0.95
_publishRepositoryMethod · 0.80

Calls 2

ghRequestMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected