From 023a47de43c224f3b832d2a5e2337f23f52f491b Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Mon, 28 Dec 2020 13:22:32 +0100 Subject: [PATCH] Update Get-GitPullRequestLocal.ps1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated GetGit with better matching 🧉 --- .../Get-GitPullRequestLocal.ps1 | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Get-GitPullRequestLocal/Get-GitPullRequestLocal.ps1 b/Get-GitPullRequestLocal/Get-GitPullRequestLocal.ps1 index 8dd32ed..70d9a08 100644 --- a/Get-GitPullRequestLocal/Get-GitPullRequestLocal.ps1 +++ b/Get-GitPullRequestLocal/Get-GitPullRequestLocal.ps1 @@ -27,13 +27,20 @@ Will create a folder in C:\Temp named after the PR number, and clone the specifi #add validation here or in param block $Request = Invoke-WebRequest $Uri - - $Values = @{ - Folder = '{0}\{1}_PR{2}' -f $Path, (($Uri -replace '\/$').Split('/')[4]), (($Uri -replace '\/$').Split('/')[-1]) - GitHubUri = 'https://github.com/{0}' -f $Request.Links.Where{$_.class -match 'no-underline'}[-1].title.split(':')[0] - Branch = $Request.Links.Where{$_.class -match 'no-underline'}[-1].title.split(':')[1] + $Values = [ordered]@{ + CurrentRepo = (($Uri -replace '\/$').Split('/')[4]) + CurrentPR = (($Uri -replace '\/$').Split('/')[-1]) } + $Values.Folder = '{0}\{1}_PR{2}' -f $Path, $Values.CurrentRepo, $Values.CurrentPR + $Values.GitHubUri, $Values.Branch = $Request.Links.Where{ + $_.class -match 'no-underline' + }[-1..-10].Where{ + $_.title -match $Values.CurrentRepo + }[0].title.split(':') + $Values.GitHubUri = 'https://github.com/{0}' -f $Values.GitHubUri + + Write-Verbose ($Values | Out-String) Write-Information -Message "mkdir -Path $($Values.Folder)" try {