A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/microsoft/PowerShellForGitHub/commit/d96541ee5e16a3b9e11a52994a26540b203fb22c below:

Add New-GitHubRepositoryFromTemplate Function (#221) · microsoft/PowerShellForGitHub@d96541e · GitHub

@@ -227,6 +227,175 @@ filter New-GitHubRepository

227 227

return (Invoke-GHRestMethod @params | Add-GitHubRepositoryAdditionalProperties)

228 228

}

229 229 230 +

filter New-GitHubRepositoryFromTemplate

231 +

{

232 +

<#

233 +

.SYNOPSIS

234 +

Creates a new repository on GitHub from a template repository.

235 + 236 +

.DESCRIPTION

237 +

Creates a new repository on GitHub from a template repository.

238 + 239 +

The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub

240 + 241 +

.PARAMETER OwnerName

242 +

Owner of the template repository.

243 +

If no value is specified, the DefaultOwnerName configuration property value will be used,

244 +

and if there is no configuration value defined, the current authenticated user will be used.

245 + 246 +

.PARAMETER RepositoryName

247 +

Name of the template repository.

248 + 249 +

.PARAMETER Uri

250 +

Uri for the repository.

251 +

The OwnerName and RepositoryName will be extracted from here instead of needing to provide

252 +

them individually.

253 + 254 +

.PARAMETER TargetOwnerName

255 +

The organization or person who will own the new repository.

256 +

To create a new repository in an organization, the authenticated user must be a member

257 +

of the specified organization.

258 + 259 +

.PARAMETER TargetRepositoryName

260 +

Name of the repository to be created.

261 + 262 +

.PARAMETER Description

263 +

A short description of the repository.

264 + 265 +

.PARAMETER Private

266 +

By default, this repository will created Public. Specify this to create a private

267 +

repository.

268 + 269 +

.PARAMETER AccessToken

270 +

If provided, this will be used as the AccessToken for authentication with the

271 +

REST Api. Otherwise, will attempt to use the configured value or will run unauthenticated.

272 + 273 +

.PARAMETER NoStatus

274 +

If this switch is specified, long-running commands will run on the main thread

275 +

with no commandline status update. When not specified, those commands run in

276 +

the background, enabling the command prompt to provide status information.

277 +

If not supplied here, the DefaultNoStatus configuration property value will be used.

278 + 279 +

.INPUTS

280 +

GitHub.Branch

281 +

GitHub.Content

282 +

GitHub.Event

283 +

GitHub.Issue

284 +

GitHub.IssueComment

285 +

GitHub.Label

286 +

GitHub.Milestone

287 +

GitHub.PullRequest

288 +

GitHub.Project

289 +

GitHub.ProjectCard

290 +

GitHub.ProjectColumn

291 +

GitHub.Release

292 +

GitHub.Repository

293 + 294 +

.OUTPUTS

295 +

GitHub.Repository

296 + 297 +

.NOTES

298 +

The authenticated user must own or be a member of an organization that owns the repository.

299 + 300 +

To check if a repository is available to use as a template, call `Get-GitHubRepository` on the

301 +

repository in question and check that the is_template property is $true.

302 + 303 +

.EXAMPLE

304 +

New-GitHubRepositoryFromTemplate -OwnerName MyOrg -RepositoryName MyTemplateRepo -TargetRepositoryName MyNewRepo -TargetOwnerName Me

305 + 306 +

Creates a new GitHub repository from the specified template repository.

307 + 308 +

.EXAMPLE

309 +

$repo = Get-GitHubRepository -OwnerName MyOrg -RepositoryName MyTemplateRepo

310 +

$repo | New-GitHubRepositoryFromTemplate -TargetRepositoryName MyNewRepo -TargetOwnerName Me

311 + 312 +

You can also pipe in a repo that was returned from a previous command.

313 +

#>

314 +

[CmdletBinding(

315 +

SupportsShouldProcess,

316 +

PositionalBinding = $false)]

317 +

[OutputType({$script:GitHubRepositoryTypeName})]

318 +

[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "",

319 +

Justification="Methods called within here make use of PSShouldProcess, and the switch is

320 +

passed on to them inherently.")]

321 +

param(

322 +

[Parameter(ParameterSetName = 'Elements')]

323 +

[string] $OwnerName,

324 + 325 +

[Parameter(

326 +

Mandatory,

327 +

Position = 1,

328 +

ParameterSetName = 'Elements')]

329 +

[ValidateNotNullOrEmpty()]

330 +

[string] $RepositoryName,

331 + 332 +

[Parameter(

333 +

Mandatory,

334 +

Position = 2,

335 +

ValueFromPipelineByPropertyName,

336 +

ParameterSetName = 'Uri')]

337 +

[Alias('RepositoryUrl')]

338 +

[string] $Uri,

339 + 340 +

[Parameter(

341 +

Mandatory,

342 +

Position = 3)]

343 +

[ValidateNotNullOrEmpty()]

344 +

[string] $TargetOwnerName,

345 + 346 +

[Parameter(

347 +

Mandatory,

348 +

Position = 4)]

349 +

[ValidateNotNullOrEmpty()]

350 +

[string] $TargetRepositoryName,

351 + 352 +

[string] $Description,

353 + 354 +

[switch] $Private,

355 + 356 +

[string] $AccessToken,

357 + 358 +

[switch] $NoStatus

359 +

)

360 + 361 +

Write-InvocationLog

362 + 363 +

$elements = Resolve-RepositoryElements -BoundParameters $PSBoundParameters

364 +

$OwnerName = $elements.ownerName

365 + 366 +

$telemetryProperties = @{

367 +

RepositoryName = (Get-PiiSafeString -PlainText $RepositoryName)

368 +

OwnerName = (Get-PiiSafeString -PlainText $OwnerName)

369 +

TargetRepositoryName = (Get-PiiSafeString -PlainText $TargetRepositoryName)

370 +

TargetOwnerName = (Get-PiiSafeString -PlainText $TargetOwnerName)

371 +

}

372 + 373 +

$uriFragment = "repos/$OwnerName/$RepositoryName/generate"

374 + 375 +

$hashBody = @{

376 +

owner = $TargetOwnerName

377 +

name = $TargetRepositoryName

378 +

}

379 + 380 +

if ($PSBoundParameters.ContainsKey('Description')) { $hashBody['description'] = $Description }

381 +

if ($PSBoundParameters.ContainsKey('Private')) { $hashBody['private'] = $Private.ToBool() }

382 + 383 +

$params = @{

384 +

'UriFragment' = $uriFragment

385 +

'Body' = (ConvertTo-Json -InputObject $hashBody)

386 +

'Method' = 'Post'

387 +

'Description' = "Creating $TargetRepositoryName from Template"

388 +

'AcceptHeader' = $script:baptisteAcceptHeader

389 +

'AccessToken' = $AccessToken

390 +

'TelemetryEventName' = $MyInvocation.MyCommand.Name

391 +

'TelemetryProperties' = $telemetryProperties

392 +

'NoStatus' = (Resolve-ParameterWithDefaultConfigurationValue `

393 +

-BoundParameters $PSBoundParameters -Name NoStatus -ConfigValueName DefaultNoStatus)

394 +

}

395 + 396 +

return (Invoke-GHRestMethod @params | Add-GitHubRepositoryAdditionalProperties)

397 +

}

398 + 230 399

filter Remove-GitHubRepository

231 400

{

232 401

<#


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4