Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #493 import-module loses previously stored configuration #508

Merged
merged 7 commits into from
May 20, 2023
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
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
## 7.13.0

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/515) from [mrwalters1988](https://github.com/mrwalters1988) the following:

- feat: added parameter for Add-VSTeamAccessControlEntry to choose whether to merge the Bits or to Overwrite the bits.

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/508) from [Miguel Nieto](https://github.com/mnieto) the following:
- Fix import-module loses previously stored configuration [493](https://github.com/MethodsAndPractices/vsteam/issues/493)

## 7.12.0


Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/506) from [Miguel Nieto](https://github.com/mnieto) the following:
- fix tests that involve dates fail when OS culture has 24 hours format

Expand All @@ -32,6 +35,10 @@ Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/502) fr
- Updated test c# project to .NET 6.0
- Fixed test fail on ubuntu-latest

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/508) from [Miguel Nieto](https://github.com/mnieto) the following:
- Fix import-module vsteam loses previously stored configuration: [issue #493](https://github.com/MethodsAndPractices/vsteam/issues/493)
- Fixed test Versions fail on local machine

mnieto marked this conversation as resolved.
Show resolved Hide resolved
## 7.9.0

Merged [Pull Request](https://github.com/MethodsAndPractices/vsteam/pull/481) from [Sebastian Schütze](https://github.com/SebastianSchuetze) the following:
Expand Down
3 changes: 3 additions & 0 deletions Source/Classes/Versions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public static void SetApiVersion(APIs service, string version)
case APIs.WorkItemTracking:
WorkItemTracking = version;
break;
case APIs.Version:
Version = version;
break;
}
}

Expand Down
26 changes: 20 additions & 6 deletions Source/VSTeam.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,32 @@ if ($null -ne $env:TEAM_PROJECT) {


# if not account and pat is set, then do not try to set the default project
if ($null -eq $env:TEAM_PAT -and $null -eq $env:TEAM_ACCT) {
Write-Warning "No PAT or Account set. You must set the environment variables TEAM_PAT or TEAM_ACCT before loading the module to use the default project."
if (($null -eq $env:TEAM_PAT -or $null -eq $env:TEAM_TOKEN) -and $null -eq $env:TEAM_ACCT) {
Write-Warning "No PAT or Account set. You must set the environment variables (TEAM_PAT or TEAM_TOKEN) and TEAM_ACCT before loading the module to use the default project."
}
else {
# set vsteam account to initialize given variables properly
Set-VSTeamAccount -Account $env:TEAM_ACCT -PersonalAccessToken $env:TEAM_PAT
$commonArgs = @{
Account = $env:TEAM_ACCT
Version = $env:TEAM_VERSION
}

if (_useBearerToken) {
$commonArgs.Add("UseBearerToken", $true)
$commonArgs.Add("PersonalAccessToken", $env:TEAM_TOKEN)
} else {
$pat = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($env:TEAM_PAT)) #decode base64 stored pat
$pat = $pat.Substring(1) #remove the leading :
$commonArgs.Add("PersonalAccessToken", $pat)
}
$defaultProject = $env:TEAM_PROJECT #save temporary defalt project because it's removed during Set-VSTeamAccount call
Set-VSTeamAccount @commonArgs
# Make sure the value in the environment variable still exisits.
if (Get-VSTeamProject | Where-Object ProjectName -eq $env:TEAM_PROJECT) {
Set-VSTeamDefaultProject -Project $env:TEAM_PROJECT
if (Get-VSTeamProject | Where-Object ProjectName -eq $defaultProject) {
Set-VSTeamDefaultProject -Project $defaultProject
}
else {
Write-Warning "The default project '$env:TEAM_PROJECT' stored in the environment variable TEAM_PROJECT does not exist."
Write-Warning "The default project '$defaultProject' stored in the environment variable TEAM_PROJECT does not exist."
}
}

Expand Down