From 874536a901df53b579d06ea6e69e7227622f35c5 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 18 Feb 2021 14:09:35 -0800 Subject: [PATCH 1/5] Trim off the target branch --- .../get-markdown-files-from-changed-files.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 6316fd1ce26..7df115d87ee 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -2,11 +2,15 @@ param ( # The root repo we scaned with. [string] $RootRepo = '$PSScriptRoot/../../..', # The target branch to compare with. - [string] $targetBranch = "origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" + [string] $targetBranch = "${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" ) -$deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) -$renamedFiles = (git diff $targetBranch HEAD --diff-filter=R) -$changedMarkdowns = (git diff $targetBranch HEAD --name-only -- '*.md') + +# Trim the "ref/head" for master branch +$targetBranch = $targetBranch -replace "refs/heads/" + +$deletedFiles = (git diff "origin/$targetBranch" HEAD --name-only --diff-filter=D) +$renamedFiles = (git diff "origin/$targetBranch" HEAD --diff-filter=R) +$changedMarkdowns = (git diff "origin/$targetBranch" HEAD --name-only -- '*.md') $beforeRenameFiles = @() # Retrieve the 'renamed from' files. Git command only returns back the files after rename. From 0f854562a82eab51bc7e5a04f5d0d44742107663 Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Thu, 18 Feb 2021 15:26:38 -0800 Subject: [PATCH 2/5] Update eng/common/scripts/get-markdown-files-from-changed-files.ps1 Co-authored-by: Wes Haggard --- eng/common/scripts/get-markdown-files-from-changed-files.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 7df115d87ee..d50e7edb7f8 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -2,7 +2,7 @@ param ( # The root repo we scaned with. [string] $RootRepo = '$PSScriptRoot/../../..', # The target branch to compare with. - [string] $targetBranch = "${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" + [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") ) # Trim the "ref/head" for master branch From 73edefe3a5e2e2cbb522e4240e265cabfeb65173 Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Thu, 18 Feb 2021 15:36:38 -0800 Subject: [PATCH 3/5] Update get-markdown-files-from-changed-files.ps1 --- .../scripts/get-markdown-files-from-changed-files.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index d50e7edb7f8..5fd1ed0ac7e 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -5,12 +5,9 @@ param ( [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") ) -# Trim the "ref/head" for master branch -$targetBranch = $targetBranch -replace "refs/heads/" - -$deletedFiles = (git diff "origin/$targetBranch" HEAD --name-only --diff-filter=D) -$renamedFiles = (git diff "origin/$targetBranch" HEAD --diff-filter=R) -$changedMarkdowns = (git diff "origin/$targetBranch" HEAD --name-only -- '*.md') +$deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) +$renamedFiles = (git diff $targetBranch HEAD --diff-filter=R) +$changedMarkdowns = (git diff $targetBranch HEAD --name-only -- '*.md') $beforeRenameFiles = @() # Retrieve the 'renamed from' files. Git command only returns back the files after rename. From 4913225aa63d13db4474aef0d1ef2bcb7fe3edd1 Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Thu, 18 Feb 2021 15:36:56 -0800 Subject: [PATCH 4/5] Update get-markdown-files-from-changed-files.ps1 --- eng/common/scripts/get-markdown-files-from-changed-files.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 5fd1ed0ac7e..84455e5ff1e 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -4,7 +4,6 @@ param ( # The target branch to compare with. [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") ) - $deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) $renamedFiles = (git diff $targetBranch HEAD --diff-filter=R) $changedMarkdowns = (git diff $targetBranch HEAD --name-only -- '*.md') From 06a43532d54d412fbd7b71564bd9e465d8688066 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Fri, 19 Feb 2021 10:40:57 -0800 Subject: [PATCH 5/5] Trim the slash --- eng/common/scripts/get-markdown-files-from-changed-files.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 84455e5ff1e..4e0d48bb87e 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -2,7 +2,7 @@ param ( # The root repo we scaned with. [string] $RootRepo = '$PSScriptRoot/../../..', # The target branch to compare with. - [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") + [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "/refs/heads/") ) $deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) $renamedFiles = (git diff $targetBranch HEAD --diff-filter=R)