Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 80 additions & 2 deletions public/issues/Add-ProjectSubIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[Parameter()][string]$Owner,
[Parameter()][string]$ProjectNumber,
# [Parameter(Mandatory)][string]$IssueId,
[Parameter(Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline, Position = 0)][Alias("id")][string]$ItemId,
[Parameter(Mandatory, Position = 1)][string]$SubIssueUrl,
[Parameter(Mandatory, Position = 0)][string]$ItemId,
[Parameter(Mandatory, ValueFromPipeline, Position = 1)][Alias("url")][string]$SubIssueUrl,

Check warning

Code scanning / PSScriptAnalyzer

Command accepts pipeline input but has not defined a process block. Warning

Command accepts pipeline input but has not defined a process block.
[Parameter()][switch]$ReplaceParent
)

Expand Down Expand Up @@ -60,6 +60,84 @@

} Export-ModuleMember -Function Add-ProjectSubIssueDirect


function Add-ProjectSubissueCreate {

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Add-ProjectSubissueCreate' does not have a help comment. Note

The cmdlet 'Add-ProjectSubissueCreate' does not have a help comment.
[CmdletBinding()]
[Alias("New-Issue")]
param (
[Parameter(Mandatory, Position = 0)][string]$ItemId,
[Parameter(Position = 1)][string]$RepoOwner,
[Parameter(Position = 2)][string]$RepoName,
[Parameter(Mandatory, Position = 3)][string]$Title,
[Parameter(Position = 4)][string]$Body,

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
[Parameter()][string]$ProjectOwner,
[Parameter()][string]$ProjectNumber,

[Parameter()][switch]$OpenOnCreation,
[Parameter()][switch]$AddToProject
)

# Get Parent item
$ProjectOwner,$ProjectNumber = Get-OwnerAndProjectNumber -Owner $ProjectOwner -ProjectNumber $ProjectNumber
$item = Get-ProjectItem -ItemId $ItemId -Owner $ProjectOwner -ProjectNumber $ProjectNumber
if($null -eq $Item){
Write-MyError "Parent ItemId [$ItemId] not found on project $ProjectOwner/$ProjectNumber"
return
}

# resolve the repo
$repoO = ( [string]::IsNullOrWhiteSpace($RepoOwner) ) ? $item.RepositoryOwner : $RepoOwner
$repoN = ( [string]::IsNullOrWhiteSpace($RepoName) ) ? $item.RepositoryName : $RepoName

if([string]::IsNullOrWhiteSpace($repoO) -or [string]::IsNullOrWhiteSpace($repoN)){
Write-MyError "Repository owner and name are required"
return
}

#
$repo = Get-Repository -Owner $repoO -Name $repoN

if( ! $repo ) {
"Repository $repoO/$repoN not found" | Write-MyError
return $null
}

$params = @{
RepoName = $repoN
RepoOwner = $repoO
Title = $Title
Body = $Body
}

$url = New-ProjectIssueDirect @params
Write-Host $url

Check warning

Code scanning / PSScriptAnalyzer

File 'Add-ProjectSubIssue.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information. Warning

File 'Add-ProjectSubIssue.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.

$params = @{
Owner = $ProjectOwner
ProjectNumber = $ProjectNumber
SubIssueUrl = $url
ItemId = $ItemId
}
$result = Add-ProjectSubIssueDirect @params
if($result)
{ Write-MyHost "SubIssue added successfully" }
else {Write-MyError "Failed to add SubIssue" ; return}

# Add to project
if($AddToProject){
$subissueId = Add-ProjectItem -Url $url -Owner $ProjectOwner -ProjectNumber $ProjectNumber
Write-Host $subissueId

Check warning

Code scanning / PSScriptAnalyzer

File 'Add-ProjectSubIssue.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information. Warning

File 'Add-ProjectSubIssue.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
}

# Open
if($OpenOnCreation){
Open-Url -Url $url
}

} Export-ModuleMember -Function Add-ProjectSubissueCreate


function addSubIssue {
[cmdletbinding()]
param(
Expand Down
7 changes: 6 additions & 1 deletion public/issues/New-ProjectIssue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ function New-ProjectIssue {
[Parameter(Mandatory, Position = 1)][string]$RepoOwner,
[Parameter(Mandatory, Position = 2)][string]$RepoName,
[Parameter(Mandatory, Position = 3)][string]$Title,
[Parameter(Position = 4)][string]$Body
[Parameter(Position = 4)][string]$Body,
[Parameter()][switch]$OpenOnCreation
)

try{
Expand All @@ -71,6 +72,10 @@ function New-ProjectIssue {

$itemId = Add-ProjectItem -Owner $ProjectOwner -ProjectNumber $ProjectNumber -Url $url

if( $OpenOnCreation ) {
Open-Url $url
}

return $itemId
}
catch{
Expand Down
13 changes: 9 additions & 4 deletions public/items/use_order.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ function Use-Order {
[cmdletbinding()]
[Alias("uo")]
param(
[Parameter(Position = 0)][int]$Ordinal = -1,
[Parameter(ValueFromPipeline)][array]$List,
[Parameter()][switch]$OpenInEditor,
[Parameter(Position = 0)][Alias("o")][int]$Ordinal = -1,
[Parameter()][Alias("e")][switch]$OpenInEditor,
[Parameter()][Alias("w")][switch]$OpenInBrowser,
[Parameter()][switch]$PassThru,
[Parameter()][Alias("C")][switch]$ClearScreen
[Parameter()][Alias("p")][switch]$PassThru,
[Parameter()][Alias("c")][switch]$ClearScreen
)

begin {
Expand Down Expand Up @@ -43,6 +43,11 @@ function Use-Order {
# Show a particular item
$itemId = $finalList[$Ordinal].id

if($null -eq $itemId){
Write-MyError "Item with ordinal $Ordinal not found."
return
}

#return item
if($PassThru) {
$i = Get-ProjectItem -ItemId $itemId
Expand Down
Loading