MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)
https://methodsandpractices.github.io/vsteam-docs/
MIT License
442 stars 155 forks source link

adding update capabilities for classification nodes #470

Closed a11smiles closed 1 year ago

a11smiles commented 2 years ago

PR Summary

For the second bullet, consider the following scenario:

In a situation where I'm syncing two projects (e.g. copying iterations from one to another), the current implementation would require me to write the following if-else statement to check if dates are provided because it doesn't allow for a nullable DateTime.

    if ($null -eq $Node.InternalObject.Attributes.StartDate) {
         Add-VSTeamIteration -ProjectName $DestinationProject -Name $Node.Name -Path $Path
    } else {
         Add-VSTeamIteration -ProjectName $DestinationProject -Name $Node.Name -Path $Path -StartDate $Node.InternalObject.Attributes.StartDate -FinishDate $Node.InternalObject.Attributes.FinishDate
    }

Not allowing a nullable DateTime is okay if the node is net new. However, I have the write this if-else for pre-existing nodes when attempting to simply copy them.

[Add|Update]-VSTeamIteration

Params changed to the following:

[Parameter(Mandatory = $false)]
[Nullable[datetime]] $StartDate,

[Parameter(Mandatory = $false)]
[Nullable[datetime]] $FinishDate,

This also removes the need for these if statements. (Also, AzDO requires that if one date is set, the other MUST also be set. It won't allow a StartDate and not a FinishDate, and vice versa.)

if ($StartDate) {
    $params.StartDate = $StartDate
}

if ($FinishDate) {
    $params.FinishDate = $FinishDate
}

By making the above changes, I no longer need my original if-else statement. I can simply write the following one line and the null values are accepted.

Add-VSTeamIteration -ProjectName $DestinationProject -Name $Node.Name -Path $Path -StartDate $Node.InternalObject.Attributes.StartDate -FinishDate $Node.InternalObject.Attributes.FinishDate

PR Checklist

a11smiles commented 2 years ago

@SebastianSchuetze can you run the workflows please? I had a mistype in my unit tests. Thanks!

SebastianSchuetze commented 2 years ago

looks like you have green lights. I will review in the next few days.

SebastianSchuetze commented 1 year ago

@a11smiles anything I can help with to get this PR finished?

a11smiles commented 1 year ago

I wasn't sure how particular you guys were with 'return' vs. 'update'. Thanks for making the changes.